mongoose-os icon indicating copy to clipboard operation
mongoose-os copied to clipboard

Support of HLW8012 energy meter

Open sebastien-savalle opened this issue 5 years ago • 13 comments

Hello,

Many devices (like Shelly 1PM or SonOff Pow R2) are using the HLW8012 sensor to monitor the power consumption. Would it be possible to integrate the HLW8012 library (https://www.arduinolibraries.info/libraries/hlw8012) to Mongoose OS ?

Thanks

sebastien-savalle avatar Mar 20 '20 10:03 sebastien-savalle

I had it on my todo list (because I have those exact Shelly 1PM units), but I'm afraid I won't be able to get to it in the short term. I can work on this in ~June at the earliest, although it would be pretty straight forward to add because the chip is a straight forward I2C speaker. By the way, Shelly 2.5 uses ADE7953 which would've been the first one on my list to implement a driver for.

On Fri, Mar 20, 2020 at 11:35 AM ellavas [email protected] wrote:

Hello,

Many devices (like Shelly 1PM or SonOff Pow R2) are using the HLW8012 sensor to monitor the power consumption. Would it be possible to integrate the HLW8012 library ( https://www.arduinolibraries.info/libraries/hlw8012) to Mongoose OS ?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cesanta/mongoose-os/issues/531, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDRSPMSSDKOHOFIK7ASY4DRINBINANCNFSM4LQIEOFA .

-- Pim van Pelt [email protected] PBVP1-RIPE - http://www.ipng.nl/

pimvanpelt avatar Mar 20 '20 10:03 pimvanpelt

Shelly firmwares are based on Mongoose, so it should not be too difficult to integrate it.

sebastien-savalle avatar Mar 20 '20 12:03 sebastien-savalle

That would be awesome to have this power monitoring available for Shelly 1 PM ! I can't wait !

albanlud avatar Mar 20 '20 13:03 albanlud

I just submitted https://github.com/mongoose-os-libs/ade7953-i2c which is for Shelly 2.5 and confirmed working on my unit:

esp8266_10C60B 5329 1585312791.954 2|mgos_ade7953.c:105      val=4475 hertz=49.988831
esp8266_10C60B 5330 1585312791.961 2|mgos_ade7953.c:114      val=6101779 volts=234.683807
esp8266_10C60B 5331 1585312791.967 2|mgos_ade7953.c:130      reg=794 val=1773 amperes=0.017730
esp8266_10C60B 5332 1585312791.973 2|mgos_ade7953.c:130      reg=795 val=46998 amperes=0.469980
esp8266_10C60B 5333 1585312791.982 2|main.c:16               frequency=49.988831 voltage=234.683807 currentA=0.017730 currentB=0.469980

I do not currently have access to a spare Shelly 1PM for the HLW8012 driver. I've ordered a few units to be able to write and test the driver, and as soon as they arrive I'll work on that next.

pimvanpelt avatar Mar 27 '20 12:03 pimvanpelt

this is great, i can integrate it into https://github.com/mongoose-os-apps/shelly-homekit now

rojer avatar Mar 27 '20 12:03 rojer

By the way, Shelly 1PM seems to be based on BL 0937, not HLW8012, but they are often referenced together so likely the same interface. I will update this issue once I have my hands on either, but could probably use some help testing that one.

pimvanpelt avatar Mar 27 '20 12:03 pimvanpelt

i only have 1 and 2.5 myself, unfortunately

rojer avatar Mar 27 '20 12:03 rojer

I got a "ready to be tested" shelly 1PM, so please do not hesitate to ask for help !

albanlud avatar Mar 27 '20 13:03 albanlud

I got a "ready to be tested" shelly 1PM, so please do not hesitate to ask for help !

Could you check which chip is soldered in the Shelly 1PM ?

sebastien-savalle avatar Mar 29 '20 19:03 sebastien-savalle

It is a BL 0937 ...

albanlud avatar Mar 30 '20 08:03 albanlud

I’ve ported the Arduino HLW8012 power meter sensor library.

It's working fine with the Shelly 1PM. (BL0937) You can have a look here:

https://github.com/ellavas/mongoose-lib-hlw8012

sebastien-savalle avatar Apr 28 '20 17:04 sebastien-savalle

Great job !!

albanlud avatar Apr 28 '20 17:04 albanlud

interesting, i need to take a look. anychance you can integrate it into the firmware as well? i don't even have 1PM to test.

rojer avatar Apr 28 '20 18:04 rojer