# Counting Problems

**URL:** <https://community.particle.io/t/counting-problems/16284>\
**Category:** Firmware\
**Created:** [October 6, 2015, 2:45pm UTC](https://community.particle.io/t/counting-problems/16284 "2015-10-06T14:45:36Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Hootie81](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hootie81/32/2879_2.png) [@Hootie81](https://community.particle.io/u/Hootie81)\
**Post date:** [October 6, 2015, 11:26pm UTC](https://community.particle.io/t/counting-problems/16284/13 "2015-10-06T23:26:38Z")

</div>

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

> **[Water usage monitor](http://community.particle.io/t/water-usage-monitor/16187)**
>
> Hey all, just wanted to quickly share this project i spent today working on.. This standard Aussie water meter has a little port where you can slip in a reed switch and measure water in 5L increments. So i decided I would use my Photon and a...

---

_[View the full topic](https://community.particle.io/t/counting-problems/16284)._
