Page 1 of 1

### How to sum up the data read by sensor?

Posted: Mon Sep 29, 2014 6:31 am
I have one project to record the usage of water daily use raspberry and water flow sensor . I am able to run the sensor with my code but I do not know how to sum up all the readings.
The water flow meter I use is http://www.seeedstudio.com/wiki/G1/2_Water_Flow_sensor
below is the part of my code

Code: Select all

``````if count >2:
totaltime = endtime - starttime
flow = totaltime * 30 * 0.26417
``````
my question is how to sum up after a new reading had read?

### Re: How to sum up the data read by sensor?

Posted: Mon Sep 29, 2014 7:06 am
Perhaps have a variable called total_flow and add flow to that variable each time flow is calculated.

### Re: How to sum up the data read by sensor?

Posted: Mon Sep 29, 2014 10:04 am
You have to get the value from sensor in liters per second. Read the sensor every second and just add the reading to some variable which you have to set to 0 every day.
Or, if you don't need current flow then just count the pulses and at the end of a day calculate consumption in liters.

### Re: How to sum up the data read by sensor?

Posted: Tue Sep 30, 2014 4:28 am
joan wrote:Perhaps have a variable called total_flow and add flow to that variable each time flow is calculated.
ya, I know the logic but I do not know how to convert it into codes. May u help me ?
after count the amount of water I used every time on and off the tap, how to store it into a variable called total_usage?

### Re: How to sum up the data read by sensor?

Posted: Tue Sep 30, 2014 4:31 am
rgrbic wrote:You have to get the value from sensor in liters per second. Read the sensor every second and just add the reading to some variable which you have to set to 0 every day.
Or, if you don't need current flow then just count the pulses and at the end of a day calculate consumption in liters.
May u help me covert your sentence into coding? As I am new in raspberry, in addition how to make it reset after 12pm

### Re: How to sum up the data read by sensor?

Posted: Tue Sep 30, 2014 7:14 am
There are plenty of web based tutorials.

Perhaps http://www.sthurlow.com/python/ would help?