logo elektroda
logo elektroda
X
logo elektroda

Newby questions: 1. Led indicator. 2. simple http commands to Openbeken device...

arjen2 1893 9
ADVERTISEMENT
  • #1 20786836
    arjen2
    Level 3  

    Dear forum,

    These might be newbie questions, but after 2 afternoons of searching, I am reaching out to the more experienced users.
    I bought 2 smart WiFi plugs with an energy meter (Silvergear). I managed to open them up without damage and was able to flash the chip with openbeken or openbkt.

    Some info:
    BK7231N on a CB2S module
    BL0937 = energy meter chip
    The smart plug is pretty unknown, CLY802M-GE.

    The 1st 'issue': LED indicator.
    Everything seems to be functional. I can switch the relay on and off, and it gives me energy statistics. When plugging the device into the mains voltage, the indicator LED (under the button) flashes a few times, probably to indicate a WiFi exchange or startup. However, when the relay is switched on, I'd like the LED to also switch on and vice versa. At this moment, the indicator LED stays off all the time except for the startup flashing. This should be fairly simple, I guess, but I did not find any solution so far (and yes, I did extensive searches...). The LED pin is connected to the RX pin on the BK7231N and is currently assigned as 'WifiLed'.

    2nd question: I already have a lot of IoT going on in my house; however, these are all running on ESP8266 with self-written software (as I was not aware of home automation software at the time I wrote it). I'd like to take little steps in the migration of my IoT devices. I managed to power on/off the smart plug through a GET command in a browser, e.g.

    http://192.168.1.7/cm?cmnd=power%20on

    This is exactly what I want. However, I did not find any command to switch the indicator LED, nor did I find any command to read the energy statistics from the smart plug. I did find the command list from both Tasmota and Openbeken, but most of the commands do nothing.
    When I search for examples, the only one I find is the http://IP/cm?cmnd=power%20on. Ok, that one works, but so far, any other command results in no answer. Only SSID1 gave me a result.

    You probably will now point me in the direction of MQTT, but I'd like to take little steps.

    The 'function' I have in mind for this smart plug is to switch on my 10-liter water heater in the kitchen whenever I have enough solar power during the day. I already installed an IoT computer that measures the energy/power usage and PV solar panels. It would be quite easy to add a few lines to control this smart plug (curl).

    Hope you can help. Thanks,
    Arjen
  • ADVERTISEMENT
  • #2 20787587
    p.kaczmarek2
    Moderator Smart Home
    Hello, thank you for joining our forum. Let's see if I can help you with your questions.

    1. WiFiLED (or, also, the more often used WiFiLED_n) only reflects a WiFi state. If you want to reflect a relay state, use LED or LED_n.
    If you want to have a WiFiLED functionality when WiFi is connecting, and a LED functionality when connected, you could write an event handler for WiFi state change. I can help with that, if that's what you need.
    Still, most of the devices I've seen have separate WiFiLED and relay status LED.

    2. To the best of my knowledge, OpenBeken currently emulates Tasmota features well and the ENERGY block is correctly populated for power metering sockets.
    See sample below:
    Code: JSON
    Log in, to see the code

    Send SENSOR command or STATUS over HTTP to get it.
    Helpful post? Buy me a coffee.
  • #3 20788233
    arjen2
    Level 3  

    Thanks @p.kaczmarek2
    1. The event handler is probably what I want. I'd like it to flash at startup establishing a WIFI connection (as what it does now). When WIFI is established the LED goes off. Then when the relay is ON the LED should be ON and vice versa. I searched the database for event handlers, but did not find an example I can use. Further, I have no idea how to implement that. :(
    Funny thing is that there is probably already an event handler defined somewhere because when I press the button the relay is toggled ON/OFF.

    This device has only one LED on board. Pin 10 (=RXD)

    2. The STATUS and SENSOR command work. I would say this part is answered. Thanks, very helpful indeed.

    However, follow-up question: (let's call it '3')
    3. As I issued the SENSOR command, I get the following:

    {"Time":"1970-01-01T00:00:00","ENERGY":{"Power": 1.269531,"ApparentPower": 2.427892,"ReactivePower": 2.069529,"Factor":0.522894,"Voltage":230.245986,"Current":0.010544,"ConsumptionTotal":0.041849,"ConsumptionLastHour":0.000000}}

    Apparently, I have to start the NTP server somewhere. How and where do I do that?

    Thanks again.
  • ADVERTISEMENT
  • #4 20788260
    p.kaczmarek2
    Moderator Smart Home
    I will reply to the question 3 for now, let me focus on 1 later.

    You just need to start NTP in short startup command:
    
    startDriver NTP
    

    You can check:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    For example:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/faq.md
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20788455
    arjen2
    Level 3  

    Thanks again!
    I managed to edit autoexec.bat with the following:

    startDriver ntp
    ntp_setServer 217.147.223.78
    ntp_timeZoneOfs 2:00

    And that gives the desired output. Why can I not use a 'human readable' address? I tried e.g 0.nl.pool.ntp.org and others but that does not work and I found another topic with the same problem.
    I am actually in 'Amsterdam' time which is +1 timezone. Will it change accordingly with daylight savings? Can check this weekend. It will change on Oct 29.
  • #6 20788458
    p.kaczmarek2
    Moderator Smart Home
    Currently we don't have daylight savings system yet, but it's planned to be implemented.

    I will check why it has to be IP address and fix if possible.

    I'll look into that WiFi LED tomorrow.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20788574
    arjen2
    Level 3  

    Found something odd that may be the cause of the IP address not resolved by DNS.

    When I issue the command 'Status 5' (get network info):

    {"StatusNET":{"Hostname":"Silvergear_nr1","IPAddress":"192.168.1.8","Gateway":"192.168.0.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.0.1","DNSServer2":"0.0.0.0","Mac":"fc:67:1f:8d:f8:da","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}

    The gateway and DNS server IPs (192.168.0.1) differ from the ones I implemented in the configure IP tab (both 192.168.1.254).
  • #8 20795457
    arjen2
    Level 3  

    Hi @p.kaczmarek2,

    Did you find the time to look into this issue? My smart plug suddenly disconnects from WiFi. I will post a separate question. I hope this is a known issue.
  • #9 20795958
    p.kaczmarek2
    Moderator Smart Home
    Thank you for reporting the problem. The issue you've found, namely:
    arjen2 wrote:

    When I issue the command 'Status 5' (get network info):

    {"StatusNET":{"Hostname":"Silvergear_nr1","IPAddress":"192.168.1.8","Gateway":"192.168.0.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.0.1","DNSServer2":"0.0.0.0","Mac":"fc:67:1f:8d:f8:da","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}

    The gateway and DNS server IPs (192.168.0.1) differ from the ones I implemented in the configure IP tab (both 192.168.1.254).

    was caused just by a simple placeholders entered into the JSON, it did not affect the functionality of the device. Still, I pushed a fix for that and it should be available on Github within 15 minutes.

    arjen2 wrote:

    My smart plug suddenly disconnects from WiFi. I will post a separate question. I hope this is a known issue.

    There can be multiple reasons for losing WiFi connection. For example, the lack of PowerSave on cheapest devices may lead to WiFi instability. I already saw a device where toggling relay without PowerSave 1 enabled was causing device to reboot because of the low quality power supply.
    Helpful post? Buy me a coffee.
  • #10 20796238
    arjen2
    Level 3  
    Thanks. I will flash the latest version and have a look at the powersafe documentation.


    Added after 4 [hours] 14 [minutes]:

    Powersave option does make it more stable, the issue is most likely in the power supply. If it persists further I'll open up the device again and replace the capacitors in the Power supply.

    I have changed setting for Pin10 to LED_n (instead of WIFILED_n) and channel 1. It now lights up when the relay is activated. However it would still be nice when at startup the Led would flash indicating that it is trying to connect. I searched for an eventhandler and wifistate. I know I am close but do not know the exact commands. Could you prepare an example I can put in the autoexec.bat ? Thanks.

Topic summary

The discussion revolves around a user seeking assistance with a smart WiFi plug (Silvergear) that has been flashed with OpenBeken firmware. The user is trying to configure the LED indicator to reflect the relay state and is looking for guidance on implementing an event handler for this purpose. Responses provide insights on using the correct LED pin for relay status, the functionality of HTTP commands for energy monitoring, and troubleshooting WiFi connectivity issues. The user also addresses problems with NTP server configuration and power supply stability, indicating that the device disconnects from WiFi intermittently. Solutions include modifying the autoexec.bat file and enabling power-saving features to enhance stability.
Summary generated by the language model.
ADVERTISEMENT