Water Flow Gauge

The book "Practical Arduino" by Jonathan Oxer and Hugh Blemings covers a range of projects and techniques from basic to advanced. [Book site] [Buy online]
Post Reply
Posts: 1
Joined: Thu May 30, 2013 3:41 am

Water Flow Gauge

Post by Harnam » Thu May 30, 2013 4:05 am

Hello Everyone !

I just finished uploading the Water Flow Gauge sketch in my Arduino UNO
Everything works fine and it is a great project. But I have a question :?:
What if power failure occurs and after restoration of power, everything goes to ZERO.

I am wondering how to restore the Values of Reset Button A and B so that it remembers
its counter last readings before the power failure.

It has to be <eeprom.h>
but how to do it, Can anyone help to solve this function ????


Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia

Re: Water Flow Gauge

Post by angusgr » Thu May 30, 2013 4:24 am

Hi Harnam,

A good challenge to explore!

Perhaps take a look at the EEPromWriteAnything Arduino example which shows a technique to read and write values longer than a byte (like the 'unsigned long' values stored in the water flow sketch). The example there should give you some ideas about how to go about it:


Bear in mind the EEPROM only supports a finite number of writes (100,000 is all that's guaranteed) before it wears out, so you'll need to make a decision about how often to update the value - for instance if you save a different value every second then you'll hit the write limit in just over a day, if you save every minute then a bit over two months, every hour then close to twelve years, etc.

One thing you can do is make sure you don't write a new value if it hasn't changed from the old value (assuming the water flow doesn't change much.)

Other forum peeps might have some other inventive ideas on how to save the values.

- Angus

Posts: 2
Joined: Mon Sep 25, 2017 3:42 pm

Re: Water Flow Gauge

Post by AllanGH » Mon Sep 25, 2017 4:42 pm

Perhaps, a means of sensing the presence of mains voltage, the cessation of which instigates a "saveState" call to write the desired values to eeprom or SRAM, with a power-up routine to recover said values? In this case, a LiPo battery or super-capacitor could be used to provide the "operational inertia" to achieve the writes before the whole thing goes down.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest