-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 energy_kWhtoday overflow #2543
Comments
Be aware that in the code line you mentioned the unsigned long value deviced by 100000000 is cast to a float so that's enough to store the Note: You are mixing physical values - kWh (energy, electric work) is not kW (electric power). |
You are right, I'm mixing kWh with kW but it does not change anything on the problem that the maximum theoretical value is 84kWh.
|
You are right, overflow will be after 42.95 kWh |
I agree that there is the possibility of an overflow of the number, but I also agree that there would be a corresponding overflow of the POW, i.e. it would probably melt if it actually carried that much energy. You must have a very big/inefficient refrigerator if you are coming close to overflowing the number. |
I changed unsigned long to uint64_t and it works fine. This is considered a temporary solution, not too economical to the device memory. If we are going to talk about good firmware functionality, there should be no such problem, no matter how likely this limit is. The device runs almost with a continuous load of 3kW for ten days and dont shows aby problems. |
I'm glad it is working for you. Some/many of the early ones had an issue where they would overheat if they that much current flowing through them for any length of time. For measuring power of that magnitude I use current transformers. I also wouldn't trust the connectors and PCB traces with that much current for very long. As far as the change you made goes, yeah you need a larger variable to hold that much usage and maintain accuracy. Using the extra 4 bytes of RAM is not an issue. The question is how did you handle the storage in the RTC ram memory. That memory is very constrained. I am not sure exactly when it gets saved to RTC (looks like when settings change and it needs to reboot, but there might be other cases too). |
5.12.0o * Fix Energy Today and Yesterday overflow (#2543)
5.12.0o * Fix Energy Today and Yesterday overflow (#2543)
5.12.0o * Fix Energy Today and Yesterday overflow (arendst#2543)
5.12.0o * Fix Energy Today and Yesterday overflow (arendst#2543)
Sonoff Pow is is designed to 16A. This means the flow until 3500W. If theoretically we plug in a device with maximum sampling, total daily value may be 84kW (3,5*24).
But in code, total conuter is assigned as:
It means maximal value 4,294,967,295. But energy_kWhtoday is not saved as kW. It is recalculated
to kW by devide 100000000. This is visible on the line 85, file
xdrv_03_energy.ino
. If you calculate maximal daily value, its just 42,9kW - which is half the maximum theoretical measurable value.For example, if you measure the consumption of the refrigerator, you measure absurd values cause the value overflows.
The text was updated successfully, but these errors were encountered: