Coping with Integer limit when Pulse Counting and tracking running totals

Hi

I have implemented a rain gauge and solar DC monitoring using emoncms.

They are both working well but I realised at some time in the future the integers on the emontx modules will overflow.

On the rain gauge specifically I cannot divide the data by ten without losing the precision I need.

There must be ways of dealing with this and I  am trying to get my head round the best solution. My first thought was to use 2 integers and incrementing the first when the second nears its limit, then resetting the second and combining the result (if possible) by adding the feeds in emoncms. This should be good for many years of data despite global warming.

Any other suggestions?

Regards

Ian

dBC's picture

Re: Coping with Integer limit when Pulse Counting and tracking running totals

If the integers live on the Arduino, you can use "long long" and "unsigned long long" if you want 64-bit integer arithmetic, or the more explicit  int64_t and uint64_t.  I'm not sure what happens if you post a number that big to emoncms... should be easy enough to test though.

Ian Eagland's picture

Re: Coping with Integer limit when Pulse Counting and tracking running totals

Thanks

I might set up a test.

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.