logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] Tuya switch with multiple buttons on single ADC pin

rishabmehta7 1173 12
ADVERTISEMENT
  • #1 20523046
    rishabmehta7
    Level 6  
    Hi Team,

    I have a 3 gang touch switch from Tuya similar to '3 Gang Switch (DS-103)' in the list. I was able to use this profile to install the Open Beken using Cloud Cutter.
    The problem is the pin layout of the device in the profile did not work. I manually figured out the pins for WiFi LED along with the 3 Relays. What I noticed was all 3 touch buttons are connected to the same GPIO PIN P23.
    This is the Analog pin, Seeting this to Temp I was able to measure the values as follows.
    no button 4095 C
    1st button 1604 C
    2nd button 897 C
    3rd button 2 C
    1st and 2nd 602 C
    1st and 3rd 4 C
    2nd and 3rd 3 C

    Is there any way to use the touch switch reliably?

    I am attaching the factory bin file along with the PCB pictures.

    Current Pin
    P7 Relay 1
    P8 Relay 2
    P22 WiFiLED
    P24 Relay 0

    Added packaging pictures.

    -Rishab
  • ADVERTISEMENT
  • #2 20523162
    p.kaczmarek2
    Moderator Smart Home
    Hello, I haven't seen such a switch yet, but using ADC to handle multiple buttons is a known practice.

    I can add support for such mechanism for you, I'd just need a few days.

    Futhermore, can you give us more information where did you get that switch and what kind of switch model is it?

    It would be also also helpful if you've checked the way resistors are arranged on ADC pins, but that's not necessary.

    PS: If you want a temporary, quick solution, it should be also possible to create a simple script mechanism for that, but I don't think it's necessary.
    Helpful post? Buy me a coffee.
  • #3 20523180
    rishabmehta7
    Level 6  
    Appreciate all your help. Will find the Alibaba listing for the same.
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #5 20538721
    rishabmehta7
    Level 6  
    >>20523162
    Hi

    Any update?
  • #6 20538794
    p.kaczmarek2
    Moderator Smart Home
    I will try to look into it today. Yesterday I had some work with TM1637/GN6932 driver.
    Helpful post? Buy me a coffee.
  • #7 20538806
    rishabmehta7
    Level 6  
    Did not mean to rush you. Please take ur time.
  • #8 20539846
    p.kaczmarek2
    Moderator Smart Home
    Hello, I didn't have time to test, but I will push a test version of a driver.

    Steps to setup:
    1. check ADC values for buttons

    You already gave me this:
    no button 4095 C
    1st button 1604 C
    2nd button 897 C
    3rd button 2 C

    2. Create margins between values (as average values):

    no button 4095 C
    2900
    1st button 1604 C
    1250
    2nd button 897 C
    450
    3rd button 2 C

    3.

    Set role ADCButton for ADC in Configure Module

    4. Write autoexec.bat:

    
    // start driver - always first
    startDriver ADCButton
    // setup map to choose button
    AB_Map 450 1250 2900
    
    // setup event handlers for buttons
    // when got "no button" reading - do nothing
    // addEventHandler OnADCButton 0 
    // on 1st button
    addEventHandler OnADCButton 1 toggleChannel 1
    // on 2nd button
    addEventHandler OnADCButton 2 toggleChannel 2
    // on 3rd button
    addEventHandler OnADCButton 3 toggleChannel 3
    

    Tested only in simulator:
    [BK7231T] Tuya switch with multiple buttons on single ADC pin

    Please test and let me know if it works

    I hope you know our scripting syntax.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #9 20539908
    rishabmehta7
    Level 6  
    Very new to OpenBeken, but I think I can figure this out (worked with Tasmota for a long time already). I will try this first thing in the morning (it's already 1 am).

    Thanks for all the help.
  • #10 20539998
    p.kaczmarek2
    Moderator Smart Home
    I will be pushing it to repository in 15 minutes.

    Autoexec.bat can be created in Web Application, LittleFS tab.
    Helpful post? Buy me a coffee.
  • #11 20541200
    rishabmehta7
    Level 6  
    So I tried with the latest build and the bat file. Seems to have some issues. Let me get a detailed video tomorrow.

    Should I use channel 1 2 3 for relay instead of 0 1 2? and leave 0 for ADC button?
  • Helpful post
    #12 20541682
    p.kaczmarek2
    Moderator Smart Home
    It doesn't matter, I think. You can use channel 10 for button to keep it far from relays, it won't be used anyway by firmware, firmware will read ADC internally.

    On the other hand, I've realized something and added a fix. Please update to latest version.
    Helpful post? Buy me a coffee.
  • Helpful post
    #13 20541973
    rishabmehta7
    Level 6  
    All Fixed!!!!!

    -----Pin Config-----
    P22WiFiLed0
    P24Relay0
    P07Relay1
    P08Relay2
    P23ADC_Button5


    -----Below is the final script-----
    // start driver - always first
    startDriver ADCButton
    // setup map to choose button
    AB_Map 450 1250 2900
    // setup event handlers for buttons
    // when got "no button" reading - do nothing
    // addEventHandler OnADCButton 0 
    // on 1st button
    addEventHandler OnADCButton 0 toggleChannel 2
    // on 2nd button
    addEventHandler OnADCButton 1 toggleChannel 1
    // on 3rd button
    addEventHandler OnADCButton 2 toggleChannel 0

Topic summary

A user inquired about a 3 gang touch switch from Tuya, specifically the '3 Gang Switch (DS-103)', which they successfully flashed with Open Beken using Cloud Cutter. However, they encountered issues with the pin layout, discovering that all three touch buttons are connected to a single ADC pin (P23). The user measured ADC values for each button and sought a reliable method to utilize the switch. Community members discussed the feasibility of using ADC for multiple buttons and provided a step-by-step guide to configure the switch, including setting up ADC values, creating margins, and writing an autoexec.bat script for button event handling. After several iterations and troubleshooting, a final configuration was established, successfully mapping the buttons and relays.
Summary generated by the language model.
ADVERTISEMENT