logo elektroda
logo elektroda
X
logo elektroda

Template for Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller

torte 1512 14
ADVERTISEMENT
  • #1 21029166
    torte
    Level 3  
    https://www.aliexpress.us/item/10050060833418...ain.24.33be5c5fya5BlM&gatewayAdapt=4itemAdapt
    Hello,

    I have flashed the Beken firmware to the device, but I failed to copy the template from the original device.
    Now I can manage the single click on both buttons, but I can't manage the battery status and double or long click.
    Can anyone help me?
    ThankYou
    Torsten

    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231N",
    "board": "TODO",
    "flags": "1024",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "16": "dInput;47",
    "20": "dInput;43",
    "26": "Rel;37"
    },
    "command": "PowerSave 1",
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }


    Template for Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller Template for Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller Template for Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller Template for Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller
  • ADVERTISEMENT
  • Helpful post
    #2 21030110
    divadiow
    Level 34  
    Ha. You beat me to the first post of this device. I dumped and flashed one of these last week and was working on an autoexec to complete the button usefulness in home assistant. I'll post what I have tomorrow, but from memory BAT_ADC is P23 (as always) and BAT_Rel is P17. The measurements will be ~300mA too high until further config.

    Added after 10 [minutes]:

    Also. It's clear this scene switch build shares some pcb/chassis moulds with this https://www.elektroda.com/rtvforum/topic4042463.html

    Which I thought was interesting
  • ADVERTISEMENT
  • #3 21030167
    torte
    Level 3  

    Great!
    Screen view of a user interface showing control status and battery level.

    Battery is working now.
  • Helpful post
    #4 21030248
    divadiow
    Level 34  
    great.

    so I haven't actually got that far. I'm still not that familiar with HA/MQTT.

    What does your autoexec look like? I was thinking about using this device to control lounge light, single presses of a button to turn on/off but then longer presses of 1 or 2 buttons to dim/brighten. Thing is, if you use the device on battery you'll want it to wake from deep sleep on button push, connect to MQTT, then send your actions all in a very short space of time or it'll be frustrating waiting for your actions to be effective. I'm not waiting 5s to turn the light on!

    Or, more likely, I was going to make a hole in the back of the device and solder in an AMS117/USB 5V cable to give a constant 3v or 3.3v, so it's always on.

    if on battery I'd want something to make it go into safe mode. that battery_setup is what gave me accurate battery voltage at 100% - I was powering it from a 3v external PSU. my basic autoexec beginning:

    Code: Text
    Log in, to see the code


    Widget displaying battery level and voltage of the device.

    Battery-powered wireless switch connected to an electronic circuit on a workbench.

    Added after 29 [minutes]:

    pics and things for the library/device list

    Wireless two-key switch and its box on a wooden surface. View of AAA batteries in an electronic device Close-up of an electronic module Model CBU on a PCB, showing pins and markings. Part of a device casing with the model designation LKWSW201_0202. Interior of a plastic battery compartment showing slots for two AAA batteries. Printed circuit board with buttons and electronic components. Printed circuit board with electronic components. Close-up of an electronic module with wires and soldered connections. Box of a Wi-Fi-enabled two-key remote. Notification of adding Wireless Switch device in the app. App interface for managing a wireless smart switch with different gesture clicks. Action selection menu for a wireless switch with options: Single Click, Long Press, Cancel. App screen showing no updates available.

    UART boot output

    Code: Text
    Log in, to see the code


    Tuya API

    Code: Text
    Log in, to see the code


    Code: JSON
    Log in, to see the code


    JSON
    Code: JSON
    Log in, to see the code


    https://github.com/OpenBekenIOT/webapp/pull/9...mits/c79c58d37697358f7ec4b6eb263d08038c0c2c26

    Device uses a custom firmware, so no GPIO extraction in Easy Flasher
  • #5 21031178
    torte
    Level 3  

    Hi,

    I am very very new to the beken devices. This was the first time I flashed one.
    So I have zero idea :-)
    I only got this so far by reading here in the forum and youtube.
    My Autoexec.bat only contains "PowerSave 1"
    The batteries have lost 18% since yesterday.
    I will now try your Autoexec.

    But you can't do the double or long clicks, can you?
    I plan to use the switch for a roller shutter, a click is then up or down by step double click would then be automatically up or down

    Thank You
    Torsten
  • #6 21031184
    divadiow
    Level 34  
    Ah yes. We need a lot more to finish setup. Powersave 1 will not be enough to stop the batteries dying within a day or two.

    My device is not of use so far. I'll do some more playing.
  • #7 21031231
    torte
    Level 3  
    I tried the template and the buttons no longer worked for me.
    pin 16 is set to 47
    pin 20 is at 43

    :-)
    I locked myself out and removed the two slashes before the deep sleep 600 :-)
    thinking before doing is sometimes better
  • ADVERTISEMENT
  • Helpful post
    #8 21031239
    divadiow
    Level 34  
    ha, yes. does the safe mode button hold work? i've not tested that yet. you can always go into safe mode by removing power 5 times. it will broadcast AP when in safe mode
  • #9 21031359
    torte
    Level 3  

    your template also works
    hold button has not activated the save mode.

    pin 16, 20 works with 5, 6, 47, 43



    Screen displaying status of various switches and battery information.
  • Helpful post
    #10 21031367
    divadiow
    Level 34  
    yes. mostly the channel # doesn't matter as long as theyre different (with some exceptions).

    for example, this would be a working channel assignment for a simple device with one push button, one LED and one relay, where you want the LED to come on when you push the button to close the relay

    "6": "Btn;1",
    "7": "LED;1",
    "24": "Rel;1"

    Added after 10 [minutes]:

    to start us off we need to review this and make use of timer and button wake from deep sleep https://www.elektroda.com/rtvforum/topic4041971.html#21000316

    other posts around that contain the necessary config will be about battery powered temperature/humidity sensors and door/windows sensors. we should be able to adapt some of the relevant autoexec bits for us from those.

    Added after 3 [minutes]:

    so already we can see we should use pindeepsleep or pindeepsleep with timer

    Added after 10 [hours] 29 [minutes]:

    I'm slightly worried that however we set it up to work with batteries that we won't get it to wake, connect to wifi, wait for mqtt and send commands quickly enough to be useful/not annoying. Even if you set a static IP on the device so you're not waiting on DHCP.

    It would be good to see how quickly you could get achieve this with OBK (don't know Tuya do this to be so quick) but I may just pursue using it on 5v USB so it's always powered. Then I don't have to care about battery and deepsleep.

    Added after 46 [seconds]:

    Unless anyone else wants to chime in to say it *can* be achieved, with decent results, on battery.
  • #11 21176455
    hutchpe
    Level 1  
    I've managed to get simple functionality working with PinDeepSleep using the following pinout and autoexec.bat, haven't tested battery life yet.

    Code: JSON
    Log in, to see the code


    Code: Text
    Log in, to see the code
  • #12 21520643
    glate
    Level 2  
    For the life of me I can't get this switch to boot into download mode. There's not a ton of information about this specific switch so I thought I'd reach out in case any of you are willing to share some tips.

    Thanks in advance.
  • ADVERTISEMENT
  • #13 21520881
    divadiow
    Level 34  
    >>21520643

    what does your wiring look like? how are you powering the device/module?
  • #14 21521306
    glate
    Level 2  
    >>21520881

    I have the switch connected to a breadboard and a Sparkfun AP63203 - I had it connected to a cheap power supply but the voltage drop wasn't giving me confidence so I moved to use the buck converter.

    I only have one USB/UART adapter.

    Things I'm unsure of:
    1. I'm unsure whether I should have a common ground between my (single) usb/uart adapter and the power supply connected to GND. I've tried both ways.
    2. Some sites say I should connect SWS to ground as well?
    3. If I need to solder directly to the chip, if the pin headers are sufficient or if I have to desolder the CBU (scary)

    I've tried swapping TX/RX multiple times, etc. I can get boot logs off TX1/RX1 (pins 10 and 11) but besides that nothing. Have tried with both ltchiptool and BK7231Flasher.

    Pics:
    A breadboard with connected jumper wires, a UART module, and a push button, all set on a desk next to a keyboard.

    Electronic board with connected wires and visible programming pins.

    Thanks very much.

    Added after 7 [hours] 4 [minutes]:

    after all that it turns out the jumpers on my usb adapter had been bumped and it was in TTL to 232 mode. Overly complicated a simple process. Thanks!

Topic summary

The discussion revolves around the Tuya Smart Push Button Switch 2Gang 6 Scene Wireless Smart Home Remote Controller, specifically issues related to flashing Beken firmware and configuring button functionalities. The user, Torsten, successfully managed single-click operations but struggled with battery status and double/long click functionalities. Other participants shared insights on pin configurations, battery management, and autoexec scripts to enhance device performance. Suggestions included using specific pins for battery status and implementing deep sleep modes to conserve battery life. The conversation highlighted the need for a comprehensive setup to fully utilize the device's capabilities, including safe mode activation and button event handling.
Summary generated by the language model.
ADVERTISEMENT