Elektroda.com
Elektroda.com
X

OpenBeken, WIFIPO120FWT, BL0937 MQTT report threshold and frequency

boozeman 261 22
  • #1
    boozeman
    Level 11  
    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?
  • #2
    p.kaczmarek2
    Moderator Smart Home
    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
  • #3
    ferbulous
    Level 15  
    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
  • #4
    boozeman
    Level 11  
    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
    p.kaczmarek2
    Moderator Smart Home
    @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.
  • #6
    boozeman
    Level 11  
    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
    p.kaczmarek2
    Moderator Smart Home
    @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.
  • #8
    boozeman
    Level 11  
    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!
  • #10
    boozeman
    Level 11  
    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
    p.kaczmarek2
    Moderator Smart Home
    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
    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?
  • #12
    boozeman
    Level 11  
    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
    p.kaczmarek2
    Moderator Smart Home
    @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?
  • #14
    boozeman
    Level 11  
    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.
  • #16
    boozeman
    Level 11  
    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
    
  • #17
    p.kaczmarek2
    Moderator Smart Home
    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...
  • #18
    boozeman
    Level 11  
    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
    Tummi
    Level 13  
    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
    p.kaczmarek2
    Moderator Smart Home
    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?
  • #21
    Tummi
    Level 13  
    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
    boozeman
    Level 11  
    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
    p.kaczmarek2
    Moderator Smart Home
    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