xoseperez / hlw8012

HLW8012 library for Arduino and ESP8266 using the Arduino Core for ESP8266.
GNU General Public License v3.0
126 stars 48 forks source link

Fix zero reading if ActivePower if not checked before checking Current #18

Open pm73 opened 5 years ago

pm73 commented 5 years ago

I noticed that if I read only "getApparentPower()" and "getVoltage()" there will by always zero returned by "getApparentPower()".
It seems that "_power" is not updated automatically other than by "getActivePower()" (or by functions which run "getActivePower()" like "getCurrent()" "getReactivePower()" or "getPowerFactor()").

This change makes sure that the "_power" value is updated and it fixed issue for me.

How to reproduce issue:
Try to measure "getApparentPower()" without checking other values.

pm73 commented 5 years ago

@xoseperez any comments?