logo elektroda
logo elektroda
X
logo elektroda

[BK7231N][CBU] ZMAi-90 Smart Energy Meter Teardown and Flashing

thebeardeddragon 11940 74
Best answers

How can I flash a BK7231N-based ZMAi-90 smart energy meter with OpenBeken and configure its meter/relay connections locally?

First check whether your ZMAi-90 is a TuyaMCU design; if it is, OpenBeken can talk to the MCU and you can identify dpIDs either with TuyaMCUAnalyzer or by using Tuya’s own developer/device logs [#20815719][#20821311] For this BK7231N CBU version, the 2 MB dump must be read from the Wi‑Fi module, not the RN8209C, and the recommended tools are BK7231GUIFlashTool / the newer flasher because bkWriter 1.60 is not reliable on BK7231N [#20821174][#20827069][#20838678] To actually write firmware, the RN8209C must be desoldered because it is wired to the Wi‑Fi UART and blocks programming; a read-only trick with VDD floating can work, but it failed for writing [#20838678][#20838936] After flashing, the discovered GPIOs were P14/P16 for the bridge relay pair, P7 for the pair button, P6 for the WiFi LED, and P26 for the tipped LED [#20838775] The RN8209 energy-meter support was being added in OpenBeken: voltage and power could work after calibration, but current still needed more driver work, and Home Assistant discovery needed the driver started before discovery [#20839061][#20865267]
Generated by the language model.
ADVERTISEMENT
  • #61 20865042
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4
    p.kaczmarek2 wrote:
    Well, there is not much choice, when you look at the boad, there is CBU, there is that RN chip for power metering, and the only other big chip is for screen. It's just it's not marked in my piece, so it's hard for me to tell which chip it is.


    So do you know how i can publish this RN value in Home Assistant? because with MQTT not show

    Warn:EnergyMeter:V 1933333, C 2697 0, P 81222 0
    Info:MQTT:Publishing val 8.24 to zmai90/power/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic zmai90/power/get
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 216
    Warn:EnergyMeter:CRC OK
    Warn:EnergyMeter:V 1933333, C 2697 0, P 81222 0
    Warn:EnergyMeter:UA 29
    Warn:EnergyMeter:UA 211
    Warn:EnergyMeter:UA 5
    Warn:EnergyMeter:UA 230
    Warn:EnergyMeter:CRC OK
    Warn:EnergyMeter:V 1954565, C 2697 0, P 81222 0
    Info:MQTT:Publishing val 224.2 to zmai90/voltage/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic zmai90/voltage/get
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 10
    Warn:EnergyMeter:UA 111
    Warn:EnergyMeter:UA 100
    Warn:EnergyMeter:CRC OK
    Warn:EnergyMeter:V 1954565, C 2671 0, P 81222 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 0
    Warn:EnergyMeter:UA 220
    Warn:EnergyMeter:CRC OK
    Warn:EnergyMeter:V 1954565, C 2671 0, P 81222 0
    Info:MQTT:Publishing val 0.221 to zmai90/current/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic zmai90/current/get


    But nothing in Home Assitant

    Home Assistant user interface showing device, control, sensors, and logs cards.
  • ADVERTISEMENT
  • #62 20865119
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    I will look into it, it may be not just enabled yet. The more important problem is that it seems you have the wrong current measurements as well, right? That means I need to look into the communication algorithm more. Something must be missing from my implementation.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #63 20865141
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4
    Yes, there are some mismatches in current, but not so big. If you calibrate from current, it is okay. You can set the value exactly for power.

    Screenshot of the Zmai90 user interface showing voltage, current, and energy data.

    I will wait until the problem with MQTT is fixed because these three are not my zmai and I need to put Beken on them. After that, I need to use them on the neighbor's house. But for now, it is on a test to find a solution and fix this Zmai 90.

    Added after 16 [minutes]:

    And i think for display this is the chip:

    https://vi.aliexpress.com/item/10050060033570...1RO%21728730991%21&curPageLogUid=DtnE9WB4gctZ

    is exact same model with same 48 pin

    Added after 4 [minutes]:

    https://datasheet.lcsc.com/lcsc/2108251130_HTCSEMI-HT1621BRQZ_C2886391.pdf
  • #64 20865267
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    The driver check was missing. I have added it now:
    https://github.com/openshwprojects/OpenBK7231...mmit/235a26ad2d466072bb20128e190e8b0bb9031609
    Can you start the driver now, then do Home Assistant Discovery, and then check are measurements getting discovered correctly?

    NOTE: Always start driver first, then do HASS discovery.
    Helpful post? Buy me a coffee.
  • #65 20865336
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4
    It shows only current and voltage:

    Screenshot of MQTT interface showing device info, controls, sensors, and a logbook.


    Added after 7 [hours] 19 [minutes]:

    is work now with publish, but what is missing in HASS is Total Energy sensor

    Added after 12 [minutes]:

    Only you need to add to publish in HASS:

    Energy Total

    Because i saw for all device don't publish this total energy
  • ADVERTISEMENT
  • #66 20866410
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    Wait, so how did you fix missing Power?
    Helpful post? Buy me a coffee.
  • #67 20866430
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4

    I pressed again on Start HASS Discovery and now it works after restarting the driver, but I don't understand why Total energy is not present in HASS.

    Screenshot of device panel for BK7231N by Beken Corporation showing sensor information.

    As you can see, there is no Total energy.

    Added after 32 [minutes]:

    What I saw when the switch is OFF, I have 0.010 amp with my meter (digital clamp meter) and on the web it is 0.033. After I switch on, I have both 0.051 on the meter and 0.051 on the web app.
  • #69 20869071
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4
    no news?
  • #70 20869247
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    Can you provide some more information, are those two counters 'Unknown' for you all the time?
    Helpful post? Buy me a coffee.
  • #71 20869271
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4

    p.kaczmarek2 wrote:
    Can you provide some more information? Are those two counters 'Unknown' for you all the time?


    Only consumption_stats is always Unknown, the rest are okay with every update of stats.
  • #72 20869375
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    I will check this when I have some time, today we are merging NTP Sunset/Sunrise events:
    https://github.com/openshwprojects/OpenBK7231...mmit/bc580f0d0acba49846b0d554e29a251b5c2f3679
    I will try to look into your question soon, sorry for the delay
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #73 20877493
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4

    Do you know RN8209 is supported in ESPHOME because I don't find any details related to this chip.

    Thanks
  • #74 20877626
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14580
    Help: 654
    Rate: 12604
    No, it's not supported, we are the first one to work on it.
    Helpful post? Buy me a coffee.
  • #75 20892254
    lionboy
    Level 10  
    Posts: 69
    Help: 1
    Rate: 4
    any news regardig to chip for display?

    Thanks

Topic summary

✨ The discussion revolves around the ZMAi-90 smart energy meter, which utilizes the BK7231N chip and has been modified from earlier versions that used the ESP8266. Users are seeking to flash the device with OpenBeken firmware to eliminate reliance on cloud services. Initial steps involve determining if the device is a TuyaMCU version and identifying the UART connections for flashing. Several users share their experiences with flashing, including challenges with communication and the need to desolder components like the RN8209C chip to facilitate the process. The conversation also touches on the power metering functionality and the integration of the device with Home Assistant, highlighting issues with current measurements and the need for calibration. Users discuss various methods for reading flash memory and the importance of ensuring proper connections to avoid damaging the device.
Generated by the language model.

FAQ

TL;DR: If you own the ZMAi-90 CBU version with BK7231N, back up the 2MB flash first, then remove the RN8209C or it will block UART writes. As one expert put it, “TX1/RX1 is for both flashing and TuyaMCU.” This FAQ is for users who want local OpenBeken control, relay switching, and RN8209 power metering without Tuya cloud. [#20827152]

Why it matters: This thread shows the exact failure points, safe flashing path, GPIO map, and early RN8209 support for the BK7231N-based ZMAi-90.

Method Read backup Write OpenBeken Main limitation
bkWriter 1.60 Unreliable on BK7231N Unreliable Better on BK7231T than BK7231N
BK7231GUIFlashTool / newer flasher Yes Yes Still blocked if RN8209C holds UART
VDD “trick” with RN8209C still present Yes, with hack No Read worked, write current was insufficient
Desolder RN8209C first Yes Yes Requires SMD rework

Key insight: The blocker is not the CBU module itself. The RN8209C shares UART lines with the BK7231N, so reliable flashing required desoldering the RN8209C before writing OpenBeken.

Quick Facts

  • The confirmed backup size for the CBU BK7231N module was 2MB, and the thread explicitly recommends taking that dump before flashing so the Tuya firmware can be restored if needed. [#20821174]
  • Confirmed GPIO map for one black-board ZMAi-90 CBU variant: P6 = WiFi LED, P7 = pair button, P14/P16 = bridge relay pair, P26 = tipped LED. [#20840241]
  • The RN8209 test driver was calibrated with a 60W bulb; voltage and power worked first, while current remained inconsistent on at least one device. [#20857064]
  • Bench tests showed the meter being checked at 220V, 247V, and 194V with an autotransformer, which helped validate voltage tracking after driver work began. [#20850811]
  • Home Assistant discovery later exposed voltage, current, power, and total energy, but one derived counter stayed Unknown for at least one user. [#20867145]

How do I flash a ZMAi-90 smart energy meter with a CBU BK7231N module to OpenBeken step by step?

You flash it by backing up the CBU first, then isolating the BK7231N from the RN8209C, then writing OpenBeken. 1. Connect to the CBU pads for GND, RX, TX, and 3.3V, and make a 2MB backup. 2. Desolder the RN8209C, because it blocks UART flashing on this board. 3. Use the newer BK7231 flasher to write OpenBeken, then restore the RN8209C and apply the GPIO template. That was the first reliable write path confirmed for this CBU black-board version. [#20838678]

Why does the RN8209C chip block flashing on the ZMAi-90, and why do people end up desoldering it first?

The RN8209C blocks flashing because it shares the BK7231N UART lines used for programming. On this board, the RN8209C sits on the same UART path as TX1/RX1, and its RST_N is tied to RX, so holding it in reset also breaks UART access. A read-only hack worked by starving the rest of the board, but writes still failed. That is why desoldering the RN8209C became the practical solution for reliable OpenBeken flashing. [#20838936]

What is TuyaMCU, and how do I tell whether my ZMAi-90 uses TuyaMCU or a custom protocol?

TuyaMCU is one possible control method, not a guarantee on every ZMAi-90. "TuyaMCU" is a serial control protocol that lets a main MCU exchange datapoints with the Wi-Fi module over UART, using structured packets instead of direct GPIO control. To identify it, check whether the CBU TX1/RX1 lines connect to the device MCU and whether packet datapoints can be decoded. The thread also warns that there are at least three separate ZMAI-90 versions, so board inspection matters before assuming TuyaMCU support. [#20856983]

What is a dpID in Tuya devices, and how can I find the datapoints for a ZMAi-90 energy meter?

A dpID is the numeric identifier for each Tuya datapoint. "dpID" is a Tuya datapoint identifier that labels a specific function or measurement, such as relay state, voltage, or energy total, inside UART or cloud-reported packets. The thread gives three ways to find them: capture hex traffic and feed it to TuyaMCUAnalyzer, inspect datapoints in the Tuya developer platform after pairing the device, or infer them from values like 2300 = 230.0 kWh. The safer path recommended there was the Tuya platform route. [#20821311]

Which UART pins on the CBU board are used for flashing and TuyaMCU communication, and what is TX2 used for?

Use TX1 and RX1 for both flashing and TuyaMCU communication. The thread states clearly that TX2 is only for debug log output, not for normal flashing. That distinction matters because several failed attempts happened before the pin roles were clarified. One expert answer in the thread said, “TX2 is only for debug log output. TX1/RX1 is for both flashing and TuyaMCU.” [#20827152]

What's the correct way to make a 2MB flash backup of a BK7231N CBU module before installing OpenBeken?

Start the flash read first, then reset power so the BK7231N can enter the boot path. 1. Connect GND, RX, TX, and 3.3V to the CBU. 2. In the flash tool, click Read before cycling power. 3. Disconnect and reconnect 3.3V, or briefly discharge the module side as described, so it can “get bus” and begin the 2MB read. The thread used this order repeatedly and confirmed that a backup was successfully extracted from the Wi-Fi module, not the RN8209C. [#20827069]

Why doesn’t bkWriter 1.60 work reliably with BK7231N, and how does BK7231GUIFlashTool compare for reading and flashing?

bkWriter 1.60 was reported as unreliable on BK7231N because it worked better on BK7231T. The thread explicitly says bkWriter 1.60 may not work good for N platform, then recommends hid_download_py or BK7231GUIFlashTool instead. In practice, the newer tooling matched the BK7231N better, but it still could not solve hardware UART contention from the RN8209C. So the software choice mattered, yet board-level interference still determined success or failure. [#20827069]

What safety precautions should I follow when probing UART or flashing a mains-powered ZMAi-90 energy meter?

Never connect a USB-UART adapter directly to the device while it is powered from mains. The thread warns that the power supply may not be isolated, so UART probing on a live 230V unit can be dangerous. Use an optoisolator if you must inspect serial traffic on a mains-powered board. A safer alternative is to remove the Wi-Fi board or power only the detached CBU from 3.3V during backup and flashing work. [#20821311]

How can I stop the RN8209C from interfering with UART flashing without damaging the board?

The least ambiguous method is to desolder the RN8209C or cut the UART trace. Reset tricks were discussed, but on this board the RN8209C RST_N shares the RX path, so reset does not cleanly free UART. A temporary read-only hack worked by forcing the Wi-Fi module to power while the MCU side stayed unpowered, but that did not support writing firmware. If you want reliable flashing without repeated failures, remove the RN8209C first and solder it back afterward. [#20838936]

Which GPIO template works for the ZMAi-90 CBU version, including relay, WiFi LED, tipped LED, and pair button pins?

The working template for one confirmed CBU BK7231N black-board version maps P6 = WifiLED_n, P7 = Btn, P14 = BridgeFWD, P16 = BridgeREV, and P26 = LED. Relay control used the P14-P16 bridge pair, not a single GPIO. Another user later simplified the relay mapping to Rel and Rel_n, but the original bridge template was the first published map tied to this teardown. Use that template only after confirming your board matches this variant. [#20840241]

How do I start and calibrate the RN8209 driver in OpenBeken for the ZMAi-90 using a known load like a 60W bulb?

Start the RN8209 driver with a startup command, wait a few seconds, then calibrate against a known load. The exact command given was startDriver RN8209. After starting it, wait about 3 seconds, because early driver updates were slow, then calibrate using a 60W bulb as the reference load, similar to Tasmota practice. The developer reported that voltage and power responded after this process, even before current behavior was fully solved. [#20857064]

Why do I get CRC BAD errors and zero readings from the RN8209 driver after flashing my ZMAi-90?

CRC BAD usually means the RN8209 communication path is wrong or physically disturbed. In the thread, one user saw repeated bad CRC and all-zero voltage, current, and power, then revealed a missing SMD capacitor near the communication path after rework. The reply noted that if that capacitor was on RX/TX, it could directly affect metering communication. Old firmware builds also caused issues, so the user was told to move from a Dec 5 build to a Dec 7 build first. [#20857903]

How do I publish ZMAi-90 RN8209 voltage, current, power, and total energy readings to Home Assistant through MQTT discovery?

Start the RN8209 driver before running Home Assistant discovery. The developer added the missing discovery check, then instructed users to startDriver RN8209 first, run HASS discovery second, and verify the entities afterward. After that fix, users reported voltage, current, power, and later Total Energy appearing through MQTT discovery, although one counter entity still stayed Unknown. If discovery runs before the driver starts, some entities may not appear. [#20865267]

What causes the current measurement on the ZMAi-90 RN8209C to be inaccurate even when voltage and power look correct?

The thread points to an incomplete RN8209 communication or calibration issue, not a finished hardware fault diagnosis. The developer repeatedly said voltage and power looked correct after calibration, while current stayed wrong and “something must be missing” in the implementation. Another tester reported smaller current mismatch: 0.010 A on a clamp meter versus 0.033 A in the web UI when off, but matching 0.051 A when on. That pattern suggests the driver was usable but not fully mature for low-current accuracy. [#20866430]

Which LCD controller chip is used on the ZMAi-90 display board, and how could OpenBeken support that screen?

The LCD controller was not confirmed in the thread. The display IC on the tested board had no visible marking, so the developer could not identify it directly. Another participant suggested it might match an HT1621B-family 48-pin controller, but that remained an informed guess, not a verified finding. OpenBeken support would require first identifying the controller and then writing a custom display driver, just as the RN8209 driver had to be written from scratch. [#20864564]
Generated by the language model.
ADVERTISEMENT