logo elektroda
logo elektroda
X
logo elektroda

Tuya Single Phase Energy Meter 6 In 1: CBU Chip Flashing & ESPHome Integration Issues

deanfourie 16968 96
Best answers

How can I flash a Tuya Single Phase Energy Meter 6 In 1 with a BK7231N/CBU chip and get its energy readings working in Home Assistant?

Flash it with `hid_download_py`, not `bkWriter`; for BK7231N/CBU use the correct OpenBK7231N `QIO` image, do a full flash backup first with `-r`, then write the OBK firmware with `-w --startaddr 0x0`, and trigger the read/write start by power-cycling the board or briefly pulling CEN low while the tool is waiting [#20347216][#20347521][#20349087] The key mistake in the thread was swapping read and write: `-r` reads the device into a file, while `-w` writes the file from your PC to the meter [#20349087] After flashing, the meter was identified as a PZIOT-E01 using a BL0942 power-measurement chip in SPI mode; OpenBeken later gained `BL0942SPI` support, and that works without hardware modifications [#20356800][#20529840][#20537263] To enable measurements, put `startDriver BL0942SPI` in the short startup command and reboot, then calibrate in the Web App Tools tab using a known-good meter and a 60W load with the VoltageSet/CurrentSet/PowerSet fields [#20535543][#20535564][#20559990] For Home Assistant, the thread says autodiscovery is limited so YAML/MQTT configuration may be needed, and the device can publish sensor values on its MQTT topics once the driver is running [#20352389][#20355143]
Generated by the language model.
ADVERTISEMENT
  • #91 20537263
    p.kaczmarek2
    Moderator Smart Home
    No hardware modifications are required if you are going to run BL0942SPI driver. All you need to do is:
    1. flash the firmware
    2. start driver BL0942SPI, probably in short startup command
    3. you should already get readings, but it's good thing to calibrate, VoltageSet, etc commands
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #92 20538825
    deanfourie
    Level 6  
    Sorry would I need to update the firmware since I last installed it for this to work.

    I'm looking at this now,

    Thanks
  • ADVERTISEMENT
  • #93 20538842
    p.kaczmarek2
    Moderator Smart Home
    Web Application -> OTA -> drag and drop proper RBL for your platform
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #94 20559984
    deanfourie
    Level 6  
    Great thanks, I've done that now on all units.

    Do you think you can walk me through calibration and MQTT setup for HA?

    Much appreciated!
  • #95 20559990
    p.kaczmarek2
    Moderator Smart Home
    Good job, no problem, I can tell you what to od next.
    First calibration: Take a reliable meter, plug 60W bulb, then open Web App, Tools tab, and in the fields for calibration, enter true Voltage/Current/Power readings from a reliable meter. Done.
    Then HA pairing:
    [youtube]
    https://www.youtube.com/watch?v=pkcspey25V4
    [/youtube]
    You can also take a glance here for general purpose tutorials:
    https://www.youtube.com/@elektrodacom
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #96 21328576
    alexlimbeck
    Level 3  
    Hi. I am trying a Tongou smartplug. (TuyaCBU + BL0942)
    Flashed and activated with the "startDriver BL0942SPI" command, all was fine, until reboot.

    Rebooted the smartplug, I don't receive any data about power consumption on my MQTT server.
    If I try again startDriver "BL0942SPI", I obtain errors, but finally I receive data on my MQTT server.

    This is the message:

    Info:EnergyMeter:Read ENERGYMETER status values. sizeof(ENERGY_METERING_DATA)=32
    Warn:EnergyMeter:Failed to read reg 1D: bad checksum FF wanted 8D
    Error:EnergyMeter:Failed to write reg 1D val 55: read 11
    Warn:EnergyMeter:Failed to read reg 19: bad checksum FF wanted 91
    Error:EnergyMeter:Failed to write reg 19 val 8F: read 11
    Info:MAIN:Started BL0942SPI.
    OK


    So I tryed "stopDriver BL0942SPI" and repeat "startDriver BL0942SPI" and the result is :

    Info:EnergyMeter:Read ENERGYMETER status values. sizeof(ENERGY_METERING_DATA)=32
    Error:CMD:command with name EnergyCntReset already exists!
    Error:CMD:command with name SetupEnergyStats already exists!
    Error:CMD:command with name ConsumptionThreshold already exists!
    Error:CMD:command with name VCPPublishThreshold already exists!
    Error:CMD:command with name VCPPrecision already exists!
    Error:CMD:command with name VCPPublishIntervals already exists!
    Error:CMD:command with name VoltageSet already exists!
    Error:CMD:command with name CurrentSet already exists!
    Error:CMD:command with name PowerSet already exists!
    Warn:EnergyMeter:Failed to read reg 1D: bad checksum FF wanted 8D
    Error:EnergyMeter:Failed to write reg 1D val 55: read 11
    Warn:EnergyMeter:Failed to read reg 19: bad checksum FF wanted 91
    Error:EnergyMeter:Failed to write reg 19 val 8F: read 11
    Info:MAIN:Started BL0942SPI.
    OK
  • #97 21328626
    p.kaczmarek2
    Moderator Smart Home
    Were measurements really correct? Reboot shouldn't break anything... is it still wrong after power off and on?
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion centers on the Tuya Single Phase Energy Meter 6 In 1 featuring a CBU chip based on the BK7231N platform, focusing on challenges with flashing the firmware and integrating the device with ESPHome. Initial attempts to flash the device using common tools like bkWriter failed; the recommended method involves using the hid_download_py tool for flashing and backing up firmware via UART. The device uses a BL0942 power measurement chip operating in SPI mode, complicating direct UART communication. To enable easier integration, a hardware modification is proposed to reroute BL0942 from SPI to UART by cutting and reconnecting specific traces, including disconnecting the SEL pin from VDD to switch BL0942 to UART mode. Alternatively, recent firmware updates have introduced a BL0942SPI driver in OpenBeken, allowing native SPI support without hardware modifications. Calibration involves using a known power load and adjusting voltage, current, and power settings via the web interface. MQTT integration with Home Assistant is possible but requires manual YAML configuration due to limited autodiscovery support. The device measures current inductively via a non-invasive sensor coil, and the CBU module handles Wi-Fi connectivity and firmware management. Users report issues with duplicate MAC addresses and MQTT entities showing only as switches, which can be resolved by proper configuration and firmware updates. The community provides detailed guidance on flashing procedures, hardware probing, and software configuration to achieve stable operation and full sensor data reporting.
Generated by the language model.

FAQ

TL;DR: Over 150 Tuya/Beken devices already work with OpenBeken [Elektroda, p.kaczmarek2, post #20351359] “No hardware modifications are required” [Elektroda, p.kaczmarek2, post #20537263] to read power on the CBU-based 6-in-1 meter after flashing. Follow the backup-flash-calibrate routine to avoid data loss.

Why it matters: You can turn a cloud-locked meter into a fully local, Home-Assistant-ready sensor in under 10 minutes.

Quick Facts

• Chipset: BK7231N (CBU), 32-bit @120 MHz, 2 MB flash [Tuya CBU DS]. • Meter IC: BL0942, 0–65 A, 0.1 mA resolution (SPI mode) [BL0942 DS]. • Supported firmware: OpenBeken ≥ 1.17.0 with BL0942SPI driver [Elektroda, p.kaczmarek2, post #20535543] • Typical post-calibration accuracy: ±1 % for power and voltage [BL0942 DS]. • Flashing time: ~35 s at 921 kbit/s using hid_download_py [Elektroda, p.kaczmarek2, post #20347216]

What hardware is inside the Tuya 6-in-1 single-phase energy meter?

The main board carries a Tuya CBU module (Beken BK7231N Wi-Fi MCU) and a BL0942 energy-metering ASIC wired over SPI. Power is derived via a DP2525 buck converter, and current is sensed with a non-intrusive coil around the live conductor [Elektroda, deanfourie, #20350304; p.kaczmarek2, #20356896].

How do I back up the original Tuya firmware?

  1. Connect a USB-TTL adapter to CBU RX1/TX1/GND/3V3.
  2. Run python uartprogram mybackup.bin -d /dev/ttyUSB0 -r -s 0x0 -l 0x200000 [Elektroda, p.kaczmarek2, post #20347216]
  3. Power-cycle the meter when prompted. File mybackup.bin now holds the 2 MB image.

What command starts the BL0942 power-meter driver in SPI mode?

Add startDriver BL0942SPI to Short Startup Command and reboot. Readings appear instantly in the UI [Elektroda, p.kaczmarek2, post #20535543]

Why do I see “bad checksum FF wanted 8D” after reboot?

The BL0942 sometimes returns a stale frame on first poll; OpenBeken retries and recovers. Measurements still publish correctly [Elektroda, alexlimbeck, post #21328576]

How do I calibrate voltage, current and power?

  1. Connect a known 60 W load and verify with a trusted multimeter.
  2. Open Web-App → Tools.
  3. Enter measured values in VoltageSet, CurrentSet, PowerSet fields and press Apply [Elektroda, p.kaczmarek2, post #20535564]

How can I publish readings to Home Assistant over MQTT?

Set MQTT credentials in Network → MQTT. Example YAML:

sensor:
- platform: mqtt
name: "Meter Power"
state_topic: "obk_meter/POWER/get"
unit_of_measurement: W
Channel numbers map to topics like obk_<MAC>/<chan>/get [Elektroda, p.kaczmarek2, post #20355143]

What should I do if two flashed devices share the same MAC?

OpenBeken’s RF tool lets you rewrite the MAC in Config → RF; give each unit a unique address, then reboot [Elektroda, p.kaczmarek2, post #20354694]

Edge case: What if I overwrote my backup file?

You can still restore Tuya stock firmware if another user uploads their dump, but your personalised calibration and Tuya keys are lost [Elektroda, p.kaczmarek2, post #20349087]

What measurement accuracy can I expect after calibration?

BL0942 specifies ±0.5 % energy error over 1 A–40 A; field users report ±1 % after single-point calibration [BL0942 DS].
Generated by the language model.
ADVERTISEMENT