Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff POW reports non zero power even with relay open #58

Closed
xoseperez opened this issue Feb 5, 2017 · 22 comments
Closed

Sonoff POW reports non zero power even with relay open #58

xoseperez opened this issue Feb 5, 2017 · 22 comments

Comments

@xoseperez
Copy link
Owner

The power value the Sonoff POW reports is very unstable. Even with the relay opened (no current) it still reads some watts from time to time.

This has been originally reported by user @zerosub in issue #50. Moved here to track it better.

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


I've got a POW flashed with espurna 1.6.9 and the readings when it's idle are almost unusable.
I use MQTT to integrate it with domoticz 3.6953 and even though there is zero usage on the circuit, the reading fluctuate wildly.
I've set it up as the wiki suggests as "electric (Instant + Counter)" and set the type to "Usage" and the energy read to "computed" also.

I've had it up like this for more than a day with the relay turned on and zero electrical usage.

I've wired the POW in the fuse box between the breaker and the outlet. I've plugged in a watt-meter into the socket to verify the voltage, which is pretty stable.
I've also tried to calibrate the POW, but that didn't succeed. I've hooked up an electric radiator that used around 700Ws for a few minutes, the readings did jump up a bit, but were inconclusive.

I've read somewhere that the POW actually sums up the values in flash (?), so the base values might be rubbish already.
Not sure what the POW reports to Domoticz, but the values are definetly non-zero, even with zero load. So Domoticz probably isn't the culprit here, but rather the POW.

I do know C, so I'd like to help if possible. Any pointers?

On a side note: nice work so far, I appreciate your efforts!

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Under 1.6.7 - I do have a few spikes, but I would not say that it is unusable.

2017-03-21 03_46_45-Domoticz.1.6.7.png

2017-03-21 03_47_42-Domoticz.1.6.7.png

If you can not get some basic calibration done then you might have other hardware issues, let me flash to 1.6.9 see if it behaves any different to what I am happy with on 1.6.7.

Later Ferdie

PS did an easy OTA to 1.6.9 - everything worked as expected, will let it sit and report back on the metrics later on.

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


Well, your graph does look a lot better. I have spikes up to 2500W when the relay is on, but idle consumers:
domoticz_power1.PNG

Not sure how I calibrate the POW, when I enter values in the POWER menu on the web interface they disappear when I press "update"..?
I don't expect different behaviour, as lib HLW8012 hasn't had changes recently.

Did you make any changes to espurna? changed some #defines?

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Nope running stock pow-debug-ota. No change made other than flashing FS at the same time.

Later Ferdie

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


Funny thing is, when there is power consumption, the readings are actually pretty good. I had the washing machine on from 8:15 until 10:30.
domoticz_power2.png

So the hardware is probably fine. Maybe there is some inductance on those wires that is picked up by the POW?
Maybe a low pass filter would help?

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


On 1.6.9 now - can not say of it is better or not.

Was wondering if it was the device rebooting - but that does not seem to be the case, I am doing the #85 hack to capture the updates on domoticz.

#!arduino

2017-03-23 21:12:53.661 MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/uptime, Message: 234030
2017-03-23 21:12:53.769 MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/freeheap, Message: 26360
2017-03-23 21:12:53.877 MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/relay/0, Message: 0
2017-03-23 21:12:53.985 MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/vcc, Message: 3138
2017-03-23 21:12:54.093 MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/status, Message: 1

2017-03-23 21_21_30-Domoticz.png

Clearly the device uptime is more than those semi regular patterns.

Maybe it is when vcc drops below a certain point - not sure but letting it run now and logging will check if I can spot anything.

Later Ferdie

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Managed to grab an event ...

#!arduino

MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/power, Message: 3
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/energy, Message: 0.050
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/current, Message: 0.00
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/voltage, Message: 221
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/apower, Message: 0
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/rpower, Message: 0
MySensorsMQTT: Topic: domoticz/in/MyMQTT/14/1/1/0/47/pfactor, Message: 100

We report power and energy consumption but no current ... so maybe a simple "check" of no current then power and energy is also zero ?

This seems to be true for the vast majority of false reports.

2017-03-24 03_22_22-Domoticz.png

2017-03-24 03_23_10-Domoticz.png

Later Ferdie

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


Yes, Ohm's law would agree. ;)

I think that power, current, voltage and cos (phi) should be reported always, or at least without hacks.
I'll check out the hack in #85 and see if that is also the case for my scenario.

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


i think there is an issue with the power calculation here. i just captured these values on my POW with idle consumers.
tmp_Screenshot_2017-03-25-19-43-38~01-321905794.png

the apparent power and cos phi do no add up.
0.13 amps times 230 votes roughly are 30VA.
with a power factor of 1 for a regular sine wave that comes down to about 22 watts.
no idea where the 1600W "active power" in the Screenshot come from.
but the value for "apparent power" seems ok, if the values for voltage and current are to be taken as correct.
in fact there is almost zero load, but that is a different issue.

so, where is the "active power" reading coming from?

@xoseperez
Copy link
Owner Author

