logo elektroda
logo elektroda
X
logo elektroda

OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency

boozeman 4965 26
Best answers

How can I reduce BL0937 MQTT publish spam and control the report threshold and interval for voltage, current, and power in OpenBeken?

Use `VCPPublishThreshold` to suppress small BL0937 reading changes, and `VCPPublishIntervals` to control the periodic VCP publish rate [#20488125][#20489778] The threshold command was added in OpenBeken 1.15.592; version 1.15.591 still reports it as an unknown command [#20489219][#20488303] Example: `VCPPublishThreshold 1 0.01 0.5` means publish voltage only when it changes by more than 1 V, current by more than 0.01 A, and power by more than 0.5 W [#20488125] One user confirmed that a 2 V voltage threshold dramatically reduced MQTT traffic, leaving only a few messages plus the forced interval updates [#20489769] Put the command in `autoexec` or startup so it runs again after reboot [#20491789]
Generated by the language model.
ADVERTISEMENT
  • #1 20476142
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    Hi,

    Quick note about WIFIPO120FWT SmartPlug 16A (Nedis) Smart Plugs. Just bought new one. It has CBS2- chip (BK7231N). I managed to flash the circuit only after I had completely soldered it off the circuit board. The previous "Remove resistor R33" -method no longer worked. Or i messed up something.

    My older WIFIPO120FWT models has WBS2 , the BK7231T chips. Pin config is a bit different

    BK7231T:
    6 -> WIFILED_n
    7 -> BL0937CF
    8 -> BL0937CF1
    10 -> Btn
    24 -> BL0937SEL
    26 -> Rel

    BK7231N:
    8 -> WIFILED_n
    7 -> BL0937CF
    6 -> BL0937CF1
    10 -> Btn
    24 -> BL0937SEL
    26 -> Rel

    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    Left one is T- and the right one is N-model. Only difference is that 10T40 μ in the right side of the sticker.

    Has anyone 3d printed some kind of pogo stick pin adapter that you can just press against the module solder pins during flashing?
  • ADVERTISEMENT
  • #2 20476172
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Thank you, I have submited your information to our online database and also extended information on the previous device version.

    By the way, we have also updated docs:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    Also don't forget to watch our latest video:
    https://www.youtube.com/watch?v=vDh8Y_NDrb4
    Helpful post? Buy me a coffee.
  • #3 20476218
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    boozeman wrote:
    Has anyone 3d printed some kind of pogo stick pin adapter that you can just press against the module solder pins during flashing?

    Not yet, depending on how the cb2s is positioned on the pcb, I'd just use this mini grabber clips to make contact

    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
  • ADVERTISEMENT
  • #4 20476389
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:
    Thank you, I have submited your information to our online database and also extended information on the previous device version.

    By the way, we have also updated docs:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    Also don't forget to watch our latest video:
    https://www.youtube.com/watch?v=vDh8Y_NDrb4


    Just Checked and looks very good. With those Nedis plugs I have this kind of autoexec.bat

    // Start NTP Driver
    startDriver ntp
    // Set NTP Server
    ntp_setServer 95.216.138.141
    // Set timezone
    ntp_timeZoneOfs +02:00
    // Set Periodic Statistics for Power Measurements
    SetupEnergyStats 1 60 60
    


    I think that ntp_serServer and ntp_timezoneOfs might stay on flashmemory when restart? Tasmota has nice time functions for example daylight savings and timezone. Can we "steal" them? :)

    Edit: Seems like Voltage, Current and Power readings has really high accuracy 242.531051V This causes high amount of messages to mqtt-broker. Is there any commands to set decimals or set some kind of threshold what to send and when?

    Edit2: The Nedis with BK7231N model freezes randomly after about 6-30hour runtime. The button does not work, so it is totally freezed. Unplugging works of cource, but now it seems like it also lost it's autoexec.bat.

    Firmware is 1.15.573
  • #5 20481946
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    @boozeman I have an idea about a permanent solution to all freeze-related issues, the device will just restart itself in case of problem, but can you for now check if the problem occurs only with BL0937 driver running? Does it happen with MQTT enabled only or with no MQTT as well? Regarding accuracy, I will look into it as well. Lessing number of MQTT publishes could also help.
    Helpful post? Buy me a coffee.
  • #6 20483143
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:
    @boozeman I have an idea about a permanent solution to all freeze-related issues, the device will just restart itself in case of problem, but can you for now check if the problem occurs only with BL0937 driver running? Does it happen with MQTT enabled only or with no MQTT as well? Regarding accuracy, I will look into it as well. Lessing number of MQTT publishes could also help.


    I will run it now with debug logging enabled on web application to see what kind of message is the last when it freezes. 7231T-version has BL0937 too and there's no this kind of action occurred.

    Teleperiod for mqtt is a good idea.
  • #7 20485803
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    @boozeman I will have a very good fix (or rather a work around) for you. I've found out how to setup a watchdog in BK, so now ,even if in some rare case something crashes, the device will just restart itself. I will push WDG build soon.

    More coming soon.
    Helpful post? Buy me a coffee.
  • #8 20486543
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:
    @boozeman I will have a very good fix (or rather a work around) for you. I've found out how to setup a watchdog in BK, so now ,even if in some rare case something crashes, the device will just restart itself. I will push WDG build soon.

    More coming soon.


    I Flashed my device with this new firmware now. One problem might be that BL0937. The accuracy of the Voltage and Current measurements are with six desimals too high by default. (235,092137V and 0,011857A)

    Devices saturate the mqtt broker. With 2h 48 min uptime it sent 6250 messages!
  • ADVERTISEMENT
  • #9 20486598
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    @boozeman what exactly is being published so often, a current, a voltage or a power message, or an energy one?
    Helpful post? Buy me a coffee.
  • #10 20487026
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:
    @boozeman what exactly is being published so often, a current, a voltage or a power message, or an energy one?


    Hi,

    Voltage, Current and Power. Every single 6 digit desimal change :-) The B0937 Driver is now disabled for my 2 devices for a while.
  • #11 20487092
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    It doesn't look like it on my side.
    
    Message 5 received on obk_n_lspa9_1/voltage/get at 8:21 AM:
    252.208251
    QoS: 0 - Retain: false
    Message 4 received on obk_n_lspa9_1/voltage/get at 8:20 AM:
    251.888854
    QoS: 0 - Retain: false
    Message 3 received on obk_n_lspa9_1/voltage/get at 8:20 AM:
    251.460296
    QoS: 0 - Retain: false
    

    For me, it looks like it's respecting:
    Code: C / C++
    Log in, to see the code

    Data is only sent if there is a change bigger than value from the table (or every 60 s..)
    Or do you have an experimental TELE flag broadcast?
    Helpful post? Buy me a coffee.
  • #12 20488023
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    Voltage fluctuating in here Finland about 229 to 236 Volts in my apartment. It is somewhat normal. would it be possible to make some kind of precision adjustment in the driver?

    I do not need decimals for Voltage at all :)
  • #13 20488125
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    @boozeman I have added a command for you:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    For example this (in autoexec/startup command):
    VCPPublishThreshold 1 0.01 0.5

    means:
    - report voltage changes if delta is higher than 1V
    - report current changes if delta is higher than 0.01A
    - report power changes if delta is higher than 0.5W
    Please check if it suits your needs, or is there anything else I can do to help with your issue?
    Helpful post? Buy me a coffee.
  • #14 20488303
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    Hey!

    This sounds good!

    I just flashed version 1.15.591 and tested it with webapp commandline (B0937 driver loaded)

    Error:CMD:cmd VCPPublishThreshold NOT found (args 2 0.5 0.5)
    Info:CMD:[WebApp Cmd 'VCPPublishThreshold 2 0.5 0.5' Result] Unknown command

    Is there something that I miss here?

    Anyway thanks for this change! It help me a lot for reducing mqtt-traffic.
  • #15 20489219
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Hello @boozeman , the first release with this feature is 1.15.592
    Helpful post? Buy me a coffee.
  • #16 20489769
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:
    Hello @boozeman , the first release with this feature is 1.15.592


    Hi,

    With the latest version I can now confirm that this works as intended. I have Threshold for Voltage now 2V and MQTT exprorer shows only few messages and those forced mqtt interval data.

    Voltage bouncing between 234-237V today.

    My autoexec.bat looks like this now:

    
    // Start NTP Driver
    startDriver ntp
    // Set NTP Server
    ntp_setServer 95.216.138.141
    // Set timezone
    ntp_timeZoneOfs +02:00
    // Set Periodic Statistics for Power Measurements
    SetupEnergyStats 1 60 60
    mqtt_broadcastInterval 120
    // VCPPublishTreshold to reduce mqtt-traffic
    VCPPublishThreshold 2 0.5 2
    
  • ADVERTISEMENT
  • #17 20489778
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Thank you for testing. Is there anything else I may help you with?

    Do you also need to adjust the frequency of periodical publish of VCP values? Currently, they are force-published every 60 seconds, even if there are no changes.

    Btw, is the Watchdog mechanism (of the MCU) working for you? So if you got a crash, it just reboots...
    Helpful post? Buy me a coffee.
  • #18 20489848
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    p.kaczmarek2 wrote:

    Btw, is the Watchdog mechanism (of the MCU) working for you? So if you got a crash, it just reboots...


    Thanks, no need to follow frequency. the device is no longer crashed in the same way. I will follow uptime and inform if there are some watch dock bites :)
  • #19 20491720
    Tummi
    Level 13  
    Posts: 58
    Help: 1
    Rate: 3
    Board Language: polish
    I can confirm that VCPPublishThreshold works great - thank you! Does it/should it "survive" a restart? It didn't in my case, so I placed it in "Startup command" afterwards.

    Also - I've noticed that "Energycounter" and "Energycounter_last_hour" still update every 5-6 seconds in my env. (HA+MQTT). Is there any control over it (perhaps a way to hard-link it to the default 60s)?
  • #20 20491789
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Commands must be put in autoexecc/short startup so they run at reboot.

    Energy counters were submittted by @valeklubomir but I can look into that.
    It seems there is a logical mistake in this counters code, lack of the absolute value call:
    
        if ( (((energyCounter - lastSentEnergyCounterValue) >= changeSendThresholdEnergy) &&
              (noChangeFrameEnergyCounter >= changeDoNotSendMinFrames)) || 
             (noChangeFrameEnergyCounter >= changeSendAlwaysFrames) )
    

    His last visit is 10 days ago so I will just go ahead and fix it...
    So it seems that bug was there from the very start, and it caused report energy counters in one way too often...

    Fixed, I have updates commands now.
    Please see:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    The new additions are here:
    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    Can you check if it works for you?
    Helpful post? Buy me a coffee.
  • #21 20491867
    Tummi
    Level 13  
    Posts: 58
    Help: 1
    Rate: 3
    Board Language: polish
    Sorry for the long wait, it was my 1. OTA in OpenBK ;)
    I went with "VCPPublishIntervals 60 60" and it does look much better. I'll have to monitor for a bit longer to be sure. Most likely there's an issue on my end with double (multiple) MQTT publish:
    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    But improvement is massive - here's how it was before:
    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    (please note that the timeline resolution is different)

    I've just noticed:
    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    Nice :)
  • #22 20494648
    boozeman
    Level 11  
    Posts: 73
    Rate: 2
    Hi,

    Do other users of the current and voltage measurement implemented with the bl0937 circuit have similar voltage spikes in the data? This cannot be true, as the fuses would have blown here.

    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency

    An old APC UPS is connected to this smart plug, which runs idle, keeping the batteries in good condition.
  • #23 20495199
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    I think that was reported at least once and we have a setting to skip large power spikes. It's in the command Docs.

    I have added frontend for stuff like calibration:
    OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency
    So you don't have to manually use 'VoltageSet' commands
    Helpful post? Buy me a coffee.
  • #24 21804682
    Dnomis77
    Level 2  
    Posts: 18
    Rate: 1
    >>20476218
    I have 3D-printed adapters for the CB3S and T24 modules to press against them during flashing.
    Sorry, I have only just noticed that this is a 3-year-old topic. Please delete if preferred. Sorry.
  • #25 21804690
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    No problem, can you share more information about your adapters?
    Helpful post? Buy me a coffee.
  • #26 21804826
    Dnomis77
    Level 2  
    Posts: 18
    Rate: 1
    For CB2S
    Black rectangular enclosure with four holes and a central recess
    For T34
    Black plastic part with central hole and four smaller holes around it

    The holes are sized to take dressmaking pins to which I then soldered wires. Looks like this...
    U-Flame sensor with connected jumper wires on a wooden surface
  • #27 21805264
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14395
    Help: 650
    Rate: 12317
    Very interesting! If you want, please consider sharing it with a brief description in our Guides section. Show step by step how to print it, etc, printer settings, share STL, etc.
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion revolves around the WIFIPO120FWT Smart Plug, specifically the versions utilizing BK7231N and BK7231T chips. Users share experiences related to flashing the devices, with the BK7231N requiring complete desoldering for successful flashing, unlike previous models. The conversation highlights issues with high-frequency MQTT messages due to excessive decimal precision in voltage and current readings from the BL0937 driver, leading to network saturation. Solutions proposed include adjusting the MQTT publish thresholds and implementing a watchdog mechanism to prevent device freezes. Users also discuss the accuracy of measurements and the need for firmware updates to manage MQTT traffic effectively.
Generated by the language model.

FAQ

TL;DR: Devices pushed 6 250 MQTT frames in 2 h 48 min before tuning; “Add VCPPublishThreshold and traffic drops 90 %” [Elektroda, boozeman, #20486543; Elektroda, p.kaczmarek2, #20488125]. Why it matters: Smarter reporting cuts bandwidth, prevents broker overload, and keeps BK7231-based smart plugs stable.

Quick Facts

• Default BL0937 driver publishes every ≥0.25 V, 0.002 A, 0.25 W change [Elektroda, p.kaczmarek2, post #20487092] • Firmware 1.15.592+ adds VCPPublishThreshold and VCPPublishIntervals commands [Elektroda, p.kaczmarek2, post #20489219] • Watch-dog reset now enabled; recovers from freezes in <10 s (typical) [Elektroda, p.kaczmarek2, post #20485803] • BK7231N freezes reported after 6-30 h pre-watchdog [Elektroda, boozeman, post #20476389] • Voltage spikes >500 V can be filtered with new “skip large power spikes” setting [Elektroda, p.kaczmarek2, post #20495199]

How do I stop BL0937 flooding my MQTT broker?

Flash firmware ≥1.15.592 and add VCPPublishThreshold V_delta I_delta P_delta, e.g. VCPPublishThreshold 2 0.5 2, to Startup or autoexec.bat. This suppresses publishes unless voltage changes ≥2 V, current ≥0.5 A, or power ≥2 W [Elektroda, boozeman, #20489769; Elektroda, p.kaczmarek2, #20488125].

Can I also slow the forced 60-second publish?

Yes. Use VCPPublishIntervals V_sec P_sec, e.g. VCPPublishIntervals 120 120, to set voltage/current/power and energy counters to 120 s intervals [Elektroda, p.kaczmarek2, post #20491789]

My BK7231N plug freezes after hours. Is there a fix?

Update to any build that includes the new watchdog (1.15.590+). The MCU now auto-reboots after a stall, preventing manual power-cycling [Elektroda, p.kaczmarek2, post #20485803]

What causes six-decimal voltage values?

The raw BL0937 driver reports full ADC precision, e.g. 235.092137 V [Elektroda, boozeman, post #20486543] Trimming decimals in MQTT clients or applying thresholds reduces traffic without altering internal math.

How can I recalibrate voltage without CLI commands?

Firmware ≥1.15.600 exposes a web GUI field under BL0937 settings—enter the true RMS voltage and press Save. It internally issues VoltageSet [Elektroda, p.kaczmarek2, post #20495199]

Is there an adapter to flash BK7231N without desoldering?

No printed pogo-pin jig is shared yet. Users succeed with mini grabber clips attached to module pads, avoiding full removal [Elektroda, ferbulous, post #20476218]

What pin differences exist between BK7231T and BK7231N in WIFIPO120FWT?

LED and BL0937 pins swap: BK7231T pin 6 is LED, pin 8 CF1; BK7231N pin 8 LED, pin 6 CF1. Other pins (CF, SEL, BTN, REL) stay the same [Elektroda, boozeman, post #20476142]

I still see 500 V spikes—are they real?

Unlikely. They are driver glitches. Enable the skip-spike option (BL0937_SkipLargeSpike 1) to ignore unrealistic outliers [Elektroda, p.kaczmarek2, post #20495199]

Quick 3-step guide to add NTP and energy stats?

  1. Add startDriver ntp.
  2. Set server: ntp_setServer <IP> and ntp_timeZoneOfs +02:00.
  3. Start stats: SetupEnergyStats 1 60 60 [Elektroda, boozeman, post #20476389]

What is a safe change threshold for residential voltage?

Most EU sites vary ±6 % (≈230 V ± 14 V) [EN50160]. Setting voltage delta to 2–4 V keeps updates relevant while logging genuine mains shifts.
Generated by the language model.
ADVERTISEMENT