Elektroda.com
Elektroda.com
X

Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

elurkki 3063 28
  • About The Device
    Nedis Wi-Fi Smart Plug WIFIP121FWT, Remote controllable plug with energy monitoring.


    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)


    Disassembled
    The plug itself
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    To remove the bottom cover, there is need only for simple small screw driver. The cover has small fastener in the each corner of the cover. A bit force is needed, but not that much there is any fear of breaking the cover.
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    There seems to be CB2S BK7231N inside the plug
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    And the energy monitorig chip is BL0937
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    Flasing
    Since I am not electronics guy, I couldn't find regulator from the PCB. There might be, but I went through all chips which I found and none of them were regulator for my eyes. So I used normal FTDI USB to TTL adapter. I soldered short cables to the 3.3V, GND, TX, RX and CEN pins of the BK7231N module.

    Connected everything like this:





    ModuleUSB to TTL
    3.3V3.3V
    GNDGND
    TXRX
    RXTX


    Fetched the binary from:
    https://github.com/openshwprojects/OpenBK7231T_App

    Flasher from:
    https://github.com/OpenBekenIOT/hid_download_py

    Once done I started flasher in my linux machine and connected the CEN pin to GND for 1seconds.
    uartprogram ~/Downloads/OpenBK7231N_QIO_1.14.1.bin -d /dev/ttyUSB0 --unprotect -w --startaddr 0x0

    And the result was this:
    UartDownloader....
    programm....
    Gotten Bus... : | |[ ?k/s]caution: ignoring unexpected reply in SetBaudRate
    Write Successful: |##################################################|[ 16.8k/s]

    Pinout
    Before assembling everything back I used multimeter to check where the pins are connected from module to energy monitoring chip. Other pins were a bit tough for me so I decided to test those in the configuration.





    ModuleConnected to
    TX1BL0937 SEL (pin 8)
    P26BL0937 CF


    BL0937 pin 7 (CF1) was not connected to anywhere.

    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    Job done
    Once the work was done. I removed the wires from the module and plugged in the just flashed plug. Connected to the plug with phone and changed proper SSID and PSK for it.

    Then rebooted it and connected to it from my desktop and everything seems to be working so far.

    Configuration
    Tested where the relay is connected (not TX1 which I assume would be pin 11, and pin 26 since those are energy monitor chip). Found out that relay starts to give nice sound when configured to P8. LED started to work at P6.

    Then configured 11 to be BL0937SEL and 26 to BL0937CF
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    The problem
    The relay works so the plug can be remotely controlled. Unfortunately the BL0937 is not automatically starting up during reboot. When using command startDriver BL0937 the chip seems to be available, but once trying to give VoltageSet etc.. there is just information:
    Info:EnergyMeter:VoltageSet: you gave 230.000000, set ref to inf

    The index page seems like this after the VoltageSet (or after any BL0937 command)
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)

    Any tips are welcome to continue from this.

    Thanks a lot!

    Cool? Ranking DIY
    About Author
    elurkki
    Level 2  
    Offline 
    elurkki wrote 3 posts with rating 3. Been with us since 2022 year.
  • #2
    p.kaczmarek2
    Moderator Smart Home
    Hey @elurkki , thanks for the post and the teardown, I will add it to our online teardowns database.

    Regarding your issue.... that's strange, please give me a while to investigate. I will update my post here later.

    EDIT: I know what might be wrong.
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    the res_v variable is 0 so you get the division by zero here.
    When dividing by zero, you get infinity.
    It sounds like an invalid configuration of BL0937.
    And now that I look at the post...
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    This sounds very implausible.
    CF1 is used to count voltage pulses:
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    It is not possible to measure voltage without CF1. This is why you have zero value in res_v variable.

    How to fix? Well, you have two options.
    1. recheck connections with multimeter to determine where CF1 goes
    2. try to guess where CF1 is, maybe look at other templates, and just try it out, but remember to reboot every time after changing config so BL0937 driver can be reset.
  • #3
    elurkki
    Level 2  
    Hi,

    You are absolutely correct! I opened the plug again and measured all the pins again. The pin 6 was just covered something and didn't give values until I used a bit force to get some values. Sorry for this inconvenience.

    The pin for this is BK7231N (24) -> BL0937 (CF1). Now the BL0937 starts up at the startup.

    Now after setting bootup values like below, everything seems to be working.
    VREF 0.124594
    PREF 1.036207
    IREF 0.008387

    Will continue testing the plugin now.

    Huge thanks!
    -Mika
  • #4
    p.kaczmarek2
    Moderator Smart Home
    I'm happy that it worked out. You might also consider updating to latest version, because it is capable of reporting average power consumption during last hour.
  • #5
    elurkki
    Level 2  
    Hi. Tested how the OTA updating works, and it was really fluent. I do now have 1.14.10 version uploaded to the plug. The Consumption is shown nicely on the plugin web page.
    Is it possible to get the consumption to be shown on Home Assistant? I removed the plug from HA and allowed the plug to do the discovery again, though just Voltage, Current and Power are shown in HA just like earlier with 1.14.1.

    Thanks a lot for tips,
    -Mika
  • #6
    p.kaczmarek2
    Moderator Smart Home
    I am not sure if I understand. Are you asking if the "Energy Consumed Last Hour" is included in the Home Assistant Discovery?
    If so, then no, you'd have to take it out manually. Only Voltage, Current and Power are included in HA discovery.
    That's because the Consumption was added today, we didn't have time to update the Discovery.

    Also, the consumption will be changed in next update and will require configuration by the user with a startup command. Still, it will be more flexible that way. You will be able to change the number of samples, etc.
  • #7
    valeklubomir
    Level 3  
    version 1.14.11 should report alls topic in Home Assistant Discovery.
    It should post: 1x relay 6x sensors (voltage, current, power, energycounter, energycounter_last_hour, consumption_stats)
    5x sensor - float value
    consumption_stats - JSON string
  • #8
    ^ToM^
    Level 41  
    As a reader, I do not know what the author of the above-mentioned of the article he meant. :D
  • #9
    p.kaczmarek2
    Moderator Smart Home
    ^ToM^ wrote:
    As a reader, I don't know what the author of the above-mentioned of the article he had in mind. :D

    This article by a friend from the USA or abroad, was machine translated, shows the inside of a smart WiFi socket and documents what's inside (what WiFi module and what energy measurement system) so that other users know what to expect. The process of uploading the batch is also described. This is generally analogous to:
    https://www.elektroda.pl/rtvforum/topic3887748.html
    it's just that there is a little bit of these sockets together with the users OBK we try to document them so that later it can be easier to change the batch (we give ready pin configuration, etc.).

    I will try to improve the translation of the article in my free time.
  • #10
    valeklubomir
    Level 3  
    Sorry my mistake it was already introduced in earlier version 1.14.7. But confirmed it on my MQTT log, where discovery message was sent from device, may be HA ignored it.????
    I am not really familiar with HA.
  • #11
    p.kaczmarek2
    Moderator Smart Home
    @valeklubomir it might be good to ask @iprak as he is doing the Discovery features. Also, was the energycounter_last_hour included in the HA discovery?
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/httpserver/hass.c
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    oh well, maybe indeed it should. Today I will try to find some time to check it when I get back to home.

    Maybe the key name for HA discovery should be different or HA discovery just don't support it
  • #12
    valeklubomir
    Level 3  
    I have executed Start Home Assistant Discovery and MQTT received following messages:
    Topic: homeassistant/switch/OpenBK7231N_8D1B2BE5_relay_0/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 0","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_relay_0","qos":1,"stat_t":"~/0/get","cmd_t":"~/0/set"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_0/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 voltage","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_0","dev_cla":"voltage","stat_t":"IoTSocket8D1B2BE5/voltage/get"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_1/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 current","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_1","dev_cla":"current","stat_t":"IoTSocket8D1B2BE5/current/get"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_2/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 power","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_2","dev_cla":"power","stat_t":"IoTSocket8D1B2BE5/power/get"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_3/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 energycounter","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_3","dev_cla":"energycounter","stat_t":"IoTSocket8D1B2BE5/energycounter/get"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_4/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 energycounter_last_hour","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_4","dev_cla":"energycounter_last_hour","stat_t":"IoTSocket8D1B2BE5/energycounter_last_hour/get"}
    Topic: homeassistant/sensor/OpenBK7231N_8D1B2BE5_sensor_5/config
    QOS: 2
    Data: {"dev":{"ids":["OpenBK7231N_8D1B2BE5"],"name":"obk8D1B2BE5","sw":"1.0.3","mf":"Beken Corporation","mdl":"BK7231N","cu":"http://192.168.64.185/index"},"name":"obk8D1B2BE5 consumption_stats","~":"IoTSocket8D1B2BE5","avty_t":"~/connected","pl_on":"1","pl_off":"0","uniq_id":"OpenBK7231N_8D1B2BE5_sensor_5","dev_cla":"consumption_stats","stat_t":"IoTSocket8D1B2BE5/consumption_stats/get"}

    I will forward it to @iprak
  • #13
    p.kaczmarek2
    Moderator Smart Home
    @valeklubomir I am testing your new stats system for power consumption (measure the power consumption during last hour and a total one) and I must admit it's great addition! Thank you.
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    I've also fixed a realloc issue in cJSON library on T platform, it should be OK now.
  • #14
    Tilator
    Level 6  
    Hello,

    Is the binary file somewhere to download?

    I don't have Linux installed for now and it sounds a bit overkill to install it all just for one compile.
  • #16
    Tilator
    Level 6  
    Thanks!

    If you bare, one more guestion.

    I have 2 of these and I would like to make a backup from the original FW.

    Is the FW similar for them both or do they have MAC address or something else unique for each device coded in FW?

    I do not need to open them both if flashing OTA does work for the other. I suppose backupping the original FW has to be made by uart.
  • #17
    p.kaczmarek2
    Moderator Smart Home
    RF partition is unique per device (with calibration data), but in case of the emergency, we have a mechanism to restore basic RF. We also have a function to change MAC address.
  • #18
    Tilator
    Level 6  
    Took some time to install everything but now I tried tuya-cloudcutter for direct OTA flashing.

    But I had no luck getting it done. It can download some config from this device but does not flash the new binary. Sounds like it does not work using neither of the available Nedis configurations. This WIFIP121FWT model seems to be different.

    All I have is an old Nokia CA-42 USB to serial adapter. I don't even remember if it's a 5V or 3.3V device. So I guess I'm a bit stuck with this one.

    *******************************************************************

    Edit:

    I got it done using QCNX 16A plug config.

    https://www.elektroda.com/rtvforum/topic3968081.html

    So, it is possible to flash this OTA using tuya-cloudcutter.

    I have not tested it if power measure and everything works, but I assume it's all doable since it can be initially flashed to at least this FW. I used version OpenBK7231N_UG_1.15.643.bin to do this.

    Now it's working OK.

    Does anyone know, can this be used directly using a direct desktop shortcut?

    ESP based FW has this ability. It's possible to make one shortcut to toggle switch on and an other to switch it off. It's faster to use, because there is no need to open a web interface and find a toggle button.

    Is this possible using this FW?

    OK - found it:

    http://openbk7231n_1f78a228/cm?cmnd=Power1%20On
    http://openbk7231n_1f78a228/cm?cmnd=Power1%20Off
  • #19
    p.kaczmarek2
    Moderator Smart Home
    Of course it's possible and it's the same syntax as in Tasmota. You can even do much more, for example, run "startDriver SSDP" in short startup command and get your BK device visible in Windows network places.
  • #20
    Tilator
    Level 6  
    Thanks. It seems this has it all already. I have alot to learn because I'm newbie with it.

    Can you tell me how to make kWh value available?
  • #21
    p.kaczmarek2
    Moderator Smart Home
    What do you mean by available? Are you asking how to get it on OBK www panel or how to get it via HTTP?
  • #22
    Tilator
    Level 6  
    Well, I made pin config for it, but is it possible to make the value available on the devices own web page?

    Or some other way?

    Well - I got the measuring going. Needed to connect pin 24 too.

    There seems to a way to calibrate or at least set calibration values for it. Does this store those values somewhere or does it need to load them every time it boots up? If loading every time, I suppose they must be put to autoexec or some similar file?

    At least voltage value is not correct because it's more than 250V.

    ***************************************************************

    Aha. Web Application -> Tools.
  • #23
    p.kaczmarek2
    Moderator Smart Home
    Hmmm for me the power metering panel has kWh value, if that's what you mean:
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    Regarding calibration, I apologize, it seems that one of the PRs flushed the command docs. I have updated them now, please see:
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md

    I think I also should add a unit mention, I will update docs again soon.

    EDIT: ye, you are right, many commands have wrapper in the Web App

    Added after 4 [minutes]:

    Btw I hope you also know that we have Tasmota-like JSON interface:
    Nedis Wi-Fi Smart Plug WIFIP121FWT (BK7231N, BL0937, CB2S)
  • #24
    Tilator
    Level 6  
    OK. Thanks.

    I got it calibrated and seems to be fine now.

    Json sounds good too to get data out of it.

    Is there any kind of a timer to put it on and off using time?
  • #25
    p.kaczmarek2
    Moderator Smart Home
    You can use addRepeatingEvent with repeats count set to 1 to do something after given amount of time. We have some examples for that in docs. You can also use addClockEvent to make something happen at given time of day at chosen days of week. You can also use change handlers to trigger something to happen when a variable changes, for example after channel changes to 1, or when voltage is higher than 240V, etc.
  • #26
    Tilator
    Level 6  
    Hello again,

    I tested the watchdog now. It starts to ping after delay setting, but should it stop too? Mine keeps pinging again and again without any pause once it starts.

    Should it really work this way?

    And B.T.W: There is still something wrong about energy measurement settings. It went OK at first, but when I changed values, it did not come up again. I suppose it can't reset/edit some settings file or value.

    I did reset all settings and still kWh value "nan":

    Voltage 230.7 V
    Current 7.561 A
    Active Power 1724.2 W
    Apparent Power 1744.9 VA
    Reactive Power 267.7 var
    Power Factor 0.98
    Energy Total nan kWh

    Edit:

    Resetting the total energy counter again fixed this.
  • #27
    Tilator
    Level 6  
    Now that it all works, it would be good time to do something new.

    Connecting an NTC temperature sensor would be nice. What pin should I use for it?
  • #29
    Tilator
    Level 6  
    p.kaczmarek2 wrote:
    Ping interval setting topic:
    https://www.elektroda.com/rtvforum/topic3971520.html

    You can measure resistance with ADC pin and then process loaded value in scripts.


    So, it should take the NTC resistor between ADC and ground.

    Then ADC must be droven up and measure voltage or current?

    Sounds like a task too much for me. Soldering is not hard but all the scripts it takes to measure and drive relay up and down.