I have a water flow sensor with Arduino Megs 2560 board. I am trying to conceptualize the concept to calculate amount of water getting dispensed esp. in 1,2,3,4 and 5 liters quantity.
The Water flow sensors generate pulses/sec when water is flowing through it. In my case it is 4.5 pluses per sec as per specification. I would connect the sensor input to any pin from 22-53 pin.
Suppose I connect to ping 23 so in my setup() function I would add:
attachInterrupt(23, pulseCounter, FALLING);
where pulseCounter is an interrupt function triggered on each signal generated from sensor and increments a variable
void pulseCounter() { // Increment the pulse counter pulseCount++; }
Now how do I calculate the flowrate and water dispensed in milliliters using this information? I am not sure but I understand that I first need to calculate flowrate first, if so is the below formula correct:
flowrate = pulseCount / 4.5;
and to measure amount of litres have dispensed is
flowMilliLitres = (flowRate / 60) * 1000;
as we keep adding flowMilliLitres oto a global variable:
totalMilliLitres += flowMilliLitres;
Please correct my understanding if I am proceeding in wright direction.