Water flow measurement with Arduino

The flow sensor used here works on the principle of “Hall Effect”. According to which, a voltage difference is induced in a conductor transverse to the electric current and the magnetic field perpendicular to it. Here, Hall Effect is utilized in the flow meter using a small fan/propeller shaped rotor which is placed in the path of the liquid flowing.

The liquid thus pushes against the fins of the rotor, causing it to rotate. The shaft of the rotor is connected to a hall effect sensor. It is an arrangement of a current flowing coil and a magnet connected to the shaft of the rotor. Thus a voltage/pulse is induced as this rotor rotates. In this flow meter, for every liter of liquid passing through it per minute it outputs about 4.5 pulses. This is due to the changing magnetic field caused by the magnet attached to the rotor shaft. Arduino measure the number of pulses and then calculate the flow rate in L/hr using a simple conversion formula.

The sensor comes with three wires: red (5-24VDC power), black (ground) and yellow (Hall effect pulse output).

Water Flow Measurement Circuit

Use only interrupt pin 2 for sensor connections

Water Flow Sensor Arduino Circuit
Water Flow Sensor Arduino Circuit

Water Flow Sensor Arduino Code

//Water Flow Measurement

volatile int FlowPulse; //measuring the rising edges of the signal
int Calc;                               
int flowsensor = 2;    //The pin-2 location of the sensor Always use this pin as we are using interrupt 0

void setup() {     
   pinMode(flowsensor, INPUT); //initializes digital pin 2 as an input
   Serial.begin(9600);         //This is the setup function where the serial port is initialised,
   attachInterrupt(0, rpm, RISING); //and the interrupt is attached on Pin 2 (INT 0)
}

void loop() {     
 FlowPulse = 0;      //Set NbTops to 0 ready for calculations
 sei();            //Enables interrupts
 delay (1000);      //Wait 1 second
 cli();            //Disable interrupts
 Calc = (FlowPulse * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.println (" L/hour"); //Prints "L/hour"
}

void rpm ()     //This is the function that the interupt calls 
{ 
  FlowPulse++;  //This function measures the rising and falling edge of the hall effect sensors signal
}

Results of Water Flow Measurement

Open Serial monitor and allow flow of some water from sensor or blow air in flow sensor to rotate the rotor.

Arduino Flow Measurement Result
Arduino Flow Measurement Result

Leave a Reply