logo elektroda
logo elektroda
X
logo elektroda

Twin BL0942 mod - Two BL0942 on two UARTs on one power metering device

XJ_  8 2415 Cool? (+7)
📢 Listen (AI):

TL;DR

  • OpenBeken 1.18.17 adds support for a power metering device with two BL0942 chips on UART1 and UART2.
  • ENABLE_BL_TWIN in obk_config.h enables the feature, and BL0942opts 3 selects both ports, with bit0 for UART1 and bit1 for UART2.
  • UART1 remains the main energy counter, while the second BL0942 reports informative readings only and appears in MQTT as _b.
  • The second meter does not contribute to main energy totals yet, and the author recommends disabling UART logging when both ports work.
Generated by the language model.
Energy consumption monitoring module with sensors and mobile app.

This is an interesting device that has two separate power measurement circuits. It can be now run without cloud, in OpenBeken.

I added support (version 1.18.17) for measuring devices with two BL0942 connected to UART1 and UART2 (Beken).

Currently, energy is always counted only from the first BL0942, the second one is informatives and values are not counted in main energy. In the future, the option of counting energy from UART1 and UART2 together could be added.
For HASS (MQTT), the second one reports with the suffix _b.

To use this feature, code must be compiled with flag ENABLE_BL_TWIN enabled in obk_config.h (or using compiler directive)

Code: C / C++
Log in, to see the code


See related topic for online builds: https://www.elektroda.com/rtvforum/topic4033833.html

To activate function, there is a new command BL0942opts [value]
The meaning of the value is simple (bit0 = UART1, bit1 = UART2)
0 - default (as before this modification), one BL0942 on the port according to flag 26 (as the main one, with energy)
3 - two BL0942 on the UART1 and UART2 ports, UART1 is taken as the main one (with energy calculation) and the second as informative (without energy)

When working with both ports, I recommend disabling logging on UART.

To activate the twin BL mode, you need to add the following to autoexec.bat

logtype none
BL0942opts 3
startDriver BL0942


WebUI using two BL0942:
Display with electrical energy data.

Flashing instructions:

Always use an external power supply [3V3] to ensure sufficient power. As bonus, on most devices you don't need to connect the CEN pin and just turn off/on to start flashing.

1. Connect the CBU module to the USBTTL converter using the CBU pins:

VCC , GND , RX1 , TX1

Electronic module highlighting RX1, TX1, RX2, TX2, GND, and VCC connections.

2. Backup the original using BK7231Flasher.exe
- select the correct com port + speed (my USBTTL converter works fine up to 1500000 baud for BK7231N)
- processor set type BK7231N
- read backup
- on / off - reading flash will start

3. Compile your own flash for BK7231N with the ENABLE_BL_TWIN flag enabled
- save the compiled bin to the BK7231Flasher.exe folder with the firmware

4. Upload a new flash using BK7231Flasher.exe
- select correct com + speed 1500000
- processor set type BK7231N
- select compiled bin (the one with ENABLE_BL_TWIN enabled)
- flash backup write
- on / off - flash write starts

4. BK7231Flasher.exe - Change OBK settings for flash write
- set SSID+pass
- write only OBK configuration
- on / off - obk config write starts

This is my "How do I that"
Electronic circuit with sensors placed on a metal tray

Using "spring contacts" pins without soldering.

Circuit board with connected wires and electronic components.

Develop forum topic {history}: https://www.elektroda.com/rtvforum/topic4086343-90.html

About Author
XJ_
XJ_ wrote 140 posts with rating 38 , helped 13 times. Been with us since 2024 year.

Comments

p.kaczmarek2 26 Feb 2025 17:49

Thank you for presentation and implementation! That's the spirit of the open source. Very interesting device. What is the use case for such dual power measurement? And what is the price of this... [Read more]

XJ_ 26 Feb 2025 19:03

PM Added after 3 [minutes]: It was cheaper, a device with one is about 14USD, with two 16USD (discounted) actually, https://www.aliexpress.com/item/1005007938950273.html https://obrazki.elektroda.pl/6407344600_1740592947_thumb.jpg... [Read more]

p.kaczmarek2 26 Feb 2025 19:58

