logo elektroda
logo elektroda
X
logo elektroda

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

XJ_ 
📢 Listen (AI):
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 135 posts with rating 32 , helped 11 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]

%}