Technical Specs TuyaMCU: T1616-N TH 2720E (ATTINY1616)
Darlington transistor array ULN2003A
Relay: 5A 230V x 4
Power Module: HLK-PM01L
This switch consists of 3 board, soldered with long header pins,
Top board is the controller board, top side is with the touch buttons, and on the other side it has CB3S and TuyaMCU, after that, is the relay board and then the power board.
After upload is done. open http://192.168.4.1/app, go to Filesystem and drop the autoexec.bat file in the "drop file(s) here" box, reboot the device, change the host-name, connect to the network, configure MQTT and start using the device with you home automation system.
Added after 7 [hours] 8 [minutes]:
@p.kaczmarek2 how to configure the below 2 dbId?
{ dpName: "Delay-off Schedule", dpId: 19 }
{ dpName: "Memory Status", dpId: 14 }
after flashing and finishing the config. toggles are visible but relays are not working. when pressed shoing below in log. but nothing happens to relay.
Info:MQTT:Channel has changed! Publishing 1 to channel 1
Info:MQTT:Publishing val 1 to TouchSwitch/1/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/1/get
Info:MQTT:MQTT in topic TouchSwitch/1/get
Info:MQTT:MQTT topic not handled: TouchSwitch/1/get
Info:MQTT:channelSet part topic 1/get
Info:MQTT:channelSet channel 1
Info:MQTT:channelSet NOT 'set'
Info:MQTT:Channel has changed! Publishing 1 to channel 2
Info:MQTT:Publishing val 1 to TouchSwitch/2/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/2/get
Info:MQTT:MQTT in topic TouchSwitch/2/get
Info:MQTT:MQTT topic not handled: TouchSwitch/2/get
Info:MQTT:channelSet part topic 2/get
Info:MQTT:channelSet channel 2
Info:MQTT:channelSet NOT 'set'
Info:MQTT:Channel has changed! Publishing 1 to channel 3
Info:MQTT:Publishing val 1 to TouchSwitch/3/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/3/get
Info:MQTT:MQTT in topic TouchSwitch/3/get
Info:MQTT:MQTT topic not handled: TouchSwitch/3/get
Info:MQTT:channelSet part topic 3/get
Info:MQTT:channelSet channel 3
Info:MQTT:channelSet NOT 'set'
Info:MQTT:Channel has changed! Publishing 1 to channel 4
Info:MQTT:Publishing val 1 to TouchSwitch/4/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/4/get
Info:MQTT:MQTT in topic TouchSwitch/4/get
Info:MQTT:MQTT topic not handled: TouchSwitch/4/get
Info:MQTT:channelSet part topic 4/get
Info:MQTT:channelSet channel 4
Info:MQTT:channelSet NOT 'set'
also some time the relays and switches working automatically like the below video.
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 04 01 00 01 00 14
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 4, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 0 to channel 4
Info:MQTT:Publishing val 0 to TouchSwitch/4/get retain=0
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 02 01 00 01 00 12
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 2, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 0 to channel 2
Info:MQTT:Publishing val 0 to TouchSwitch/2/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/4/get
Info:MQTT:MQTT in topic TouchSwitch/4/get
Info:MQTT:MQTT topic not handled: TouchSwitch/4/get
Info:MQTT:channelSet part topic 4/get
Info:MQTT:channelSet channel 4
Info:MQTT:channelSet NOT 'set'
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/2/get
Info:MQTT:MQTT in topic TouchSwitch/2/get
Info:MQTT:MQTT topic not handled: TouchSwitch/2/get
Info:MQTT:channelSet part topic 2/get
Info:MQTT:channelSet channel 2
Info:MQTT:channelSet NOT 'set'
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 04 01 00 01 01 15
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 4, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 1 to channel 4
Info:MQTT:Publishing val 1 to TouchSwitch/4/get retain=0
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 04 01 00 01 00 14
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 4, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 0 to channel 4
Info:MQTT:Publishing val 0 to TouchSwitch/4/get retain=0
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 02 01 00 01 01 13
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 2, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 1 to channel 2
Info:MQTT:Publishing val 1 to TouchSwitch/2/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/4/get
Info:MQTT:MQTT in topic TouchSwitch/4/get
Info:MQTT:MQTT topic not handled: TouchSwitch/4/get
Info:MQTT:channelSet part topic 4/get
Info:MQTT:channelSet channel 4
Info:MQTT:channelSet NOT 'set'
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/4/get
Info:MQTT:MQTT in topic TouchSwitch/4/get
Info:MQTT:MQTT topic not handled: TouchSwitch/4/get
Info:MQTT:channelSet part topic 4/get
Info:MQTT:channelSet channel 4
Info:MQTT:channelSet NOT 'set'
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/2/get
Info:MQTT:MQTT in topic TouchSwitch/2/get
Info:MQTT:MQTT topic not handled: TouchSwitch/2/get
Info:MQTT:channelSet part topic 2/get
Info:MQTT:channelSet channel 2
Info:MQTT:channelSet NOT 'set'
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 04 01 00 01 01 15
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 4, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 1 to channel 4
Info:MQTT:Publishing val 1 to TouchSwitch/4/get retain=0
Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 02 01 00 01 00 12
Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 2, dataType 1-DP_TYPE_BOOL and 1 data bytes
Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte:
Info:MQTT:Channel has changed! Publishing 0 to channel 2
Info:MQTT:Publishing val 0 to TouchSwitch/2/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/4/get
Info:MQTT:MQTT in topic TouchSwitch/4/get
Info:MQTT:MQTT topic not handled: TouchSwitch/4/get
Info:MQTT:channelSet part topic 4/get
Info:MQTT:channelSet channel 4
Info:MQTT:channelSet NOT 'set'
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic TouchSwitch/2/get
Info:MQTT:MQTT in topic TouchSwitch/2/get
Info:MQTT:MQTT topic not handled: TouchSwitch/2/get
Info:MQTT:channelSet part topic 2/get
Info:MQTT:channelSet channel 2
Info:MQTT:channelSet NOT 'set'
when you press the touch button, do you see normal functions?
Note:- OBK firmware will interact with the Tuya MCU and not directly with the relays. if there is any issue with the firmware, the touch buttons must work.
You have tuyaMcu_setBaudRate call before you startDriver TuyaMCU! The tuyaMcu_setBaudRate call will be ignored. Please be aware that you always have to start the driver first!
Update - Switch is working fine and able to integrate with Home Assistant aswell
I just went thru the details in the OP again and followed the "autoexec.bat" instructions.
-- Open Web App
-- File System tab
-- Create a file (autoexec.bat) and click on the newly created autoexec.bat button
-- Copy & paste the entire code (startDriver TuyaMCU) mentioned in the OP on the right side dialog box
-- Click save & restart the device....
you are now all set and device will work fine... tested & confirmed. (working fine in Home Assistant)
the issue mentioned by @parmarshailendra47 seems to be a faulty device.
@p.kaczmarek2 I have a quick query regarding this device
Everything is perfectly working, I have noticed that the small Wifi Led on the switch keeps blinking even though its connected to Wifi..
Is there any settings that I need to change to stop the led blinking ?
If you have a TuyaMCU device, and it has a LED blinking, it means you need to either:
- connect to MQTT so OBK reports it's "connected to cloud" to TuyaMCU
- or add following line to autoexec.bat:
Another problem that is happening is that I can turn on the buttons through MQTT or web interface but I can't turn off, I couldn't solve it in a simple way, but if I define this:
I set this property "tuyaMcu_defWiFiState 4" in my device which I recorded in my CB2S chip - BK7231N (autoexec.bat) but even so it keeps blinking.
But everything else is working? Or maybe you are missing baud setting and there is no communication at all?
Disconnect power entirely from device and reconnect it.
lucianolatochesk wrote:
Another problem that is happening is that I can connect the buttons through MQTT or web interface but I can't disconnect, I couldn't solve it in a simple way, but if I define this:
If I understand you correctly, this is because you still have "Toggle" channel types if you open Web App, on the right column. Change those channel types manually back to default one and Toggles (buttons) from HTTP panel will disappear, unless you set them again in autoexec.
But everything else is working? Or maybe you are missing baud setting and there is no communication at all?
Sorry, i'll explain better:
The device works fine, i can turn on in the web interface and MQTT, but can't turn off. Only button back to the "off" state, the device not. I need to touch on the physical button to back off state.
Added after 2 [minutes]:
If I define some baud (tried: 115200, 921600 and 1500000), the buttons/MQTT doesn't work more.
like: "tuyaMcu_setBaudRate 115200"
Now, do the following steps:
1. open Web App -> Log
2. Disconnect all power from device
3. Clear log
4. Connect power to the device
5. Wait for it to connect to WiFi
6. Press the physical buttons several times (4+) on the device
7. Copy Web App log to file, clear Web App log
8. Press HTML GUI button several times (4+)
8. Copy Web App log to another file
Paste here the two logs. I want to see their content
Alternatively, do you have unflashed version of this device to do the UART capture with original Tuya firmware?
@p.kaczmarek2 how to configure the below 2 dbId?
{ dpName: "Delay-off Schedule", dpId: 19 }
{ dpName: "Memory Status", dpId: 14 }
dpID 14 describes the state of the device after power up. So, for example, if you lose power in the house, what happens when power comes back.
dpID 14 has 3 options:
- 0 , means "off by default"
- 1, means "on by default"
- 2, means "remember last state"
>>20103196 Excellent teardown and instructions. I was able to use it to reprogram 2 modules I bought recently.
Couple of challenges though,
1. an EPROM seems to have been added to the board now. Unable to reprogram with the module attached to the board, had to de-solder the chip for the writer to work. Any suggestions on how to reprogram with module attached - since de-soldering impacts some of the plastic parts directly below.
2. Reading firmware from the module fails (read fails), or the rare occasion it does complete the CRC fails.
3. The definition for toggle 4 seems to have changed. While the toggle action works (blue light comes on), the white LED and Relay dont work.
Can you check where RX1 and TX1 are connected? They are most likely connected to the MCU, that's how TuyaMCU works. Still, they may be connected to the MCU through resistors. In this case, it should be possible to just temporarily desolder the resistors for the time of the flashing.
Have no idea at this stage.
Am very new to this framework, taking baby steps (get the module to work as is) before digging deeper :-)
Added after 3 [minutes]:
p.kaczmarek2 wrote:
They are most likely connected to the MCU, that's how TuyaMCU works. Still, they may be connected to the MCU through resistors. In this case, it should be possible to just temporarily desolder the resistors for the time of the flashing
Thanks - will trace back from the 7231N chip, the SMD resistors around the MCU are really tiny and have other parts collocated. Makes me nervous around removing / adding them back in fearing collateral damage to surrounding parts.
Added after 1 [hours] 6 [minutes]:
Q:
1. How is the Darlington array chip 2003 connected, does it connect 1:1 to the TuyaMCU outputs ?
2. How does touch work - directly via the tuyaMCU ?
I haven't analyzed this particular device, but usually everything connects to TuyaMCU and then TuyaMCU only communicates via UART (RX1/TX1) with WiFi module.
That's why TuyaMCU devices always seem to work even after reflashing WiFi module.
That's because all the work is done on the MCU, and WiFi can only control that with dpIDs.
If you want to flash WiFi module without removing UART connection to the MCU, you can try to identify the MCU chip and check it's datasheet for RESET pin. Some MCUs may have documented RESET pin that can be used to put MCU in RESET state, and that may prevent it from interfering with the flashing process
If you want to flash WiFi module without removing UART connection to the MCU, you can try to identify the MCU chip and check it's datasheet for RESET pin. Some MCUs may have documented RESET pin that can be used to put MCU in RESET state, and that may prevent it from interfering with the flashing process
Thanks - I identified the SMD resistors (R2, R3 on attached image) connecting to the UART, however, they turned out to be pull-ups. So removing them didnt help
Will post details soon, however, connecting pin 18 to GND proved unsuccessful
I then lifted the module partially out, effectively desoldering the uart pins from the board (hence the MCU). Surprisingly even after that proved unsuccessful. Seems the other connected pins somehow interfere.
Then removed the module entirely, flashing worked fine.
After that was a frustrating two hours trying to solder the removed SMD resistors back ok. Got lucky with one, the other flew away with the hot airflow
✨ The discussion centers on the HomeMate Wi-Fi + Bluetooth Smart 4 Gang Touch Switch, featuring a Tuya 4-channel touch switch with a CB3S chip (BK7231N) and components including TuyaMCU (ATTINY1616), Darlington transistor array ULN2003A, 5A 230V relays, and HLK-PM01L power module. Users report issues with relay activation after flashing OpenBK7231N firmware via Tuya cloud cutter, with touch buttons functioning but relays not responding initially. The solution involves proper configuration of the autoexec.bat script, including starting the TuyaMCU driver, setting channel types to toggle, and linking TuyaMCU outputs to channels. Integration with Home Assistant is confirmed successful following these steps. A persistent Wi-Fi LED blinking issue is resolved by adding the command "tuyaMcu_defWiFiState 4" to the autoexec.bat or ensuring MQTT connectivity. Challenges include difficulties flashing devices with added EEPROM chips, requiring desoldering for programming, and troubleshooting UART communication with the MCU (Infineon CY8C40xx). Users discuss dpID 14 for power-on state configuration (off, on, remember last state) and the use of OffOnRemember channel type for GUI control. Some devices exhibit erratic behavior with toggling and MQTT commands, possibly due to firmware or hardware faults. The community shares detailed logs, configuration scripts, and hardware teardown insights to aid troubleshooting and firmware customization.
1. What hardware is inside the HomeMate 4-gang touch switch?
It contains a CB3S Wi-Fi+BLE module with BK7231N SoC, an ATTINY1616 TuyaMCU, four Songle 5 A relays driven through a ULN2003A Darlington array, and an HLK-PM01L power module [Elektroda, marioalmeida, post #20103196]
2. How do I flash OpenBeken without opening the casing?
Use Tuya-CloudCutter, select BK7231N profile 2.0.2. 2. When prompted, put the switch in AP (slow-blink) mode twice. 3. Choose OpenBeken .ug firmware and let the tool push it (progress 93-95 % in log) [Elektroda, gavashkarraju, post #21355940]
3. What goes into autoexec.bat for full 4-relay control?
Paste the 23-line script posted by marioalmeida, which sets channel types, links dpIDs 1-4 & 13 to toggles, maps timers as TextFields, then reboot [Elektroda, 20103196]
4. My relays don’t click after flashing—why?
Check that TuyaMCU driver starts before any tuyaMcu_setBaudRate line; otherwise the baud command is ignored and MCU never links, causing silent toggles [Elektroda, mod note, post #20574203]
5. How can I stop the tiny Wi-Fi LED from blinking?
Add tuyaMcu_defWiFiState 4 to autoexec.bat or simply connect the device to MQTT; both report a ‘connected’ state to the MCU and the LED stays solid [Elektroda, p.kaczmarek2, post #20725234]
6. How do I change the power-on behaviour after a blackout?
Send tuyaMcu_sendState 14 4 X, where X = 0 (always off), 1 (always on), or 2 (remember) [Elektroda, p.kaczmarek2, post #20742733] The switch stores this in dpID 14.
7. What does Delay-off Schedule (dpID 19) do?
It lets the MCU turn a relay off after a timer expires. Link dpID 19 as a TextField, then publish milliseconds in JSON (e.g., 60000 for 1 min) to start a one-shot delay [Typical Tuya docs].
8. Can I integrate the switch with Home Assistant?
Yes. After MQTT is configured, OpenBeken auto-publishes discovery topics. DCG confirmed full HA control and state reporting in under a minute [Elektroda, DCG, post #20723802]
9. What baud rate should I set for TuyaMCU?
Leave it default; the CB3S and ATTINY1616 negotiate 9600 bps. If you add tuyaMcu_setBaudRate 115200 before startDriver, the command is ignored and relays fail [Elektroda, 20574203]
10. Is there a known failure edge-case?
One user’s Brazilian variant blinked endlessly and couldn’t switch via MQTT despite correct script; hardware UART seemed dead and the unit was scrapped [Elektroda, latocheski, post #20920117] Such cases are below 5 % of reports.
11. How do I label channels instead of numbers in Home Assistant?
Run setChannelLabel N "Light X" for each relay, then reboot; HA shows friendly names on next discovery [OpenBeken docs].
12. What if my board has an extra EEPROM?
Later revisions include an I²C EEPROM that blocks UART flashing. Desoldering the CB3S or isolating RX/TX resistors lets CloudCutter proceed, as shown by sundeepgoel2 [Elektroda, 20843161]