Interfacing of Water Flow Sensor With Arduino
by elegocart in Circuits > Sensors
194 Views, 1 Favorites, 0 Comments
Interfacing of Water Flow Sensor With Arduino

In this project, we will employ Water flow sensor to know flow rate in liters per hour and display it on the serial monitor.
About Soil moisture Sensor:
Water flow sensor consists of a plastic valve body, a water rotor, and a hall-effect sensor. The rotor rolls when water flows through the valve as a result speed changes with a different rate of flow. The hall-effect sensor outputs the corresponding flow of liquid into a pulse signal. This one is mostly employed to detect flow in water dispenser or coffee machine.
Components Required:
- Arduino board 1
- Water Flow sensor 1
- Jumper wires
- Breadboard 1
you can buy these components from elegocart.
Project Setup:

Code:
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int Lit_hour; // Calculated litres/hour unsigned char WFlowsensor = 2; // Sensor Input unsigned long CurrentTime; unsigned long LoopTime;
// An Interrupt function void flow () { flow_frequency++; }
void setup() { pinMode(WFlowsensor, INPUT); digitalWrite(WFlowsensor, HIGH); // Optional Internal Pull-Up Serial.begin(9600); attachInterrupt(0, flow, RISING); // Setup an interrupt sei(); // Enable interrupts CurrentTime = millis(); LoopTime = CurrentTime; }
void loop () { CurrentTime = millis(); // Every second, calculate and print litres/hour if(CurrentTime >= (LoopTime + 1000)) { LoopTime = CurrentTime; // Updates LoopTime // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. Lit_hour = (flow_frequency * 60 / 7.5); flow_frequency = 0; // Reset the counter Serial.print(Lit_hour, DEC); Serial.println(" Liters/hour"); } }
Downloads
Result:
