logo elektroda
logo elektroda
X
logo elektroda

[Solved] Tuya Smart Power Socket T34 Chip with BL0937: Flashing OpenBK7231N Firmware Guide

schaloule 30 1
ADVERTISEMENT
  • Helpful post
    #1 21849084
    schaloule
    Level 6  
    Tuya smart power socket with T34 chip and BL0937 power monitor

    Open the device by cautiously cracking the glued rim; eventually, pry it open.

    White adapter with two round metal prongs, clamped in a green vise on a blue work mat. White Type E power plug with two round pins and a metal grounding contact, held in a vise Close-up of a white plastic cylinder and a metal measuring tool with scale checking an edge

    Unscrew the inner PCB and wire 3.3 V (red), GND, Rx (yellow), and Tx (green).
    PCB close-up with two screw terminals, wires, and red “Tx Rx” labelClose-up of a green device with a PCB and wires; a red USB module with a blue plug nearby

    You need a 3.3 V USB-to-UART converter to connect to the T34 chip.
    Also, you may need to exchange the Rx and Tx lines depending on your USB-to-UART programmer.
    Use the Openbeken flasher: set UART port and chip type (BK7231N), and test the connection by doing a firmware backup.
    Eventually, you need to re-power the module a few times until the chip enters the programming mode.
    Use a suitable baud rate that your PC handles without errors.
    Screenshot of BK7231 Easy UART Flasher reading flash memory from a BK7231N chip.
    After a successful backup, write the new firmware to the chip.
    Screenshot of BK7231 Easy UART Flasher showing “Writing…” and a log of erasing and writing memory sectors

    After a successful write, re-power the device. It should open a hotspot which you can connect to at 192.168.4.1
    Enter the Wi-Fi config and set your SSID and password.
    Re-power, and check your router to find it in your network.
    Look for OpenBK7231N-... and connect to it.
    Then use the device configuration to set the pins for the interfaces.
    For my device, it was:
    - P6 : BL0937CF;0
    - P7 : BL0937CF1;0
    - P8 : BL0937SEL;0
    - P24: Relay;1
    - P26: Btn;1
    - P28: WiFiLED_n;1
    The Wi-Fi LED and the relay LED in my plug are both blue, which makes it difficult to see if the device is on or off, because the Wi-Fi LED outshines it.
    So, I put some Kapton tape on top of the Wi-Fi LED to dim it.
    To make use of the plug in your home network, you may need to go to the filesystem settings and create an autoexec.bat for your needs,
    which may look like this (the Wemo driver enables the device to integrate with Amazon Alexa)
    // enable drivers
    startDriver ntp
    startDriver SSDP
    startDriver Wemo
    // enable NTP
    startDriver ntp
    ntp_setServer 192.168.???
    ntp_timeZoneOfs 1:00
    ntp_setLatlong 58.66189 18.92459
    waitFor NTPState 1
    //addClockEvent <time> <daysOfWeek> <id> <command> 
    //  <time>  :  {seconds from midnight}, {HH:mm[:ss]}, {sunrise|sunset}
    //  <DoW>   :  {0x01..0x40|0x7F} = bitmaske: Sunday..Saturday|daily
    addClockEvent  6:00 0xff 1 setChannel 1 1 
    addClockEvent  7:30 0xff 2 setChannel 1 0 
    listClockEvents
  • ADVERTISEMENT
  • #2 21849087
    schaloule
    Level 6  
    This is a tutorial to help others, not a problem case.
ADVERTISEMENT