The HLW8012 reports three different values: active power (or true power), current and voltage (RMS). With the caveat that it cannot measure current and voltage at the same time. The library that interfaces the chip switches from one to the other every 2 seconds aprox. The active power is directly related to the frequency the HLW8012 outputs in the CF pin. I would think the active power to be more credible... my guess is that sometimes it suffers from spurious readings. Apparent power is calculated multiplying RMS current and voltage (mind they are not measured at the same time) and reactive power is the other side of the power triangle: sqrt(apparent * apparent - active * active).

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


Well, in my case the active power reading was totally wrong. We were at or around zero Watts.
Also, if the power factor is 100% then active power == apparent power.

Even if the power readings would vary wildly between the 2 seconds those values would be shaky at best.
Does the HLW8012 integrate current / power over these intervals, or is is just a one-off measurement?
The datasheet is kind of vague on these issues. Hold-time would be interesting...

edit:
Actually if you switch every 2 seconds between voltage and current in my scenario a different approach might be more useful.
I assume the voltage is constant and only care about current. Zero current is obviously indicated by an frequency of zero, so it's never going to be absolute zero. But a sample timeout of 5 seconds should be sufficient.

For what it's worth I also want to signal when my washing machine is ready. So I need to trigger on zero power usage after some non-zero power usage. Hence I don't need scientifically exact readings (like the HLW8012 can't give those... ;-) ). So I guess I'll tinker with the HLW8012 lib of yours and see if I can get some more reliably readings this way.

@xoseperez
Copy link
Owner Author

Original comment by Nuno Sousa (Bitbucket: nunofgs, GitHub: nunofgs):


Looks like we all had the same idea. I too am using a Sonoff POW on my washing machine. My intent is to receive notifications when a laundry cycle is complete.

I am also having issues with reported power values being non-zero, even when the washing machine is turned off. Here's a graph of the last 24h:

Screen Shot 2017-03-27 at 19.55.55.png

Both of those spikes were when the washing machine was turned off!

If we end up discovering that this is a hardware issue, how about implementing a Kalman filter?

@xoseperez
Copy link
Owner Author

I have just released version 1.7.0 and it has some improvements in the POW side. Basically I'm applying some logic to filter out spurious values. Not a Kalman filter but way more simple. The code is checking power every 5 seconds, I'm filtering out readings different from 0 that are surrounded by 0 readings assuming than even if you havesome power hungry appliance running for less than 5 seconds it won't sum up much. I'm not doing it in the HLW8012 library but in the ESPurna code since I though it is more like a high level (code-wise) hack.

BTW: I am also using my POW in my washing machine and never had the problem since my approach was slightly more complex: I kept a 5 position ring buffer holding whether the reading on each of the last 5 minutes has been more than 100W. If the ring holds more than 2 such readings I set a flag. If the ring gets empty and the flag is set I raise a notification.

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Thanks for the Upgrade to 1.7.0 Xose,

Spotted a single event on the web while the switch was off - active power 90, power factor 100, voltage 222 rest all zero. Decided to re-calibrate - reset power setting first then the normal calibration. MQTT needed to be tickled to connect - just made a root topic change, then it connected, but that was after I spotted the power issue.

Will monitor and see if things look better, my power consumption is low < 50W that I am monitoring when on.

Later Ferdie

@xoseperez
Copy link
Owner Author

The data on the web interface is not filtered out. Those are raw values directly from the HLW8012 library. But if they are single events they get removed when averaging the minute power. I deployed this version to my POW monitoring the washer machine tonight and this is how it looks like without load.

Grafana   Domos.jpeg

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Ah thanks for the info on what has been fixed.... yeah did the upgrade just after 02:00 - good results, no funnies.

2017-03-28 17_35_26-Domoticz.png

Hmm my energy is at zero - need to go dig why.
Later Ferdie

@xoseperez
Copy link
Owner Author

Original comment by Helmut Wieser (Bitbucket: fizze, GitHub: fizze):


wow, what a difference. for me all those spikes just vanished.
seems i can now stay to figure out domoticz and the notification.
thanks xose!

@xoseperez
Copy link
Owner Author

Original comment by Nuno Sousa (Bitbucket: nunofgs, GitHub: nunofgs):


I am also pleasantly surprised. I flashed this yesterday and the power usage stayed at 0 the entire day.

I just did a wash and it worked PERFECTLY. Got a notification 30 seconds after the washer stopped.

Great user experience!

@xoseperez
Copy link
Owner Author

Great to know it's working fine for you guys. I'm closing this one.

@xoseperez
Copy link
Owner Author

Original comment by izhar marinov (Bitbucket: izharmar, GitHub: Unknown):


i upgraded to 1.7.1, the power reports are now much better, but I'm still seeing occasional wrong reports of tens of even hundreds of watts. Seems strange since as far as I understand the report is an average of 12 readings with some spike filtering. I am filtering the data in a openhab rule, so for on/off indications it is good enough, it is a problem for energy metering though.

@xoseperez
Copy link
Owner Author

Original comment by Nuno Sousa (Bitbucket: nunofgs, GitHub: nunofgs):


I have two sonoff POWs. One on a dryer and another on a washer. After upgrading to the latest version they are working flawlessly.

Not a single false positive yet after half a dozen loads.

Maybe your device has a hardware issue?

@xoseperez
Copy link
Owner Author

Removing milestone: 1.7.0 (automated comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant