Water Flow Sensor with Arduino Programming

Water Flow Sensor to Measure Flow Rate & Volum

The project can be used to measure liquid flowing through a pipe or container or to create a control system based on the water flow rate or quantity.
For example, you could use this while gardening to measure the amount of water used to water your plants, to prevent wastage.

Circuit Diagram:

Connect the LCD pin 1, 3, 5, 16 to GND & 2, 15 to 5V VCC. And then connect LCD pins 4,6,11,12,13,14 to Arduino digital pins D7, D6, D5, D4, D3, D2.
Connect YFS201 Hall Effect Water Flow Sensor VCC pins to 5V Power supply & GND to GND. Since it’s an analog sensor, so connect its analog pin to A0 of Arduino as shown in the figure above.

YFS201 Hall Effect Water Flow Sensor:

This sensor sits in line with your water line and contains a pinwheel sensor to measure how much liquid has moved through it. There’s an integrated magnetic hall effect sensor that outputs an electrical pulse with every revolution. The hall effect sensor is sealed from the water pipe and allows the sensor to stay safe and dry.

The sensor comes with three wires: red (5-24 VDC power), black (ground), and yellow (Hall effect pulse output). By counting the pulses from the output of the sensor, you can easily calculate the water flow rate. Each pulse is approximately 2.25 milliliters. Note this isn’t a precision sensor, and the pulse rate does vary a bit depending on the flow rate, fluid pressure, and sensor orientation. It will need careful calibration if better than 10% precision is required. However, it’s great for basic measurement tasks!

Working of YFS201 Hall Effect Water Flow Sensor:

The Water Flow Sensor for Flow Rate & Volume Measurement using Arduino works on the principle of the Hall effect. According to the Hall effect, a voltage difference is induced in a conductor transverse to the electric current and the magnetic field perpendicular to it. Here, the 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 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. We measure the number of pulses using an Arduino and then calculate the flow rate in liters per hour (L/hr) and total volume in Litre using a simple conversion formula.

Arduino with Water Flow Sensor Code:
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int X;
int Y;
float TIME = 0;
float FREQUENCY = 0;
float WATER = 0;
float TOTAL = 0;
float LS = 0;
const int input = A0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Water Flow Meter”);
lcd.setCursor(0,1);
lcd.print(“     Demo       ”);
delay(2000);
pinMode(input,INPUT);
}
void loop()
{
X = pulseIn(input, HIGH);
Y = pulseIn(input, LOW);
TIME = X + Y;
FREQUENCY = 1000000/TIME;
WATER = FREQUENCY/7.5;
LS = WATER/60;
if(FREQUENCY >= 0)
{
if(isinf(FREQUENCY))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“VOL. :0.00”);
lcd.setCursor(0,1);
lcd.print(“TOTAL:”);
lcd.print( TOTAL);
lcd.print(” L”);
}
else
{
TOTAL = TOTAL + LS;
Serial.println(FREQUENCY);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“VOL.: “);
lcd.print(WATER);
lcd.print(” L/M”);
lcd.setCursor(0,1);
lcd.print(“TOTAL:”);
lcd.print( TOTAL);
lcd.print(” L”);
}
}
delay(1000);
}
Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 514

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×