Elektroda.com
Elektroda.com
X
Elektroda.com

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

elurkki 1311 12
  • 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 1, helped 0 times. Been with us since 2022 year.
  • #2
    p.kaczmarek2
    Level 28  
    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
    Level 28  
    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
    Level 28  
    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 2  
    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 40  
    As a reader, I do not know what the author of the above-mentioned of the article he meant. :D
  • #9
    p.kaczmarek2
    Level 28  
    ^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 2  
    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
    Level 28  
    @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 2  
    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
    Level 28  
    @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.