0% found this document useful (0 votes)
46 views

Measure Water Flow Rate and Volume Using Arduino

This document describes how to measure water flow rate and volume using an Arduino and a water flow sensor. The water flow sensor detects water flow using the Hall effect and outputs pulses that correspond to flow rate. The Arduino counts these pulses over time to calculate flow in liters per minute and total volume. It displays the real-time flow rate and cumulative volume on an LCD screen. The circuit connects the water flow sensor to an Arduino, which processes the pulse data and outputs readings of water flow in liters per hour and total liters passed.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Measure Water Flow Rate and Volume Using Arduino

This document describes how to measure water flow rate and volume using an Arduino and a water flow sensor. The water flow sensor detects water flow using the Hall effect and outputs pulses that correspond to flow rate. The Arduino counts these pulses over time to calculate flow in liters per minute and total volume. It displays the real-time flow rate and cumulative volume on an LCD screen. The circuit connects the water flow sensor to an Arduino, which processes the pulse data and outputs readings of water flow in liters per hour and total liters passed.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

instructables

Measure Water Flow Rate and Volume Using Arduino

by electronicsworkshop111

In this tutorial, we will measure the water ow rate and volume using an Arduino and a Flow Sensor. In this circuit, the
water ow sensor is linked to an Arduino and an LCD, which is programmed to display the volume of water that has
passed through the valve. The water ow sensor used in this circuit is an S201, which uses a hall e ect to sense the ow
rate of the liquid.
If You want similar Projects CLICK HERE

Supplies:

1 Arduino BoardArduino UNO R3 Development Board https://amzn.to/3UBnwTO


2 LCDDisplay16x2LCDDisplay https://amzn.to/3UhShNH
3 Potentiometer10K https://amzn.to/3NMyzag
4 Water Flow SensorYFS201 Hall E ect Water Flow Sensor https://amzn.to/3XEcnDV
5 Water Pipenormal https://amzn.to/3EHvcxy
7 Connecting wiresjumper wiresome https://amzn.to/3fMoSw7
8 BreadboardNormal https://amzn.to/3FUQlXe

Step 1: YFS201 Water Flow Sensor

Measure Water Flow Rate and Volume Using Arduino: Page 1


The sensor has 3 wires RED, YELLOW, and BLACK as shown in the gure below. The red wire is used for supply voltage
which ranges from 5V to 18V and the black wire is connected to GND. The yellow wire is used for output(pulses), which
can be read by an MCU. The water ow sensor consists of a pinwheel sensor that measures the quantity of liquid that has
passed through it.

YFS201 water ow sensor

The working of the YFS201 water ow sensor is simple to understand. The water ow sensor works on the principle of
hall e ect. Hall e ect is the production of the potential di erence across an electric conductor when a magnetic eld is
applied in the direction perpendicular to that of the ow of current. The water ow sensor is integrated with a magnetic
hall e ect sensor, which generates an electric pulse with every revolution. Its design is in such a way that the hall e ect
sensor is sealed o from the water, and allows the sensor to stay safe and dry.
The picture of the YFS201 sensor module alone is shown below.

YFS201 water ow sensor

To connect with the pipe and water ow sensor, I used two connectors with a female thread as shown below.

Measure Water Flow Rate and Volume Using Arduino: Page 2


connectors with a female thread

According to YFS201 Speci cations, the maximum current it draws at 5V is 15mA, and the working ow rate is 1 to 30
liters/minute. When the liquid ows through the sensor, it makes contact with the ns of the turbine wheel, which is
placed in the path of the owing liquid. The shaft of the turbine wheel is connected to a hall e ect sensor. Due to this,
whenever water ows through the valve it generates pulses. Now, all we have to do is to measure the time for the pluses
or to count the number of pulses in 1 second and then calculate the ow rates in liter per hour (L/Hr) and then use simple
conversion formula to nd the volume of the water which had passed through it. To measure the pulses, we are going to
use Arduino UNO. The pic below shows you the pinout of the water ow sensor.

working of S201 ow sensor

Water Flow Sensor Calculation


As you know,
1 Litre = 1000 mL
So, the range of this sensor is 300mL to 6000mL per minute.
At 1000mL you get 5880 pulses, but is that over a minute otherwise over a second its 5880/60 = 98 Hz square wave which
has a period of 1/98 = 10.2 milliseconds.
For 1mL you calculate 5880/1000 = 5.88/60 = 0.098Hz with a period of 10.2 seconds. In the programming, I will be using
the pulsein to measure the time of a pulse.

Step 2: Connections

The connection of the water ow sensor and LCD(16×2) with the Arduino is given below in table format. Note that the
pot is connected in between 5V and GND and pot’s pin 2 is connected with the V0 pin of the LCD.
Measure Water Flow Rate and Volume Using Arduino: Page 3
Connection diagram

Step 3: Circuit Diagram of How We Can Measure Water Flow Rate and Volume Using
Arduino

CIrcuit Diagram of Measurement of

Water Flow Rate and Volume using Arduino


In this circuit, the water ow sensor is connected to a pipe; if the pipe’s output valve is closed, no water is sensed by the
ow sensor, and thus no pulses are generated. There will be no interrupt signal on Arduino pin 2 and the ow frequency
count will be zero. When the pipe’s output valve is opened, water ows through the sensor, rotating the wheel inside the
sensor. There will now be pulses, and the Arduino will send an interrupt signal, and the count of the ow frequency will
be increased by one for each interrupt signal. In this way we can measure the water ow rate and volume using an
Arduino.
The coding is written in such a way that if there is no pulse, the code written inside the else loop will function. And the
ow frequency on each pulse is used to calculate the water ow rate and volume. When the calculations are completed,
the ow frequency variable is reset to zero, and the process is restarted

Step 4: Source Code


Measure Water Flow Rate and Volume Using Arduino: Page 4
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: hobbytronics.co.uk
*/
volatile int flow_frequency; // Measures flow sensor pulses
// Calculated litres/hour
float vol = 0.0,l_minute;
unsigned char flowsensor = 2; // Sensor Input
unsigned long currentTime;
unsigned long cloopTime;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 9);
void flow () // Interrupt function
{
flow_frequency++;
}
void setup()
{
pinMode(flowsensor, INPUT);
digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
Serial.begin(9600);
lcd.begin(16, 2);
attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Water Flow Meter");
lcd.setCursor(0,1);
lcd.print("Circuit Digest");
currentTime = millis();
cloopTime = currentTime;
}
void loop ()
{
currentTime = millis();
// Every second, calculate and print litres/hour
if(currentTime >= (cloopTime + 1000))
{
cloopTime = currentTime; // Updates cloopTime
if(flow_frequency != 0){
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
l_minute = (flow_frequency / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Rate: ");
lcd.print(l_minute);
lcd.print(" L/M");
l_minute = l_minute/60;
lcd.setCursor(0,1);
vol = vol +l_minute;
lcd.print("Vol:");
lcd.print(vol);
lcd.print(" L");
flow_frequency = 0; // Reset Counter
Serial.print(l_minute, DEC); // Print litres/hour
Serial.println(" L/Sec");
}
else {
Serial.println(" flow rate = 0 ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Rate: ");
lcd.print( flow_frequency );
lcd.print(" L/M");
lcd.setCursor(0,1);
lcd.print("Vol:");
lcd.print(vol);
lcd.print(" L");
}
}
}

Measure Water Flow Rate and Volume Using Arduino: Page 5


Step 5: Uses and Application

Automatic water dispensers.


Soft drink industries
Chemical industries
Smart irrigation systems

Measure Water Flow Rate and Volume Using Arduino: Page 6

You might also like