Hi all, I'm new to the tuya flashing world! I have two of the switches listed in this thread, but can't manage to flash them, they have firmware 1.3.10 v102. I wired them up like was shown in the first post of said thread.
I get several errors during the flashing process after repeatedly clicking the "write only" button, I added them at the bottom of this post. Things I tried:
- Swapped arduino nano for uno
- Used SoftwareSerial (see added code)
- Wiped arduinos and used Rx Tx pins with gnd and reset pins shorted (cant set baud rate with that setup)
- Tried standalone psu @ 3.3v instead of arduino 3.3v pin
- Tried hid_download_py and to flash through CMD, to no avail. It fails to set baud rate.
- Tried different USB ports
Does anyone have some advice? I ordered some USB to TTL uart bridge adapters to try instead of the arduinos but they'll take some time to arrive.
Arduino code:
Errors:
I get several errors during the flashing process after repeatedly clicking the "write only" button, I added them at the bottom of this post. Things I tried:
- Swapped arduino nano for uno
- Used SoftwareSerial (see added code)
- Wiped arduinos and used Rx Tx pins with gnd and reset pins shorted (cant set baud rate with that setup)
- Tried standalone psu @ 3.3v instead of arduino 3.3v pin
- Tried hid_download_py and to flash through CMD, to no avail. It fails to set baud rate.
- Tried different USB ports
Does anyone have some advice? I ordered some USB to TTL uart bridge adapters to try instead of the arduinos but they'll take some time to arrive.

Arduino code:
#include <SoftwareSerial.h>
// Define the pins for SoftwareSerial
SoftwareSerial tuyaSerial(9, 10); // RX, TX
void setup() {
// Start the hardware serial for communication with the PC
Serial.begin(115200);
// Start the software serial for communication with the Tuya WiFi chip
tuyaSerial.begin(115200);
}
void loop() {
// Read from PC and send to Tuya
if (Serial.available()) {
char c = Serial.read();
tuyaSerial.write(c);
}
// Read from Tuya and send to PC
if (tuyaSerial.available()) {
char c = tuyaSerial.read();
Serial.write(c);
}
}
Errors:
Starting flash new (no backup)!
Now is: Saturday, May 25, 2024 11:40:32 AM.
Flasher mode: BK7231N
Going to open port: COM7.
Serial port open!
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
Flash MID loaded: 1560EB
Will now search for Flash def in out database...
Flash def found! For: 1560EB
Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
Entering SetProtectState(True)...
sr: 0
sr: 0
final sr: 0
msk: 407c
cw: 0, sb: 2, lb: 5
bfd: 0
SetProtectState(True) success!
Reading file firmwares/OpenBK7231N_QIO_1.17.592.bin...
Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.592.bin...
Preparing to write data file to chip - resetting bus and baud...
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Failed to set baud rate!
Starting flash new (no backup)!
Now is: Saturday, May 25, 2024 11:40:39 AM.
Flasher mode: BK7231N
Going to open port: COM7.
Serial port open!
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
Flash MID loaded: 1560EB
Will now search for Flash def in out database...
Flash def found! For: 1560EB
Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
Entering SetProtectState(True)...
sr: 0
sr: 0
final sr: 0
msk: 407c
cw: 0, sb: 2, lb: 5
bfd: 0
SetProtectState(True) success!
Reading file firmwares/OpenBK7231N_QIO_1.17.592.bin...
Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.592.bin...
Preparing to write data file to chip - resetting bus and baud...
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
Flash MID loaded: 1560EB
Will now search for Flash def in out database...
Flash def found! For: 1560EB
Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
Entering SetProtectState(True)...
sr: 0
sr: 0
final sr: 0
msk: 407c
cw: 0, sb: 2, lb: 5
bfd: 0
SetProtectState(True) success!
Going to do erase, start 0, sec count 298!
Erasing sector 0... ok! Erasing sector 4096... ok! Erasing sector 8192... ok! Erasing sector 12288... ok! Erasing sector 16384... ok! Erasing sector 20480... ok! Erasing sector 24576... ok! Erasing sector 28672... ok! Erasing sector 32768... ok! Erasing sector 36864... ok! Erasing sector 40960... ok! Erasing sector 45056... Erasing sector 45056 failed!
Writing file data to chip failed.
Starting flash new (no backup)!
Now is: Saturday, May 25, 2024 11:41:35 AM.
Flasher mode: BK7231N
Going to open port: COM7.
Serial port open!
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
CheckRespond_FlashGetMID: bad value returned?
Failed to read device MID!
Reading file firmwares/OpenBK7231N_QIO_1.17.592.bin...
Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.592.bin...
Preparing to write data file to chip - resetting bus and baud...
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
CheckRespond_FlashGetMID: bad value returned?
Failed to read device MID!
Going to do erase, start 0, sec count 298!
Erasing sector 0... Erasing sector 0 failed!
Writing file data to chip failed.
Starting flash new (no backup)!
Now is: Saturday, May 25, 2024 11:42:06 AM.
Flasher mode: BK7231N
Going to open port: COM7.
Serial port open!
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
CheckRespond_FlashGetMID: bad value returned?
Failed to read device MID!
Reading file firmwares/OpenBK7231N_QIO_1.17.592.bin...
Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.592.bin...
Preparing to write data file to chip - resetting bus and baud...
Getting bus... (now, please do reboot by CEN or by power off/on)
Getting bus success!
Going to set baud rate setting (115200)!
Will try to read device flash MID (for unprotect N):
CheckRespond_FlashGetMID: bad value returned?
Failed to read device MID!
Going to do erase, start 0, sec count 298!
Erasing sector 0... ok! Erasing sector 4096... ok! Erasing sector 8192... ok! Erasing sector 12288... ok! Erasing sector 16384... ok! Erasing sector 20480... ok! Erasing sector 24576... ok! Erasing sector 28672... ok! Erasing sector 32768... ok! Erasing sector 36864... ok! Erasing sector 40960... ok! Erasing sector 45056... ok! Erasing sector 49152... ok! Erasing sector 53248... ok! Erasing sector 57344... ok! Erasing sector 61440... ok! Erasing sector 65536... ok! Erasing sector 69632... ok! Erasing sector 73728... ok! Erasing sector 77824... ok! Erasing sector 81920... ok! Erasing sector 86016... ok! Erasing sector 90112... ok! Erasing sector 94208... ok! Erasing sector 98304... ok! Erasing sector 102400... ok! Erasing sector 106496... ok! Erasing sector 110592... ok! Erasing sector 114688... ok! Erasing sector 118784... ok! Erasing sector 122880... ok! Erasing sector 126976... ok! Erasing sector 131072... ok! Erasing sector 135168... ok! Erasing sector 139264... ok! Erasing sector 143360... ok! Erasing sector 147456... ok! Erasing sector 151552... ok! Erasing sector 155648... ok! Erasing sector 159744... ok! Erasing sector 163840... ok! Erasing sector 167936... ok! Erasing sector 172032... ok! Erasing sector 176128... ok! Erasing sector 180224... ok! Erasing sector 184320... ok! Erasing sector 188416... ok! Erasing sector 192512... ok! Erasing sector 196608... ok! Erasing sector 200704... ok! Erasing sector 204800... ok! Erasing sector 208896... ok! Erasing sector 212992... ok! Erasing sector 217088... ok! Erasing sector 221184... ok! Erasing sector 225280... ok! Erasing sector 229376... ok! Erasing sector 233472... Erasing sector 233472 failed!
Writing file data to chip failed.