How Do I Address Integral Sensor Precision Loss

I’m using the Integral Sensor to integrate the sum of 2 power values in Watts. The Integral Sensor is used as an input to a Utility Meter with a daily meter reset cycle. The utility meter resets to 0 daily. However, the integral sensor value continues to increase. I would like to automate resetting the integral sensor to 0. How do I do that?

Why do I want to reset the integral sensor? If left operating long enough the integral sensor value will increase so much that small values can no longer be added to it. For example if X is the sensor value, when X is large enough (X+1)-X != 1. For a C++ float variable this happens a little after 1x10^7 (10,000,000). For a C++ double variable this happens a little after 1x10^15.

If I assume the Integral Sensor result is stored in a float, and that my energy increases by 40 kWh/day, then I will start to experience a precision loss around day 250 (10,000,000/40,000). The precision loss can be avoided by resetting the Integral Sensor to 0 periodically, which the Utility Meter input design supports.

There’s no method available to reset an integral helper. A Python float variable is going to have 15 or more significant digits, and you would normally track your usage in kWh not Wh, so that means you’ll start to lose accuracy in about 70 billion years.

I’m willing to bet the devs will solve this issue before then. I’d even bet my life on it :wink:

Thanks for explaining that a Python float is 64 bit double precision, like a C++ double. In my example using Wh it won’t be an issue for about 68 million years. I’ll make a note to fix in future.