logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 220614 1308

TL;DR

  • OpenBK7231T adds a cross-platform C HTTP mini-server, web pin configurator, and MQTT integration for BK7231T-based WB2S/WB3S modules with Home Assistant control.
  • The design splits Windows-specific networking from reusable HTTP and pin code, so the same configurator and packet parser can run on Windows and on the BK7231T firmware.
  • The server listens on port 80, uses one int as a channel bitmask, and therefore supports up to 32 channels on a 32-bit platform.
  • MQTT callbacks propagate relay/button changes to Home Assistant and accept commands back, and a 4-relay setup uses wildcard topics like wb2s/1/get through wb2s/4/set.
  • The current pin configurator does not save settings to Flash yet, so configuration is still coded and compiled into the firmware.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI voice):
  • #1201 20526516
    Tilator
    Level 12  
    Posts: 139
    Help: 2
    Rate: 13
    Dark Man wrote:
    I found a great deal on smart sockets with current measurement and 20A relay for $2.99 with free shipping in 11 days:
    US$2.99 82%OFF | Tuya 16A 20A EU Smart Socket WiFi Smart Plug With Power Monitoring Timing Function Voice Control Alexa Google Assistant
    https://a.aliexpress.com/_EuI37V5


    Nice, but:

    1,000+ orders
  • ADVERTISEMENT
  • #1202 20527197
    Dark Man
    Level 13  
    Posts: 74
    Rate: 20
    I ordered 1 pc. and it turned out that this is also the limit for one account.
  • ADVERTISEMENT
  • Clean browser required for account login

    #1203 20527345
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    It didn't work for me on any of the accounts (mine or family members), I had to try it on a clean browser. It's weird. After all, I recently ordered a smart socket from aliexpress 2 years ago.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Bought for PLN 20, thank you for the link, it will be useful for making another video for the Elektrody channel:
    https://www.youtube.com/@elektrodacom
    Helpful post? Buy me a coffee.
  • Question about changing sensor precision to kWh

    #1205 20541157
    Dark Man
    Level 13  
    Posts: 74
    Rate: 20
    Dark Man wrote:
    I found a great deal on smart sockets with current measurement and 20A relay for $2.99 with free shipping in 11 days:
    US$2.99 82%OFF | Tuya 16A 20A EU Smart Socket WiFi Smart Plug With Power Monitoring Timing Function Voice Control Alexa Google Assistant
    https://a.aliexpress.com/_EuI37V5

    The socket has arrived.
    I tried to upload the soft via Cloudcutter but it turned out that there is soft v1.1.12 in the socket for which there is no exploit :(
    I uploaded the series.

    I configured for HA through Discovery, but I have a question:
    How to change the precision of the sent sensor data?
    e.g. the electricity meter is sent in Wh with 6 decimal places and I would like it to send in kWh with 2 decimal places.
    It is possible?
  • #1206 20541822
    Tilator
    Level 12  
    Posts: 139
    Help: 2
    Rate: 13
    Dark Man wrote:
    I tried to upload the soft via Cloudcutter but it turned out that there is soft v1.1.12 in the socket for which there is no exploit


    Any chance to downgrade it first?
  • #1207 20545727
    rishabmehta7
    Level 6  
    Posts: 19
    Help: 1
    Rate: 1
    >>20541157
    Precision can be set on the HA level.
  • ADVERTISEMENT
  • Upcoming OBK support for TM1638, BMP280 and SSD1306

    #1208 20550963
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    I found this project by accident and got hooked up fast :) Got to talk to the admin and we figured I can contribute the the community. We already did one project (GN6932 driver) almost from scratch, details in this post - https://www.elektroda.com/rtvforum/topic3971252.html

    I will continue to support this project by sharing as much information as possible here and on GitHub.

    Here are some of the upcoming devices that will be implemented and worked on so OBK will be more powerful and documented in the best way possible.

    TM1638 - 7 segmend display driver
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    some of the devices for future support

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    And some other toys to play with, like new modules, BMP280 pressure sensor, SSD1306 OLED LCD....

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I have plenty of other devices to play with as well so thank you @p.kaczmarek2 for you unselfish support and looking forward to new developments.
  • #1209 20551996
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Welcome onboard, @DeDaMrAz . Our cooperation so far has proven to be very fruitful. I hope we can improve OpenBeken much more together.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • BK7231GUIFlashTool to extract Tuya config and edit OBK config

    #1210 20573740
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Important update.
    BK7231GUIFlashTool, this project:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    will soon get update that allows:
    - to extract Tuya config from tuya device binary (so it means you get ready gpio config)
    - to modify obk config via flash tool
    Here's a short preview:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • Question about exposing BK7231N internal temperature sensor over MQTT

    #1211 20580135
    keeepcool
    Level 1  
    Posts: 1
    Good evening, this is my first post, so I hope I'm not asking in the wrong place (I searched around and this seems like the best place to ask this question).

    I recently bough a WSM16-4 Tuya device (its a 4 gang/switch with a CBU), flashed OpenBeken and it works perfectly with HomeAssistant.
    Amazing job on everything done so far.

    My question is if its possible to access the internal BK7231N temperature sensor and send that data over MQTT.
  • #1212 20630474
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    Hi @p.kaczmarek2
    One of my wall switch (N device) stopped responding after latest ota
    I removed the pcb and use serial method to flash it but I keep getting crc error
    Anyway to fix this?

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #1213 20633272
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Are you 100% sure it's N chip? Not a T with "CB2S" or something like that marking?

    Can you also check with hid_download_py?
    Helpful post? Buy me a coffee.
  • #1214 20633667
    Dark Man
    Level 13  
    Posts: 74
    Rate: 20
    My bet is that the memory is corrupted in the chip.
    Try to read the entire memory and see if there are any errors.
  • Memory corruption suspected after hid_download_py CRC errors

    #1215 20635046
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    p.kaczmarek2 wrote:
    Are you 100% sure it's N chip? Not a T with "CB2S" or something like that marking?

    Can you also check with hid_download_py?


    Yes, it's a cbu (N chip)
    hid_downlaod_py also gave crc error

    Added after 2 [minutes]:

    Dark Man wrote:
    My bet is that the memory is corrupted in the chip.
    Try to read the entire memory and see if there are any errors.


    Could be, I've already replaced it with another spare cbu chip to get the switch working again.
    will post the firmware bin later
  • #1216 20635053
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    CRC error in hid_download_py for N can be ignored currently, I think. It will be updated soon yet to do a correct CRC calculation.
    Helpful post? Buy me a coffee.
  • #1217 20879442
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    Hi, just wondering is there an espnow equivalent for beken chips?
    Started using tasmesh (based on espnow) on tasmota and I like how it still works by communicating directly to another esp broker even when wifi is down.
  • #1218 21006637
    alexej550271
    Level 5  
    Posts: 11
    Добрый день всем участникам! Скажите пожалуйста есть ли возможность изменить прошивку для умной розетки с энергомонитором BL0937, которую купил. а в ней оказался контроллер rtl8710bn, добавили уже поддержку этого чипа?... Или стоит заказывать чип ESP?
  • #1219 21008720
    giovi321
    Level 1  
    Posts: 1
    Hi,
    I have flashed on a CB3S version 1.17.509, however I cannot connect to wifi networks that have spaces in the PSK.
  • #1220 21009389
    divadiow
    Level 38  
    Posts: 5188
    Help: 445
    Rate: 912
    @alexej550271 RTL8710BN is not currently supported by OpenBeken
  • #1221 21035737
    alexej550271
    Level 5  
    Posts: 11
    Не скажите, в ближайшее время планируется добавить поддержку этого модуля?
  • #1222 21036047
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Yes, I need to get some time and I will check this out. It's just that there are many other issues and I am also constantly making new teardowns for our list:
    https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.
  • #1223 21061728
    ewessels89
    Level 2  
    Posts: 3
    Hi all,

    I'm looking for a way to flash the WBR2 chip. I saw a post that is should be possible. Is there anything i can do to help?

    Seea picture of my device. Close-up of an electronic board with an LED display and WBR2 chip.
  • #1224 21061739
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    What kind of device is that? Can you provide more information?

    Is it TuyaMCU? Otherwise you will need to write a driver for that display...
    Helpful post? Buy me a coffee.
  • BK7231T thermostat appears to use TuyaMCU UART link

    #1225 21061938
    ewessels89
    Level 2  
    Posts: 3
    Its a WiFi thermostat for a electric towel radiator. See also this manual https://cdn.webshopapp.com/shops/85556/files/432038087/english-guide.pdf

    I have two devices so i decided to open up one off them. I also remove the wbr2 chip and as far ass i can tell only 3v3, ground and the tx/rx are connected so i think its tuyamcu. See also this picture. WiFi thermostat circuit board with digital display. Close-up of the inside of a WiFi thermostat with an exposed PCB. Open WiFi thermostat for an electric towel radiator, showing the circuit board and display. Interior of a WiFi thermostat for an electric towel radiator with visible wires and electronic components. Image of an electronic module with a blue PCB and connectors labeled 3V3, GND, A13, A14. WBR2 electronic module on a dark background.
  • #1226 21062053
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Have you tried to do TuyaMCU communication capture?
    TuyaMCU analyzer - UART packet decoder for Tuya devices - dpID detector
    Helpful post? Buy me a coffee.
  • #1227 21062277
    ewessels89
    Level 2  
    Posts: 3
    I can see the heartbeat but it’s not paired with the Tuya app so I can’t send command to it (is there a way I can get the chip in pairing mode?
    Close-up of a connected electronic module with connecting wires. Screenshot of the TuyaMCU Explorer/Analyzer program showing Wi-Fi packet data.
  • #1228 21067221
    jakubhrusovsky01
    Level 2  
    Posts: 2
    Hello, is it possible add syslog on UDP to new firmware update ? Like Tasmota have, i want it for Loxone state read. Thanks
  • #1229 21067367
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14728
    Help: 659
    Rate: 12814
    Sure, I can print the log to UDP for you. Can you provide any more details how it should work, which port, etc? UDP is not really reliable and may lose packets. Can you point me towards that "Loxone syslog" documentation?
    Helpful post? Buy me a coffee.
  • #1230 21068230
    jakubhrusovsky01
    Level 2  
    Posts: 2
    Screenshot of logging settings in the Tasmota interface.

    In Tasmota i have this settings and it works perfectly for my integration with Loxone, i use virtual read and it reads state of relay and give it to Loxone.
📢 Listen (AI voice):

Topic summary

✨ Discussion about developing and testing open firmware for BK7231T-based Tuya devices, including a cross-platform mini HTTP server, web configurator for GPIO/pin mapping, MQTT integration, and Home Assistant control. The thread covers flashing procedures with Beken Writer and a Python UART downloader, backup of original firmware, UART wiring, CEN reset method, power-supply precautions, and troubleshooting of flashing failures, erase limits, baud-rate issues, and boot problems. As development progresses, PWM dimmer support is added, MQTT startup bugs are fixed, Wi‑Fi AP/client mode behavior is improved, network scanning is implemented, and support is extended toward BK7231N and related SDKs. Participants also identify device internals such as BL0937 power metering, AMS1117 regulators, TuyaMCU/UART peripherals, and various smart plugs, switches, bulbs, and dimmers that may be compatible with the firmware.
AI summary based on the discussion. May contain errors.

FAQ

TL;DR: 100 % flash-success reported on BK7231 T/N modules [Elektroda, p.kaczmarek2, post #19906676]; “OpenBK7231T now boots on three chip families” [Elektroda, p.kaczmarek2, post #19883071] Use QIO image for BK7231N, UA for BK7231T; erase only 0×11000-0×1EF000. Why it matters: a single workflow now replaces vendor firmware on 60 + low-cost IoT boards.

Quick Facts

• Supported MCUs: BK7231T, BK7231N, XR809 (Wi-Fi + BLE) [Elektroda, 19883071] • Recommended UART speed: 921 600 bps for write, 115 200 bps for read [Elektroda, 19857664] • Flash sizes: Typical 2 MB on-chip; config area starts @ 0×1EF000 [Elektroda, post #19893493] • OTA format: .rbl (gzip + AES, served by HTTP) [Elektroda, btsimonh, post #19880525] • Typical power: 5 V @ 500 mA to AMS1117 input for safe programming [Elektroda, ExploWare, post #19853546]

3. Writer stops at “Erasing 0×11000” – why?

The chip is protected. For BK7231N add --unprotect when using uartprogram, or choose BK7231N mode in BKWriter; baud 921 600 often succeeds after 115 200 fails [Elektroda, boozeman, post #19857804]

4. Relay clicks during flashing – safe fix?

A pull-up on RX1 ties the push-button to 3 V3, driving the relay. Remove jumper R33 on Nedis WIFIPO120FWT, flash, then solder it back [Elektroda, boozeman, post #19882233]

5. How can I back-up the Tuya stock firmware?

Run python bk7231tools.py read_flash -d COMx --no-verify-checksum -s 0 -c 512 dump.bin for T/N chips (2 MB, 512 × 4 KB) [GitHub bk7231tools].

6. My BK7231N loses settings after power-cycle.

Disable FAST_CONNECT (RL_SUPPORT_FAST_CONNECT) or use latest OpenBK build ≥ f6c3c8f6 that stores config outside NET_PARAM table [Elektroda, p.kaczmarek2, post #19893493]

7. Does OTA work and how do I host updates?

Yes. Serve *.rbl over HTTP (http-here --host 0.0.0.0 8000). In WebApp → OTA tab → enter http://<IP>:8000/firmware.rbl; device backs up filesystem, flashes, restores settings [Elektroda, btsimonh, post #19880525]

9. What are the default GPIO roles for common plugs?

• Nedis WIFIPO120FWT – P6 LED, P10 Button, P26 Relay [Elektroda, 19883937] • QiaChip Smart Switch (WB2S,T) – P24 Relay, P26 Button [Elektroda, 19906692]

10. How do I compile on Linux or Windows?

Clone SDK OpenBK7231T, then OpenBK7231T_App into /apps. Build: ./build_app.sh apps/OpenBK7231T_App OpenBK7231T_App git (Linux) or Cygwin on Windows; ensure build-essential and gcc-arm-none-eabi installed [Elektroda, boozeman, post #19885620]

11. Is there a no-solder exploit?

Yes. CloudCutter abuses 2019 Tuya SDK bug to OTA-flash BK7231 lights wirelessly; code published February 2022 [khalednassar/tuya-cloudcutter]. "It works on every test bulb so far" [Tom Clement, #19890768].
AI summary based on the discussion. May contain errors.
ADVERTISEMENT