Counting Problems

Agreed retained variables are perfect for this, and even one better is to use system threading too, that way you can still count while not connected and once connected it can send the totals.

Here is some code I wrote just the other day to do exactly what your doing but reading a reed switch. And I’m actually in progress to make it report total consumption and the days consumption. I also added a function to set the current meter value to the unit, and changed the code slightly to report in litres instead of pulses