Running Total calculated from flow rate

To get the total amount you need to integrate the flow rate over time.

Measure the flow rate. Measure the elapsed time since the previous flow measurement.Multiple the flow rate by the elapsed time to get the amount that flowed in that time interval. Add that to your running total.

You want the measurement interval to be relatively small, but not so small that the resolution of your time measurement or flow rate measurement become significant. Sampling once a second would probably be reasonable. Sampling once a millisecond or once a minute probably wouldn't.