logo elektroda
logo elektroda
X
logo elektroda

BK7238 (T1-3S) Tuya 4-Gang Switch – Physical Buttons Stuck in LongPress Need Pull-Down Input Support

Xtr33m 342 12
ADVERTISEMENT
  • #1 21814405
    Xtr33m
    Level 2  
    Hello,

    I am using a Tuya T1-3S 4-gang switch module with BK7238 and flashed OpenBeken 1.18.247.

    Relay control via UI/MQTT works correctly, but physical wall switches do not work.

    Hardware details:

    Module: T1-3S

    MCU: BK7238

    Switch wiring: Common LIVE (active-HIGH)

    Original Tuya firmware worked fine with this wiring.

    Current Pin Mapping:

    Relays:

    P9 = Relay 1
    P24 = Relay 2
    P23 = Relay 3
    P6 = Relay 4


    Switch Inputs:

    P8 = Input CH1
    P10 = Input CH2
    P22 = Input CH4
    P26 = Input CH3


    Configured as:

    dInput / Btn / dInput_n tested
    Channel type = Toggle

    Problem:

    In OpenBeken log I constantly get:

    Button_OnLongPressHold


    on all button GPIOs:

    8, 10, 22, 26


    This happens even when no button is pressed.

    So OpenBeken always sees the inputs as "held", and no toggle event is generated.

    Root Cause (Suspected):

    My switches are wired as Active-HIGH (LIVE → switch → GPIO).

    BK7238 seems to only support internal pull-UP, not pull-DOWN.

    Because of this:

    GPIO idle state floats or stays HIGH

    No stable LOW state exists

    Long-press condition is triggered permanently

    Attempted Fix:

    Tried to use:

    PinMode 8 input_pulldown


    But received:

    Error: CMD PinMode NOT found

    Conclusion:

    It appears that BK7238 hardware does not support internal pull-down resistors, so active-HIGH common-live switch wiring cannot work without:

    External pulldown resistors (ex: 10k to GND), or

    Rewiring switches to dry-contact logic (GPIO → Switch → GND)

    Question:

    Is there any planned support for:

    Software pulldown emulation (if possible), or

    Better documentation for BK7238 input limitations with AC common-live Tuya boards?

    Thanks.


    AZIoT electric module in compact casing with labeled terminals and size 91x50x22 mm Wiring diagram of AZIOT controller with 4 switches and 4 loads connected
    Managed to flash it
    Electronic board with relays and Wi-Fi module on a wooden surface

    {
      "rl1_lv":"1",
      "netled_lv":"0",
      "bt1_pin":"8",
      "onoff_clear_t":"5",
      "net_trig":"1",
      "cd_flag2":"1",
      "ffc_select":"1",
      "nety_led":"0",
      "netled_pin":"11",
      "total_stat":"2",
      "bt1_lv":"1",
      "module":"T1-3S",
      "rl2_pin":"24",
      "light_status_select":"1",
      "bt2_lv":"1",
      "rl1_pin":"9",
      "rl4_lv":"1",
      "onoff_rst_m":"1",
      "rl3_pin":"23",
      "onoff_cnt":"7",
      "rl3_lv":"1",
      "onoff_n":"3",
      "rl4_pin":"6",
      "jv":"1.2.1",
      "pd_category":"1",
      "ext_bt_type":"3",
      "bt3_lv":"1",
      "reset_t":"5",
      "rl2_lv":"1",
      "ch_flag1":"1",
      "ch_flag3":"1",
      "bt4_pin":"22",
      "ch_flag4":"1",
      "bt3_pin":"26",
      "ch_cddpid1":"7",
      "ble_pair_time":"30",
      "clean_t":"5",
      "bt4_lv":"1",
      "zero_select":"0",
      "bt2_pin":"10",
      "ch_cddpid4":"10",
      "ch_cddpid2":"8",
      "ch_cddpid3":"9",
      "ch_num":"4",
      "ch_dpid3":"3",
      "ch_dpid4":"4",
      "netn_led":"1",
      "ch_dpid1":"1",
      "ch_dpid2":"2",
      "crc":"98"
    }



    Small electronic module with connectors and exposed wires on a dark surface
  • ADVERTISEMENT
  • #2 21815018
    p.kaczmarek2
    Moderator Smart Home
    So you basically want a button but with a programmable pull down resistor, not a pull up, like it has in obk?

    It's very, very hard to read your post with those extra lines formatting.

    Beken should just support programmable pull down resistors.

    Let's made a test - I changed buttons to use pulldowns instead of pullups, get binaries here:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1953
    Test both Btn and Btn_n.

    Do any of them works good for you?

    If yes, then I will later add dedicated roles, like, Btn_pd and Btn_pd_n. Still, let's try it first.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21815749
    Xtr33m
    Level 2  
    >>21815018

    Confirmed! The test firmware works. I set the pins to Button (with channels 1, 2, 3, 4) and the electrical issue is solved.

    However, I have rocker switches (latch), not push buttons. Currently, the Button role acts weirdly (it sees the switch as a 'long press' because it stays ON).

    Could you please add the TglChanOnTgl_pd (Toggle with Pull-Down) role? This would make my switches work perfectly.
  • #4 21815771
    p.kaczmarek2
    Moderator Smart Home
    Ahhh, so we need to add Btn_pd, Btn_pd_n, and TglChanOnTgl_pd?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21815783
    Xtr33m
    Level 2  
    >>21815771 Yes, I need both so that I can test both.

    Thanks
  • #6 21815887
    p.kaczmarek2
    Moderator Smart Home
    Ok, here build with 3 pd roles - button, button_n and tglontoggle:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1954
    Can you check, can we merge it into main release?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 21816681
    Xtr33m
    Level 2  
    >>21815887 Feedback on PR #1954: I flashed the new build and selected the TglChanOnTgl_pd role.

    However, it is not acting like a Toggle switch. It behaves like a Button. The logs are spamming: Info:GEN:22 Button_OnLongPressHold.

    It seems that TglChanOnTgl_pd is accidentally using the Button handler (interpreting the switch state as a Long Press) instead of the Toggle handler. Could you please check the mapping?
  • #8 21816953
    p.kaczmarek2
    Moderator Smart Home
    Are you sure? It passes self test for me:

    C code fragment with unit test function and SELFTEST_ASSERT calls

    I will try to investigate futher tomorrow.

    Added after 6 [hours] 16 [minutes]:

    Ahhh, I see a problem. I updated the PR.
    Helpful post? Buy me a coffee.
  • #9 21817672
    Xtr33m
    Level 2  
    >>21816953

    Now everything works perfectly.

    Thanks for your time.
  • Helpful post
    #10 21818815
    p.kaczmarek2
    Moderator Smart Home
    Thank you, the changes are now merged into the main codebase!

    Can we close the issue now, or can I somehow help you futher? Do you have any other feature suggestions for our firmware?
    Helpful post? Buy me a coffee.
  • #11 21819480
    Xtr33m
    Level 2  
    >>21818815

    Sure, you can close the issue.

    I will DM you some more suggestions.
  • #12 21819521
    p.kaczmarek2
    Moderator Smart Home
    You can just open new topic with suggestions, so other people can also have their vote.
    Helpful post? Buy me a coffee.
  • #13 21821015
    belveder79
    Level 4  
    >>21819521 Note that this did not solve the issue on this one >>21821007.

Topic summary

The discussion addresses an issue with the Tuya T1-3S 4-gang switch module based on the BK7238 MCU running OpenBeken firmware version 1.18.247. While relay control via UI and MQTT functions correctly, the physical wall switches wired as active-HIGH (common LIVE) inputs do not operate properly. The OpenBeken firmware continuously registers "Button_OnLongPressHold" events on all input GPIOs (P8, P10, P22, P26) even when no buttons are pressed, indicating the inputs are always detected as held. The root cause is suspected to be the BK7238's lack of internal pull-down resistor support, as it only supports internal pull-up resistors. This hardware limitation conflicts with the active-HIGH wiring scheme, causing the firmware to misinterpret the input state. The pin mapping for relays and inputs is specified, and the input channels are configured as toggle type with various input modes tested (dInput, Btn, dInput_n). The original Tuya firmware handled the wiring correctly, highlighting a firmware or hardware compatibility issue with OpenBeken on BK7238 for active-HIGH switch inputs without pull-down support.
Summary generated by the language model.
ADVERTISEMENT