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

[HLW8012] Improve stability and resolution Voltage/Current measurement #4328

Merged
merged 3 commits into from
Nov 3, 2022

Conversation

TD-er
Copy link
Member

@TD-er TD-er commented Nov 2, 2022

Every now and then there would be some fluke measurements, due to some late interrupt handling. Now the pulses on CF1 are counted as well as measured. For low pulse counts, only the duration of the last pulse is taken as it may take some time to get stable pulses. Thus then it is better to use only the last one of a period. For high pulse counts, it is better to take the duration over a longer time and then average over the nr of pulses.

Before this, the "resolution" of the mains voltage measurements were roughly 8V and thus completely unusable.
image
The resolution of the POW r1 using the code from before this PR.

And with this PR included:
image

With these changes, the resolution of the mains voltage is closely following the measured voltage of the CSE7766, used in the Sonoff POW2. (less than 0.1 V off in the same wall socket)

image
Left Sonoff POW r1, right Sonoff POW r2
Both measuring interval of 60 seconds, but not exactly at the same second.

TD-er added 3 commits November 3, 2022 00:42
Every now and then there would be some fluke measurements, due to some late interrupt handling.
Now the pulses on CF1 are counted as well as measured.
For low pulse counts, only the duration of the last pulse is taken as it may take some time to get stable pulses. Thus then it is better to use only the last one of a period.
For high pulse counts, it is better to take the duration over a longer time and then average over the nr of pulses.

Before this, the "resolution" of the mains voltage measurements were roughly 8V and thus completely unusable.
With these changes, the resolution of the mains voltage is closely following the measured voltage of the CSE7766, used in the Sonoff POW2. (less than 0.1 V off in the same wall socket)
@TD-er
Copy link
Member Author

TD-er commented Nov 3, 2022

Also made a PR to the original library for these improvements: xoseperez/hlw8012#32

@TD-er TD-er merged commit d67c354 into letscontrolit:mega Nov 3, 2022
@TD-er TD-er deleted the bugfix/HLW8012_jitter branch November 3, 2022 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant