logo elektroda
logo elektroda
X
logo elektroda

Smart cube with power metering, 2 phase with clamps, 2x BL0942, CBU module, BK7231N

XJ_ 7473 118
Best answers

How can I get the second BL0942 working on UART2 on a BK7231N CBU device?

The zero readings on UART2 were not caused by the BL0942 address; the real problem was UART2 receive on the Beken SDK, which XJ_ traced to an SDK bug and first worked around with polling before finding a proper fix [#21299065][#21304930][#21310881] After the patch, UART2 BL0942 reading was confirmed working on BK7231N and also on BK7231T, with a test showing normal packet reception and the expected BL0942 buffer messages [#21324450][#213130130?]. For dual-sensor devices, the merged solution is to use `BL0942opts 3` plus `startDriver BL0942` in `autoexec.bat`, with `flag 26` disabled; UART1 stays the main sensor with energy calculation, and UART2 is informational only [#21432573] When both UARTs are used, `logtype none` is recommended to avoid serial logging interference [#21432573] For Home Assistant/MQTT, the second sensor reports with the `_b` suffix [#21432573]
Generated by the language model.
ADVERTISEMENT
  • #91 21422210
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Retry later and if ok, then I can merge. But didn't @insmod include a TCP to UART bridge in his PR? I would suspect that this bridge will also require update for new UART handling?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #92 21422237
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21422210
    my changes to uart are backwards compatible. I only changed UART on the Beken HAL platform, and only those use the new routines with uartindex.
    The others still using old functions.

    Added after 9 [minutes]:

    >>21422210
    What I mean is that the behavior of uart.h is unchanged, and outwardly it works the same as before. The only change in uart.h that affected the rest was

    extern int g_uart_init_counter;

    was changed to
    int get_g_uart_init_counter();


    Added after 11 [minutes]:

    p.kaczmarek2 wrote:
    Retry later and if ok, then I can merge.

    recheck successful
  • #93 21424868
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21422210
    p.kaczmarek2 wrote:
    Retry later and if ok, then I can merge


    @p.kaczmarek2

    Hi, can you merge this? It's still fine, even in version 1.18.34 from today.

    If not, let me know and I'll cancel the PR.

    It's been 3 months and third PR. I'm tired of checking, editing and waiting for someone to make a change so I can merge the 3 month old changes back into the current version.

    Without this change, it's not possible to do twin bl0942 support.

    Thanks.
  • #94 21424915
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Ok I just hope it won't break anything as I didn't manage to do full checks, especially:

    Code snippet showing UART log redirection to UART1 instead of UART2 on Beken with UART command line support.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #95 21424948
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21424915
    I couldn't test everything. If there's a problem, I'll fix it.
  • Helpful post
    #96 21432573
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    Finally, I added support for measuring devices with two BL0942 connected to UART1 and UART2 (Beken).

    PR: https://github.com/openshwprojects/OpenBK7231T_App/pull/1531

    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 activate, there is a new command BL0942opts [value]

    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 dual BL mode, you need to add the following to autoexec.bat

    logtype none
    BL0942opts 3
    startDriver BL0942
    
  • ADVERTISEMENT
  • Helpful post
    #98 21451204
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    @p.kaczmarek2

    Hi, can you merge this PR, please?
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1531

    Thank You.

    Added after 5 [minutes]:

    As usual, the behavior of bl_shared and bl0942 is unchanged and outwardly they work the same as before. I just added new routines using the dataset index.
  • #99 21451211
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    I see, I think I can merge it, but can you also check how much it made the binary file grow?

    @divadiow do you have BL0942 device or BL0937 device to double-check if OBK behaviour is still the same after this PR?
    Helpful post? Buy me a coffee.
  • #100 21451391
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21451211
    BK7231N +1079 bytes (mainly due to double datasets for two sensors and names for mqtt)
    OpenBK7231N_App-twmod_UG_1.18.43-twinbl0942mod.bin 500504 bytes
    OpenBK7231N_App_UG_1.18.43.bin 499425 bytes
  • #101 21451599
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    That's a bit much, especially considering that there are just few people who can use this feature. Would it be possible to introduce a #define to obk_config.h so we can have it disabled by default in main release?

    We have a serious problem with OTA file growing and removing LFS on update on T platform periodically.
    Helpful post? Buy me a coffee.
  • #102 21451722
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21451599
    by adding ENABLE_BL_TWIN I can get 499848 - that's +423 bytes with ENABLE_BL_TWIN mode disabled.

    Is that enough? Shortening it more will probably require a lot more work.

    I tested it with ENABLE_BL_TWIN turned off and on with two BL0942 on BK7231N.
    Both variants work as they should
    I edited the branch and updated PR.
  • Helpful post
    #103 21452680
    divadiow
    Level 38  
    Posts: 4839
    Help: 420
    Rate: 852
    p.kaczmarek2 wrote:
    @divadiow do you have BL0942 device or BL0937 device to double-check if OBK behaviour is still the same after this PR?

    on the face of it, seems OK for BL0937..

    1.18.23
    Screenshot of electrical parameter measurements.
    1531_merge_964b96547bd1
    Screenshot of electrical energy consumption data.

    Screenshot showing data on electrical energy consumption and electrical parameters.
    HA OK before and after

    Added after 15 [minutes]:

    do these code changes only affect BK7231N? I have this for T/BL0942... https://www.elektroda.com/rtvforum/topic4101872.html
  • #104 21452969
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    divadiow wrote:
    do these code changes only affect BK7231N? I have this for T/BL0942

    Internally, the code was changed for all platforms. However, the functionality of the original functions was preserved.

    The possibility of using two bl0942 is currently only available for the Beken platform (Bk7231N / BK7231T), which has implemented support for two UARTs
  • #105 21454665
    divadiow
    Level 38  
    Posts: 4839
    Help: 420
    Rate: 852
    BK7231T / BL0942
    1.18.45
    Screenshot displaying electrical parameters such as frequency, voltage, and energy consumption. Screenshot showing energy data of a device.

    merge_a25ae12c60c3
    Screenshot displaying electrical parameters such as frequency, voltage, and energy consumption. Screenshot showing electrical energy consumption data.
  • #106 21454692
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21454665
    Super, Thank You

    Added after 6 [minutes]:

    @p.kaczmarek2 what do you think, friend?
  • #107 21454909
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    +423 is still a bit much, at least as long as we have just like 2 or 3 known such devices.... would it be possible to optimize it just a little bit futher before merge?

    Which parts have grown so much in flash usage? Maybe if we can break the DRY principle (don't repeat yourself) and introduce extra functions for HA json creation, instead of adding argument that's always 0, we could save more bytes? Or maybe that's not the main reason of size growth... I didn't investigate that much.

    Alternatively, I can merge it when I'll see there are more such devices....

    To anyone reading this topic - let me know if you have dual BL0942 device! How many of you are there?
    Helpful post? Buy me a coffee.
  • #108 21454974
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    p.kaczmarek2 wrote:
    Which parts have grown so much in flash usage?

    well, I don't quite understand it either, maybe because I used typedef struct instead of static array. I didn't add that much new code. I'll try to investigate.

    How many extra bytes are accepted from your side, so I know if I should bother with it?

    Added after 52 [seconds]:

    p.kaczmarek2 wrote:
    To anyone reading this topic - let me know if you have dual BL0942 device! How many of you are there?


    I have four ;-)
  • #109 21455205
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    100 bytes? 200 bytes, maybe, if some people show up with this device? 300 if more people request it?
    Helpful post? Buy me a coffee.
  • Helpful post
    #110 21455536
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21455205
    I changed the code so that with ENABLE_BL_TWIN disabled the UG bin on BK7231N is +110 bytes.
    The change is made by adding the ENABLE_BL_TWIN condition in many more places.
    If it is ok from your side, I will double check the behavior in both modes on HW, update branch and PR. OK?

    Added after 6 [minutes]:

    I just want to point out that there are also a few fixes and improvements included. Additionally, the bl_shared.c sensors dataset with multiple channels could be used elsewhere (e.g. TuyaMCU) and it would add more compatibility with HASS.
  • #111 21455546
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    So it's just +110 bytes now? Also on RBL? Then I think I could merge it.

    TuyaMCU has separate power mechanisms right now, sadly... they don't go through bl_shared
    Helpful post? Buy me a coffee.
  • Helpful post
    #112 21455568
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    Have you thought about shortening the log dtexts? And use long texts only e.g. #ifdef LOG_TEXT_EXT?
    For example, bl_shared has cca 200 bytes of log texts

    Consumption History enabled
    Sample Count: %d
    Sample Interval: %d
    Consumption History disabled
    ConsumptionThreshold: %1.1f
    Read ENERGYMETER status values. sizeof(ENERGY_METERING_DATA)=%d\n


    especially
    
    Read ENERGYMETER status values. sizeof(ENERGY_METERING_DATA)
    


    in bl0942 200 bytes:

    Consumed %i unwanted non-header byte in BL0942 buffer\n
    Skipping packet with bad checksum %02X wanted %02X
    Failed to read reg %02X: bad checksum %02X wanted %02X
    Failed to write reg %02X val %02X: read %02X
    


    What about setting rules for adding texts to the log?

    Added after 1 [minutes]:

    p.kaczmarek2 wrote:
    TuyaMCU has separate power mechanisms right now, sadly... they don't go through bl_shared

    p.kaczmarek2 wrote:
    Also on RBL?

    RBL is +96

    Added after 2 [minutes]:

    p.kaczmarek2 wrote:
    TuyaMCU has separate power mechanisms right now, sadly... they don't go through bl_shared

    well, I also have a Tuya version and I had it modified via bl_shared. But then I bought new cubes, and there were already 2x BL0942 in all of them. So I canceled the changes for Tuya.

    Added after 2 [minutes]:

    p.kaczmarek2 wrote:
    So it's just +110 bytes now?

    OK, I'll check it today evening and let you know.

    Added after 5 [hours] 29 [minutes]:

    @p.kaczmarek2

    Done. UG.bin +90 bytes, RBL +96 bytes in compare to main 45
    tested both variants on real HW with BK7213N

    ENABLE_BL_TWIN disabled (default)
    - flag 26 = 0 - one BL on UART1
    - flag 26 = 1 - one BL on UART2

    ENABLE_BL_TWIN enabled (rbl + 1090 in compare to main 45)
    - BL942opts 0
    - flag 26 = 0 - one BL on UART1
    - flag 26 = 1 - one BL on UART2
    - BL942opts 3, flag 26 = 0
    two BL on UART1 + UART2

    Everything works as it should

    PR -all checks OK
  • #113 21456787
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Ok, you've convinced me, I've merged this PR. Good job, you've managed to solve all the issues well.

    So we finally are able to get two BL0942 working together, but this topic is now 4 pages long, can you consider making a separate teardown/guide topic so people don't have to read through all 4 pages?
    Photos of 2xBL0942 device, configuration details, flashing details, etc, etc. Then we could feature it in Devices section (which is for complete guides, not for WIP topics):
    https://www.elektroda.com/rtvforum/forum507.html
    Then we coudl also link to your topic from OBK readme (I'll add double BL0942 to features list).
    Helpful post? Buy me a coffee.
  • #115 21486675
    maxim2002
    Level 13  
    Posts: 46
    Help: 4
    Rate: 12
    Thanks for great driver guys!
    Got it working on "Built on Mar 6 2025 20:10:04 version 1.18.56" with TONGOU TO-Q-SY1-JWT.
    Setup was super easy.
    Everything worked out of the box.
    Just a feature request: Can we also have frequency published to mqtt.
    Screenshot with data on electricity consumption.
    Screenshot of energy sensor data.

    Many thanks.
  • ADVERTISEMENT
  • #116 21486900
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    maxim2002 wrote:
    Can we also have frequency published to mqtt.

    I'm currently testing an mod to calculate the energy of both channels. I'll see what adding frequency would entail.

    Added after 5 [hours] 23 [minutes]:

    maxim2002 wrote:
    Just a feature request: Can we also have frequency published to mqtt.


    Added frequency. If you want to test it:

    Changes only in TWIN_BL_ENABLED mode:
    - ENERGY_TOTAL and ENERGY_TODAY are now calculated also for the second device. I used ConsumptionHistory[2] to store the values (in normal mode they are used for energy 2 and 3 days ago).

    Changes in standard and TWIN_BL_ENABLED modes:
    - Bug fix in src/cmnds/cmd_main.c - CMD_UARTConsole_Init()
    - Added HASS MQTT frequency, value from device 1, used new static channel SPECIAL_CHANNEL_OBK_FREQUENCY 138

    https://github.com/xjikka/OpenBK7231T_App/tree/twinblenergy
    https://github.com/xjikka/OpenBK7231T_App/actions/runs/13958325510

    To view the frequency in HASS, you will need to rerun the discovery after the update.
  • #117 21487451
    maxim2002
    Level 13  
    Posts: 46
    Help: 4
    Rate: 12
    XJ_ wrote:
    Added frequency.

    That was awesome XJ_, just grabbed your build and OTA'ed on already configured device. All configs where preserved. After reboot and HA discovery I already have frequency available. Very nice job. Thanks.
  • #118 21494249
    maxim2002
    Level 13  
    Posts: 46
    Help: 4
    Rate: 12
    Did some testing. Any clues why I'm getting 0 at power even if others are not indicating that?
    I'm on version twinblenergy_1b511cda2cfb. Didn't calibrate it yet.
    Screenshot of electrical energy data.

    Added after 16 [minutes]:

    Oddly but if toggled Off it shows some residual Power.
    It's same on official release "Built on Mar 23 2025 08:26:16 version 1.18.65".
    Did I mess around something with cables?

    Screen displaying electric energy consumption data with numerical values for frequency, voltage, current, and energy.

    Added after 22 [minutes]:

    Enabling "Flag 25 - [POWER] Allow negative current/power for power measurement (all chips, BL0937, BL0942, etc)" resolves issue, but power is negative.
    Pretty sure I've connected it as indicated on case. Shunt molex is other way around inside the case ?

    Screen displaying electrical energy consumption data with various values.

    "Flag 48 - [PWR] Invert AC dir" has no effect.
  • #119 21500108
    XJ_
    Level 12  
    Posts: 140
    Help: 13
    Rate: 38
    >>21494249
    Try to change the polarity of the clamp

    Added after 9 [minutes]:

    maxim2002 wrote:
    Did I mess around something with cables?

    Change the polarity of clamp red<>black, calibrate it and try again.

    Added after 6 [minutes]:

    maxim2002 wrote:
    "Flag 48 - [PWR] Invert AC dir" has no effect.


    @p.kaczmarek2
    I didn't find any place in the code where this flag (OBK_FLAG_POWER_INVERT_AC) is used.

Topic summary

✨ The discussion focuses on integrating and troubleshooting a smart energy power meter device featuring two BL0942 power metering chips connected via UART1 and UART2 on a Beken BK7231N module (CBU). The primary issue was that the BL0942 on UART1 functioned correctly, while UART2 returned zero values with flag 26 enabled. Investigation revealed that UART2 receive interrupts were broken at the SDK level, requiring a workaround by polling UART2 RX manually. A patch was developed and tested, enabling stable UART2 communication and simultaneous operation of both BL0942 chips. Firmware modifications introduced a new command, BL0942opts, to support dual BL0942 operation with energy calculation from UART1 and informative data from UART2, using MQTT suffix "_b" for the second sensor. Home Assistant (HASS) MQTT discovery was extended to support dual sensors while maintaining backward compatibility. The patch increased firmware size, leading to the introduction of a compile-time flag (ENABLE_BL_TWIN) to enable or disable dual BL0942 support. Testing confirmed stable operation on BK7231N and BK7231T platforms. Additional features such as frequency measurement publication and moving average filtering were added. Users reported calibration and polarity issues with clamps, resolved by reversing clamp polarity and enabling specific flags. The final solution includes firmware branches and pull requests on GitHub, with detailed configuration instructions and community-shared binaries. The discussion also covers logging behavior on UART ports, flashing procedures without desoldering, and troubleshooting steps for consistent sensor data reading.
Generated by the language model.

FAQ

TL;DR: 2 BL0942 chips can now run together on BK7231N and BK7231T in OpenBK using BL0942opts 3; the flash-size overhead was cut to about +90 bytes, and the maintainer confirmed: "I've merged this PR." This FAQ is for users modding dual-channel clamp meters who need stable UART1+UART2 metering, MQTT, and Home Assistant behavior. [#21456787]

Dlaczego to ma znaczenie: Ten wątek turns a half-working dual-UART power meter into a repeatable OpenBK setup with known firmware settings, SDK fixes, and Home Assistant limits.

Opcja Co robi Kiedy używać Ograniczenia
Flag 26 = 0 BL0942 na UART1 Pojedynczy licznik na głównym porcie Brak drugiego kanału
Flag 26 = 1 BL0942 na UART2 Test lub pojedynczy licznik na UART2 Wymaga poprawki UART2 w Beken SDK
BL0942opts 3 Dwa BL0942 na UART1 + UART2 Licznik 2-kanałowy na Beken Energia liczona tylko z kanału A
logtype none Wyłącza log na UART Zawsze przy trybie dual BL0942 Startup log może pojawić się przed autoexec

Najważniejszy wniosek: Problem nie leżał w adresie BL0942 ani w samym driverze, tylko w obsłudze odbioru UART2 w Beken SDK. Po poprawce SDK i właściwym autoexec dwa BL0942 działają równocześnie na BK7231N i BK7231T. [#21324542]

Quick Facts

  • Dual BL0942 support was finally merged on 2025-02-26, after tests on BK7231N and BK7231T plus size optimization from about +423 bytes down to roughly +90 bytes in the default-disabled build path. [#21455568]
  • BL0942 packets are treated as 23-byte frames in the debugging discussion, and corrupted UART2 traffic showed extra bytes and desynchronization when hardware or UART handling was wrong. [#21407663]
  • The standard BL0942 driver runs at 4800 baud, and startDriver BL0942 switches the UART speed to that value, which matters when you sniff traffic or mix logging with metering. [#21407285]
  • For flashing the CBU/BK7231N module without desoldering, the reported working connection was GND, 3V3, RX1, TX1, with no CEN required; the board just needed a normal power-on during the flashing routine. [#21298953]
  • In dual mode, Home Assistant kept backward compatibility by treating channel A as the main channel; channel B was added with _b suffixes, while total energy initially stayed tied to the first BL0942 only. [#21432573]

How do I get two BL0942 energy metering chips working on UART1 and UART2 at the same time on a BK7231N or BK7231T device with OpenBK7231T_App?

Use a build that includes twin BL0942 support and the Beken UART2 fix, then enable dual mode in autoexec. 1. Put logtype none, BL0942opts 3, and startDriver BL0942 into autoexec.bat. 2. Keep Flag 26 disabled in dual mode. 3. Reboot and verify that UART1 is the main channel and UART2 appears as channel B. The merged implementation supports BK7231N and BK7231T, but energy is initially counted only from the first BL0942. [#21432573]

Why does BL0942 on UART2 return only zeros on a CBU/BK7231N device even though the chip responds on the RX2 pin?

Because the chip can answer electrically on RX2 while the SDK still fails to deliver those bytes to the OpenBK receive path. In the thread, TX2 sent the 2-byte request, a PC sniffer saw a 17-byte BL0942 response on RX2, yet the firmware logged bl0942 uart bytes 00. Looping RX2 into RX1 made the first UART receive data immediately, which isolated the fault to UART2 reception, not BL0942 addressing. [#21299078]

What was the actual UART2 bug in the Beken SDK, and how was it fixed for BK7231N and BK7231T?

The real bug was in the Beken SDK UART2 receive handling, not in BL0942 commands. A temporary workaround polled UART2 RX manually from a quick-tick function, but the final fix patched the SDK so UART2 interrupt-driven reading worked normally again. The BK7231N patch was confirmed first, then BK7231T was tested with the matching SDK change and verified to receive UART2 data correctly using the stock app plus the patched SDK. [#21315899]

Which autoexec.bat settings are needed to enable dual BL0942 mode in OpenBK, including BL0942opts 3 and logtype none?

Use exactly the three-line autoexec shown by the developer for dual mode on Beken. It is:
  1. logtype none
  2. BL0942opts 3
  3. startDriver BL0942 This setup disables serial logging after boot, enables the two-chip mode, and starts the BL0942 driver on both UART1 and UART2. The author explicitly recommended disabling UART logging when both ports are active. [#21432573]

When should I use Flag 26 for BL0942, and how does that differ from using BL0942opts 3 on Beken devices?

Use Flag 26 only for single-chip BL0942 selection, not for true dual-chip mode. With Flag 26 = 0, OpenBK reads one BL0942 on UART1. With Flag 26 = 1, it reads one BL0942 on UART2. With BL0942opts 3, OpenBK reads two BL0942 chips at once on UART1 and UART2, and the developer specifically said Flag 26 should be disabled in that mode. [#21404961]

What is a BL0942 chip, and what measurements does it provide in OpenBK-based power meters?

"BL0942 is an energy-metering chip that reads mains-related electrical values over UART, reports packetized measurements, and is used in OpenBK smart meters for live power data." In this thread, OpenBK exposed voltage, current, power, frequency, and energy-related values from BL0942 devices. In dual mode, the second chip first provided informative values only, while total energy stayed tied to the first BL0942 until later experimental work expanded that behavior. [#21486900]

What is a CBU module with BK7231N, and how does it differ from WB2S or WB3S in these smart energy meters?

"CBU is a Beken-based Wi-Fi module that uses the BK7231N SoC, serves as the main controller in some smart meters, and exposes UART and GPIO needed for flashing and metering integration." In this thread, the original device used a CBU with BK7231N, LED on P9, and button on P24. Later tests also used WB2S on BK7231T and WB3S hardware, mainly to validate the same UART2 and BL0942 behavior on other Beken module families. [#21298953]

How can I flash a CBU/BK7231N smart cube without desoldering, and which pins need to be connected?

You can flash it in-circuit through the first UART. The reported working method used four wires: GND, 3V3, RX1, and TX1. The author stated there was no need to use CEN; a normal power-on during the flashing routine was enough. On that same CBU board, the LED was on P9 and the button was on P24, which helps when bringing the module up after flashing. [#21298953]

Why does Home Assistant MQTT discovery work for channel A but not fully for channel B in twin BL0942 builds?

Because channel B discovery was unfinished in the early twin-BL0942 branches. The developer said channel A remained the backward-compatible main channel, while channel B initially only published MQTT values and had not yet been fully added to Home Assistant discovery. Later test builds added basic channel B discovery, but the developer warned the unique IDs for channel B were still provisional and could change. [#21405934]

How are MQTT topics and Home Assistant entities named for dual BL0942 devices, and how is backward compatibility preserved for the main channel?

The main channel keeps the original names such as voltage, current, and power, while the second BL0942 uses _b suffixes such as voltage_b and current_b. That naming preserves existing Home Assistant and MQTT setups for channel A. The maintainer pushed to avoid renaming the main topic to _a, because old HA discovery and configuration.yaml users already expect the original unsuffixed topic names. [#21321740]

What is get_ate_mode_state() in the Beken SDK, and how does ATE mode affect UART handling?

It appears to be an SDK test-related hook, not an OpenBK metering feature. The thread linked UART2 behavior to checks around ATE mode and noted that the key compile-time test symbol was ATE_APP_FUN, tied to CFG_ENABLE_ATE_FEATURE. On BK7231N, that flag was shown as #define CFG_ENABLE_ATE_FEATURE 0, which helped explain why the developer treated the UART2 issue as an SDK logic problem rather than a BL0942 driver bug. [#21310909]

Which approach is better for UART2 on Beken: polling the RX path in software or patching the SDK interrupt handling?

Patching the SDK interrupt handling is better. Polling via a quick-tick function did work as a stopgap, and it proved UART2 bytes could be recovered in software, but the author explicitly preferred finding and fixing the root cause in the SDK. Once the SDK bug was fixed, the workaround was no longer needed, and UART2 worked globally instead of only through BL0942-specific polling logic. [#21310909]

How do I troubleshoot intermittent or corrupted BL0942 readings on UART2 when the log shows messages like 'Consumed unwanted non-header byte in BL0942 buffer'?

Treat that message as a framing or data-integrity warning. 1. Test each BL0942 alone with stock firmware: Flag 26 off for UART1, then on for UART2. 2. Run each path for a long soak test, even 2 days, before re-enabling dual mode. 3. If corruption persists, inspect UART captures for malformed 23-byte packets or extra bytes, because one user’s UART2 stream was described as “crap” while UART1 was clean. [#21407571]

What causes current and power to stay at 0 or go negative on BL0942 clamp-based meters, and how do clamp polarity, Flag 25, and Flag 48 affect that?

Wrong clamp polarity is the first thing to check. One user saw voltage and frequency look normal while current and power stayed at 0.00; enabling Flag 25 allowed negative power readings, which strongly suggested reversed current-sense direction. The recommended fix was to swap the clamp polarity, described as red-to-black reversal, then recalibrate. The same report said Flag 48 had no effect there, and the developer noted he could not find code actually using that AC-invert flag. [#21500108]

Where does OpenBK currently publish frequency for BL0942 devices, and what steps are needed to make frequency appear in MQTT and Home Assistant discovery?

Frequency was later added to MQTT and Home Assistant through a new static channel named SPECIAL_CHANNEL_OBK_FREQUENCY 138. To make it appear, update to a build that includes the frequency change, reboot, and rerun Home Assistant discovery. The author stated that discovery must be rerun after the update, otherwise HA will not create the new frequency entity even if the firmware already publishes it. [#21486900]
Generated by the language model.
ADVERTISEMENT