I see, so price is actually very good. It makes it useful for various energy-metering purposes, like figuring out which phase uses the most of electricity, which can be later useful to reduce that reduction. It... [Read more]

_Arecki_ 27 Feb 2025 21:59

. Different phases are probably hard to measure, or at least accurately, as there is only one voltage input. So it could well measure the energy consumption of two consumers on one phase. And this is... [Read more]

XJ_ 28 Feb 2025 09:02

Sure, that's why I use three devices. Each one is on one phase. On each of them, the main BL0942 /UART1/ measures the total power consumption of that particular phase. The second BL0942 /UART2/ on the... [Read more]

p.kaczmarek2 28 Feb 2025 11:06

Correct, I meant it's good for two different devices, not phases. This device is single phase only. [Read more]

groove6j 01 Mar 2025 23:55

Great job! Works well! If someone is too lazy to compile their own build, then I can share my build here. [Read more]

XJ_ 02 Mar 2025 12:30

Thanks [Read more]

FAQ

TL;DR: At about $16 vs $14, this mod targets OpenBeken users who need dual power readings on one BK7231N meter. One contributor sums it up: "Works well!" Enable ENABLE_BL_TWIN, set BL0942opts 3, and OpenBeken reads BL0942 chips on UART1 and UART2, while counting energy only from the first meter. [#21462055]

Why it matters: This setup gives one single-phase device two current measurements, which is useful when you want total usage plus a separate informative sub-load reading without cloud dependence.

Option Approx. price Measurement setup Space impact
Single-BL0942 device $14 One measurement channel Baseline
Dual-BL0942 device $16 discounted Two measurement channels on one single-phase device Saves box space versus two separate units

Key insight: A dual-BL0942 OpenBeken build is best used for two consumers on one phase, not for two different phases. In the current implementation, UART1 remains the main energy source and UART2 adds informative readings only.

Quick Facts

  • Twin support was added in OpenBeken version 1.18.17, with one BL0942 on UART1 and another on UART2 for Beken devices. [#21457209]
  • The required compile-time switch is #define ENABLE_BL_TWIN 1, and the runtime command for dual mode is BL0942opts 3. [#21457209]
  • Flashing uses an external 3.3 V supply, and one reported setup worked up to 1,500,000 baud on BK7231N with BK7231Flasher.exe. [#21457209]
  • Home Assistant over MQTT exposes the second meter with the suffix _b, while main energy remains tied to the first BL0942. [#21457209]
  • Reported pricing was about $14 for a one-meter version and $16 discounted for the two-meter version, with the dual model also saving enclosure space. [#21457428]

How do I enable twin BL0942 support in OpenBeken for a BK7231N device with one BL0942 on UART1 and another on UART2?

Enable the feature at compile time and then turn it on in startup commands. Compile OpenBeken with ENABLE_BL_TWIN set to 1, then add logtype none, BL0942opts 3, and startDriver BL0942 to autoexec.bat. That setup makes OpenBeken use BL0942 chips on UART1 and UART2 on a BK7231N-class device. [#21457209]

What does the OpenBeken command "BL0942opts 3" do on a dual-BL0942 power meter, and how do the bit values map to UART1 and UART2?

BL0942opts 3 enables both BL0942 channels at once. The value uses bit mapping: bit0 = UART1 and bit1 = UART2, so 3 means 1 + 2, or both ports enabled. In that mode, UART1 stays the main meter with energy calculation, while UART2 is read as the secondary informative channel. [#21457209]

Why is energy counted only from the first BL0942 in the current twin BL0942 OpenBeken implementation, and how is the second meter reported?

Energy is counted only from the first BL0942 because the current implementation treats UART1 as the main source. The second BL0942 is informative only, so its values do not enter the main energy total yet. In Home Assistant over MQTT, OpenBeken reports that second channel using the _b suffix. [#21457209]

What is the use case for a single power metering device with two BL0942 chips instead of one?

The main use case is measuring total consumption and a specific sub-load on the same phase. One practical example uses the first BL0942 for total phase consumption and the second for heating consumption on that same phase. That gives one device two useful views without needing two separate single-purpose meters. [#21459474]

How does a dual-BL0942 meter compare with buying two separate BL0942 power metering devices in terms of price and space savings?

The dual-BL0942 meter was reported as cheaper and more compact. One contributor gave approximate prices of $14 for a single-meter device and $16 discounted for a two-meter version, which makes the dual model strong value. Another contributor also noted that it saves space in the box. [#21457530]

What is BL0942, and what role does it play in OpenBeken-based power metering devices?

BL0942 is the power-measurement chip that OpenBeken reads to show electrical values. "BL0942" is a power-metering IC that measures electrical consumption data, with OpenBeken reading it over UART to expose live values and energy-related data in a smart power meter. In this thread, one device uses either one BL0942 or two, with UART1 as the main channel. [#21457209]

What is the CBU module in a BK7231N device, and which pins are used for flashing with a USB-TTL adapter?

The CBU module is the board module you connect directly for flashing. "CBU" is a Wi-Fi module used inside the BK7231N device that hosts the firmware, with exposed serial pins for flashing and recovery through a USB-TTL adapter. The thread lists four flashing connections: VCC, GND, RX1, and TX1. [#21457209]

How do I flash a BK7231N-based dual-BL0942 device with BK7231Flasher.exe, including backup, firmware write, and OBK configuration steps?

Use a three-step process with BK7231Flasher.exe. 1. Connect VCC, GND, RX1, and TX1, choose BK7231N, and read a backup. 2. Compile a BK7231N firmware with ENABLE_BL_TWIN, select the .bin, then write flash at up to 1,500,000 baud if stable. 3. Set SSID and password, then write only the OBK configuration. Power-cycling starts both backup read and flash write in the described setup. [#21457209]

Why is it recommended to disable UART logging when running two BL0942 chips on UART1 and UART2 in OpenBeken?

Disable UART logging to avoid serial-port conflicts when both BL0942 channels are active. The thread explicitly recommends turning logging off on UART during dual-port operation, and the example startup uses logtype none before BL0942opts 3. That reduces the chance of communication problems on UART1 and UART2. [#21457209]

How are the second BL0942 readings exposed in Home Assistant over MQTT, and what does the "_b" suffix mean?

Home Assistant receives the second BL0942 values as separate MQTT entities with the _b suffix. That suffix marks readings from the secondary meter, not the main one. The main BL0942 remains the channel used for energy counting, while the _b entities provide informative secondary measurements. [#21457209]

Why can't one dual-clamp BL0942 device accurately measure two different electrical phases?

It cannot measure two phases correctly because the device has only one voltage input. One contributor states that using one device with two measuring clamps on two phases gives a meaningless power factor. In practice, the thread treats this hardware as single-phase only, even when it has two current measurements. [#21459474]

What is the best way to monitor total phase consumption and heating consumption using three single-phase dual-BL0942 devices?

Use one dual-BL0942 device per phase. On each device, let the main BL0942 on UART1 measure total consumption for that phase, and use the second BL0942 on UART2 to track heating on that same phase. That yields three total-phase readings plus three informative heating readings across a three-phase installation. [#21459474]

Which firmware build options and compiler flags are required to compile OpenBeken with twin BL0942 support enabled?

You must compile OpenBeken with the twin feature enabled. The thread names one required switch: ENABLE_BL_TWIN in obk_config.h, set as #define ENABLE_BL_TWIN 1, or enabled through an equivalent compiler directive. Without that flag, the dual-UART twin BL0942 mode is not available. [#21457209]

What troubleshooting steps should I try if my BK7231N device does not start flashing or communicating reliably at high baud rates with BK7231Flasher.exe?

First, verify power and serial wiring, then lower stress on the link. 1. Recheck VCC, GND, RX1, and TX1, and use an external 3.3 V supply. 2. Power-cycle the device, since the thread notes on/off starts read and write operations. 3. If 1,500,000 baud is unstable on your USB-TTL adapter, use a lower speed and keep UART logging disabled in dual-BL mode. [#21457209]

How should I safely power a BK7231N or CBU module during flashing, and why is an external 3.3V supply recommended?

Power it from an external 3.3 V supply during flashing. The thread says to always use external 3V3 to ensure sufficient power, and adds that many devices then do not need the CEN pin connected. As a practical benefit, simple power off/on can start flashing in that setup. [#21457209]
Generated by the language model.
%}