logo elektroda
logo elektroda
X
logo elektroda

How To Flash T34-Based Smart Switch from Aliexpress With Tasmota/Esphome style firmware OBK

Mati Crawn 11754 78
ADVERTISEMENT
  • #1 21062328
    Mati Crawn
    Level 9  
    The latest purchase from Aliexpress bring me 2 new type of the Smart Switch.

    Smart Switch with manufacturer's label and connectors.

    and
    Mini Smart Switch label with technical information.

    I've ordered 4 pc, and received in the same box two type :

    DIY Smart Switch box with Amazon Alexa, Google Assistant, and Tmall Genie logos.

    First release have the pushbutton on the back, the second on the front

    Close-up of a circuit board with electronic components in a plastic case.

    booth are equipped with the same base board, consist the power adapter, relay and T34 chip.

    Electronic module smart switch with visible components.

    The first try was with the Tuya Cloudcutter, finally i give up when I've found that the software installed there is as below - 1.3.10, on the other post i found information that this is not flashable by the cloud cutter ...

    Software update screen showing no newer version for the main module and other type.

    So when i opened the boxt i see that T34 is glued to the main board.

    Close-up of a smart switch baseboard with visible electronic components.

    View of the back side of a smart switch baseboard.

    the power taken from UART module i have connected as in the picture:
    GND- Violet
    3V3 - Violet+RED power

    Close-up of an electronic board with a relay and electronic components.

    the tricky part is to get access to the programming pins.

    the reference say:
    Diagram of the T34 circuit with pin and component labels.

    I need access to pins:
    T34 25 (RX) <- UART TX
    and
    T34 26 (TX) <- UART RX


    I've mount board in the bracket and preapre two "Needle arms" made with 1,5mm cooper wire and the sewing needle at the end.

    Close-up of an assembled electronic circuit with a smart relay and wires connected to programming pins.

    the next 30 min it took me to position the needle on the first board in the right way using magnifing glass to get the proper contact and force in the right direction.
    accidently scratching the pins by the sharp end of the needle i took an small piece of the solder between the pins what confused me for an while, so i recommend after placing pins (needles) on - to check with multimeter if they are not shortened just again good magnify glass help.

    Baseboard with connected wires and components.

    After first succesfull flash of the first one, the other 3 units took only 10 min to be also burn with new becken software via "bk7231flasher_1.1.6"


    the pin configuration is as follow:



    Code: JSON
    Log in, to see the code



    The P14 is the external S1-S2 input of the unit,
    while P24 in the internal switch build on the motherboard.
    The P16 LED output is negative type, while P15 relay is positive, but it depends to the needs.

    The rest is fine

    just added startup command "PowerSave 1" to save power ..

    Hope it shorten the way for someone ..
  • ADVERTISEMENT
  • #2 21062879
    divadiow
    Level 34  
    Good work. These T34s sure look fiddly. I wonder if any come with test/programming pads on the PCB, seems odd there aren't some. Not sure I've seen a T34 device yet with any.
  • #3 21121701
    baudneo
    Level 6  
    Thank you for your write up! I ordered 3 of the Zigbee version and received these T34 WiFi version (the one with the switch on the back). Going to try your method of the needle pin to flash them.
  • #4 21121760
    divadiow
    Level 34  
    you know I'd forgotten this method was already posted and that I'd already seen it before I did my T34 with needles. Good luck, it's fiddly but totally doable.

    Please post boot log and factory fw backup (if you want to).

    Added after 16 [minutes]:

    also, the pins for the OPs device are not seen on any other in the device list and it's different being T34 so:

    https://github.com/OpenBekenIOT/webapp/pull/126
  • #5 21195371
    zyklop
    Level 2  
    Great work!
    I changed the script on PIN 24 to toggle the relay each time to press, no need to hold it down.
    (your script has a " , " too much at the end.)
    I backed up one of them. File is at the end of this post !

    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Wifi Smart Switch",
    "model": "DIY",
    "chip": "BK7231N",
    "board": "T34",
    "flags": "0",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "6": "LED_n;0",
    "14": "TglChanOnTgl;0",
    "15": "Rel;0",
    "24": "Btn_Tgl_All;0"
    },
    "command": "",
    "image": "https://obrazki.elektroda.pl/5168873200_1714224899.png",    
     "wiki": "https://www.elektroda.com/rtvforum/topic4051203.html"
    }


    I had luck to flash easily 6 boards with this "sdcard rescue spider".
    Circuit board with electronic components on a workspace.


    tuya config in source file is from 1D4000   to   1D41C1 and shown as follows:

    {rl1_lv:1,on_off_cnt:10,onoff_rst_m:1,onoff_clear_t:10,rand_dpid:42,net_trig:4,onoff_n:5,netled1_lv:0,jv:110.0.0,onoff_rst_type:2,ffc_select:0,total_bt_pin:24,nety_led:2,total_stat:0,reset_t:5,netled1_pin:6,remote_add_dp:49,remote_list_dp:50,net_type:0,inch_dp:44,module:T34,ch_cddpid1:9,inch_en1:0,onoff1:14,clean_t:5,init_conf:38,zero_select:0,onoff_type:0,series_ctrl:0,total_bt_lv:0,cyc_dpid:43,ch_num:1,rl1_pin:15,netn_led:2,ch_dpid1:1,crc:83,}

    or sorted:

    {rl1_lv:1,
    on_off_cnt:10,
    onoff_rst_m:1,
    onoff_clear_t:10,
    rand_dpid:42,
    net_trig:4,
    onoff_n:5,
    netled1_lv:0,
    jv:110.0.0,
    onoff_rst_type:2,
    ffc_select:0,
    total_bt_pin:24,
    nety_led:2,
    total_stat:0,
    reset_t:5,
    netled1_pin:6,
    remote_add_dp:49,
    remote_list_dp:50,
    net_type:0,
    inch_dp:44,
    module:T34,
    ch_cddpid1:9,
    inch_en1:0,
    onoff1:14,
    clean_t:5,
    init_conf:38,
    zero_select:0,
    onoff_type:0,
    series_ctrl:0,
    total_bt_lv:0,
    cyc_dpid:43,
    ch_num:1,
    rl1_pin:15,
    netn_led:2,
    ch_dpid1:1,
    crc:83,}
  • ADVERTISEMENT
  • #6 21207982
    tmordalski
    Level 5  
    Computer screen displaying firmware update software. Laptop on desk displaying a circuit board. Dobra robota.
    Wielkie dzięki za ten temat. Jestem po wgrywaniu OB na kilku miniswitchach z Ali (T34)
    i wszystko działa super.
    Jestem zielony w te klocki z JSON, ale myślę, że to mały problem.
    Dla takich początkujących jak ja kilka spostrzeżeń
    1. Podczas wgrywania OB zatrzymywało mi "read" po zbyt szybkim podłączeniu 3.3V w celu resetu. Ale doszedłem do wprawy.
    2. Po zakończeniu flash wyskakiwał problem niezgodności conf obk czy coś takiego, ale po drugim flashu wszystko było ok.
    3. Ustawienia mosquitto pod żadnym pozorem nie należy używać polskich znaków, wtedy integracja z HA banalnie prosta.
    4. OB o wiele szybciej się paruje z wifi w porównaniu z Tasmotą (nie przeszkadza 5 GHz, przy Tasmocie muszę wyłączać radio 5G na routerze, ale to znany problem z
    routerami Asus )
    Bardzo dobra robota panowie.
    Worktable with a digital microscope over open electronics.
  • ADVERTISEMENT
  • #7 21223931
    mustafathamer85
    Level 3  
    >>21062328 Hi, @Mati Crawn sorry for this trivial question but I really couldn't manage to put the device in the flashing mode,,, is there any trick to do that?
  • #8 21224028
    tmordalski
    Level 5  
    >>21223931 Nigdy nie wiadomo, jak to działa, ja przerywałem zasilanie na sekundę, czasami na dłużej, musisz obserwować logi i pasek postępu na BK flasher. Gdy nie działa, sprawdź połączenia i czy poprawnie podłączyłeś Rx Tx do programatora.
  • #9 21224052
    baudneo
    Level 6  
    >>21223931

    I am also having issues getting it into flash mode. Have a sd spider board, so I'm pretty sure the connection is good. I've tried 2 different mini smart switches and can't get UART on either.

    Might need a microscope to make sure the connections are solid.
  • ADVERTISEMENT
  • #11 21224436
    baudneo
    Level 6  
    tmordalski wrote:
    >>21224052 Ja używam taniego mikroskopu usb (jak widać na zdjęciach) https://obrazki.elektroda.pl/5425301900_1724921161.jpg
    Pin 25 dotykam przy chipie, ale pin 26 dotykam na BR4. Close-up of a circuit board with microchips and electronic components.


    Thank you for the BR4 pad tip, that should make things easier. I am going to order one of those microscopes off AliExpress today!
  • #12 21224469
    p.kaczmarek2
    Moderator Smart Home
    @tmordalski on com domain, please use English. If you want to write in Polish, use PL domain. Otherwise it confuses our translator.

    If flashing is not working:
    - try to shorten your wires
    - use lower baud rate
    - make sure there is nothing on RX/TX pins, for example, like it happened on your video:
    https://www.youtube.com/watch?v=PKkiqDNFIx8
    - make sure that you have good LDO to power the WiFi module (from 3.3V)

    Recarding scopes, here is my test of a little one:
    https://www.elektroda.pl/rtvforum/topic3745278.html
    And here is my iPhone as zoom test:
    https://www.elektroda.pl/rtvforum/topic3959944.html

    Of course, you may need to use Google Translate to check those out!
    Helpful post? Buy me a coffee.
  • #13 21224821
    mustafathamer85
    Level 3  
    Thank you guys for the quick replies ... unfortunately I did manage to do it.... not short cct btw RX/TX everything seems ok but I couldn't get flashing mode ... every time I try to turn off/on the switch to enter the flashing mode, I get an error on the BK7231 Flash Tool (image below)
    I used the BK7231 Flash Tool v 1.1.6 and also v 1.3.3 (both throw same error)

    Screenshot of BK7231 Easy UART Flasher tool with an error. Close-up of a microcontroller on a PCB with connected probe wires.
  • #14 21224826
    p.kaczmarek2
    Moderator Smart Home
    You are doing the turn on/off incorrectly. The UART dongle should not reset when you turn on/off the device. By "turn on/off power" we mean that you should:
    - keep UART dongle in USB all the time
    - but disconnect/reconnect power to the device itself
    Long story short, your approach seems invalid.

    Alternatively, you may be doing a simple GND to VDD short which overloads and turns off your USB port. This is also possible.

    Can you show us your whole circuit (how is everything connected) so we can help you a bit more?
    Helpful post? Buy me a coffee.
  • #15 21224827
    divadiow
    Level 34  
    >>21224821

    got any broader pics of your whole wiring setup showing every length and start/finish of cable ends?

    also, I've had it before that when using external PSU and you turn on the whole PSU to get into flashing mode that the initial surge seems to not put the device into flashing mode. I now keep the PSU on but bring power to the device by inserting dupont into breadboard - so no PSU powering on surge.
  • #16 21224882
    mustafathamer85
    Level 3  
    @p.kaczmarek2 @divadiow thank you guys for the help ... I never pulled out the USB-TTL device ... it's always connected ... I only disconnect the 3V wire and reconnect it to emulate the turnoff/on process ..... but every time I disconnect/reconnect the 3V wire I hear the plug/unplug Ms windows sound .. it could be a driver problem ! anyway here is my connection: sorry @divadiow I couldn't take photo of the whole connections, I will do it when I will be back home Close-up view of connections on an electronic board with wires labeled GND, 3V, TX (TTL RX), and RX (TTL TX).
  • #17 21224931
    p.kaczmarek2
    Moderator Smart Home
    You are using too weak power supply and the inrush current (large amount of current that flows at the startup) caused by capacitors on the board are overloading your USB port. You need to either use a better power supply or to remove the large capacitor that is on the PCB. You can also try powering device from separate power supply so USB port is not overloaded.


    It is also still possible that you have a short and you just short GND to 3.3V, then it would also act the way you describe.
    Helpful post? Buy me a coffee.
  • #18 21225016
    mustafathamer85
    Level 3  
    @p.kaczmarek2 thank you .. I will try to use an external power supply
  • #19 21225102
    baudneo
    Level 6  
    I also have this issue, but sporadically. I have a 110v AC to 3.3v DC 700mA power supply for the mini switch, ftdi dongle is powered by usb bus, only Rx/tx are connected from ftdi to mini switch chip.

    The error only happens maybe 1/10 times when off/on the mini switch. I power off by removing du pont wire, not by turning PSU off.
  • #20 21225206
    mustafathamer85
    Level 3  
    >>21225102 @baudneo well I think I am going to give up, but just for curiosity, why should you remove the dupoint and not power off the PSU, is there a trick point here?
  • #21 21257039
    agetntx74
    Level 1  
    Hi there!

    Here's my solution, which might be helpful for someone.
    I used a cheap glue gun from Fixprise to fix a UTP pair. Then I adjusted it to fit on pins 25 and 26 of T34.
    The rest of the process is the same as everyone else's: 3.3V, GND, and CEN.
    It's not difficult, and I hope it helps!

    Close-up of a circuit board with attached multicolored wires and electronic components, secured with glue. Close-up of a circuit board with electronic components and wires. Close-up of a repaired circuit board using glue and wires.
  • #22 21264891
    woessner
    Level 2  
    Hello everyone,
    please have a close look at your board, You will find a resistor marked BR4, this is a pull down resistor for the TX pin (26)
    Thus you can easily access the TX pin on the side of the "4" of the resistor. The other side is GND.
    This leaves you with having to access pin 25 on the IC which is way easier than 26 because it is the outermost pin on the corner.
    I did not find RX anywhere else on the PCB.
    PS.: Does anyone have an idea why one would add a pull down resistor to TX? But anyhow, it makes life easier for us.
    Close-up of a PCB with visible electronic components, including capacitors and a resistor labeled BR4.
  • #23 21264928
    p.kaczmarek2
    Moderator Smart Home
    Is this TX pin on your board used for any other purpose? I don't see any reasons why there would be TX pin connected ONLY to a pull down. Especially that there are internal, configurable pull downs in Beken... maybe it used to be a button pin and it has a pull down that's a left over from previous design? From before migrating to BK?
    Helpful post? Buy me a coffee.
  • #24 21265132
    woessner
    Level 2  
    I tried to follow the trace but did not find anything thus it does not look as if the TX pin is used for anything else and flashing worked flawlessly as well.
  • #25 21296769
    morgan_flint
    Level 14  
    I also managed to flash one of these, thanks to all for the information!

    This was my approach to solder the TX/RX pins:
    Printed circuit board with visible electronic components including an integrated circuit, capacitors, and a screw terminal.

    I took a pair of wire wrapping wires, stripped and tinned a short length, and tied them together with a small thermal shrink tubing. I cut the isolated portion to just one mm and adjusted the distance between them to fit the distance between the IC pins. Then, with the help of a drop of flux, I aligned the points with the pins and touched them briefly with the soldering iron fitted with a smaller tip than usual. 3.3V, and GND wires were soldered to C2 capacitor pins.

    I read a backup with OBK flasher and everything went well, although it didn't recognize the configuration:
    Screenshot of the BK7231 flashing software with messages indicating successful reading. Screenshot of the Tuya Config Quick Viewer program displaying device GPIO configuration.

    Then, after flashing OBK config with the flashing tool, I used the JSON posted at the beginning and everything is going OK.

    Thanks again to everybody!

    EDIT: for flashing a second unit, I used the BR4 approach to connect TX pin, as suggested by @tmordalski and @woessner, thanks for the suggestion!
  • #26 21310912
    max4elektroda
    Level 20  
    Thanks for your input, especially for the solder-less solutions.
    Let me provide some pictures of my approach, kind of a "self contained" variant of the idea in the opening post by @Mati Crawn:
    I left most of the isolation on the wires, so I could connect them to the switches connectors (needs some force to fix them so that they don't move during positioning).
    The needles connected to BR4 for TX and pin 25 for RX.
    Took some time to bend and connect the needles, but I succeeded in the end ;-)

    I set speed to lowest (115200) after the first errors in reading (reading didn't finish).

    In the end, it did work when just writing the image, but only after setting the default speed 921600 (with 115200 erasing was successful, but writing failed).
    Might have also been due to the fact that I did everything on an Ubuntu PC...

    Sadly I lost my logs by closing the program to early :-(.

    So, here are some pictures of my approach (not shown: I soldered breadboard wires to the needle arms)

    Close-up of two copper wires with green and yellow insulation, with curved ends. Two wires with needles connected to a green screw terminal block. Close-up of a prototype electronic circuit with wires and pins connected to a PCB.
  • #27 21310967
    p.kaczmarek2
    Moderator Smart Home
    So it makes sense to try faster baud speed if slower one fails.. interesting
    Helpful post? Buy me a coffee.
  • #28 21310995
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:
    So it makes sense to try faster baud speed if slower one fails.. interesting

    That was my thought, too. But I had nothing to lose: The device was already erased, so I also tried the unusual step ;-)
  • #29 21321496
    marekvnl
    Level 9  
    Good evening, gentlemen,

    I'm having a little problem with the flash of this device. I managed to plug in its UART and do a full firmware dump, so I seem to have a good connection.

    SetProtectState(True) success!
    Going to read encryption key...
    Encryption key read done!
    Encryption key: 510fb093 a3cbeadc 5993a17e c7adeb03
    Going to start reading at offset 0x00...
    (...)
    Basic read operation finished, but now it's time to verify...
    Starting CRC check for 512 sectors, starting at offset 0x00
    CRC matches 0x10CF5951!
    All read!
    Loaded total 0x200000 bytes 
    Wrote 2097152 to readResult_BK7231N_QIO_2024-26-11-23-49-23.bin
    .

    I have tried dozens of times - different baud rates, different firmware versions and different flasher versions. The error is always the same:

    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: 15701C
    Will now search for Flash def in our database...
    Flash def found! For: 15701C
    Flash information: mid: 15701C, icName: EN25QH16B, manufacturer: ESMT, szMem: 1000000, szSR: 1, cwUnp: 0, cwEnp: 7, cwMsk: 3C, sb: 2, lb: 4, cwdRd: 05-FF-FF-FF, cwdWr: 01-FF-FF-FF
    Entering SetProtectState(True)...
    sr: 0
    final sr: 0
    msk: 3c
    cw: 0, sb: 2, lb: 4
    bfd: 0
    SetProtectState(True) success!
    Going to do erase, start 69632, sec count 281!
    failed with serial.BytesToRead 1 (expected 16)
    The beginning of buffer in UART contains 00 data.
    Erasing sector 69632... Erasing sector 69632 failed!
    Writing file data to chip failed.
    .

    Is there still a ground pin there to clear it or overwrite the flash? Documentation only talks about Pin18 being pulled up when loading flash from SPI.

    Could someone please suggest what this could be about? Thank you very much in advance.

    Greetings.
  • #30 21321499
    p.kaczmarek2
    Moderator Smart Home
    What kind of connection? Any pictures?

    This problem is quite well known and has already appeared on the forum, the symptoms are quite deceptive, reading works and writing breaks down, but it all usually comes down to improving the power supply, shortening the cables, possibly changing the USB to UART converter, possibly a different baud rate. It's also sometimes worth trying a higher baud as a lower one gives errors (and vice versa).

    Are you running Flasher on Windows?



    And if all else fails.... you can use hid_download_py:
    https://github.com/OpenBekenIOT/hid_download_py


    .
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around flashing T34-based smart switches purchased from Aliexpress with Tasmota or OpenBeken (OB) firmware. Users report receiving different versions of the switches, both equipped with the T34 chip but differing in button placement. Initial attempts to flash using Tuya Cloudcutter were unsuccessful due to firmware version limitations. Various methods for flashing, including using needle pins and external power supplies, were shared. Users encountered issues entering flashing mode, often related to power supply surges or incorrect wiring. Tips for accessing specific pins on the PCB, such as using a pull-down resistor for the TX pin, were also provided. Overall, the community shared troubleshooting advice and successful flashing experiences.
Summary generated by the language model.
ADVERTISEMENT