A water flow sensor is a plastic valve body with rotor that provides a hall-effect sensing when water flows through the motor. The motor will roll and the speed will change on a different rate flow. The hall-effect sensor will read the corresponding voltage pulse signal and send the signal to the micro controller and provide liquid flow rate as data.
How it works?
As liquid passes through the valve and the magnetic rotor spins at a rate proportional to flow, a series of magnetic field to stimulate the hall effect sensor and producing a series of voltage pulses. The output voltage pulses are the same voltage level as the input with a frequency proportional flow rate. The output signal can be digital rate totalizes or other electronic controller.
Wiring the Sensor to Arduino Board
Arduino Source Code / Sketch Using the Water Flow Sensor
Demo sketch reading the water flow sensor
int TORBINE; //Measures incrementing signal
int HSensor = 2; //Assign to Arduino Digital Pin 2
void rpm () //Function interrupt call
TORBINE++; //Function measures the incrementing falling edge
pinMode(HSensor, INPUT); //initializes Arduino digital pin 2 as an input
Serial.begin(9600); //Serial communication begin to see the output data
attachInterrupt(0, rpm, RISING); //interrupt is attached
void loop ()
TORBINE = 0; //Set TORBINE to 0 for calculations
sei(); //Enables interrupts
delay (1000); //Delay wait for 1 second
cli(); //Disable interrupts
Calc = (TORBINE * 60 / 7.5); //PULSE multiply by 60 divided by 7.5Q, equal FLOW RATE in L / hour
Serial.print(Calc, DEC); //Show the number calculated above to communication port
Serial.print(" L/hour\r\n"); //Prints L / hour & returns a new line