# Arduino based Digital Water Flow Meter using YF-S201 Hall Effect Sensor(DIY)

Water Flow Meter is an automatic system for measurement of water flow. This project is using Arduino microcontroller with Hall’s effect based water flow sensor (YF-S201) and LCD is to display output. Sensor is using Hall’s effect; when the water or air flows through the sensor the fans inside the sensor rotate and counts the fluid flow per minute. After calculations on input data, output is displayed on LCD screen.

## What is Water flow meter- an introduction

Water flow meter for measurement of volume of water flowing. For public water supply system, it provides basis of water meters. On industrial scale, it finds many applications in controlled flow of fluids for mixing with solenoid valve for control purposes. The flow rate of water measured in cubic m (m3) or litter on an electronic or mechanical register.

## YF-S201 Hall’s Effect Water Flow Sensor:

This sensor has a Hall’s effect based working principle. When fluid flow through it, it rotates and generates pulsated output after each cycle. This pulse is read by microcontroller and it sends command accordingly.

The sensor comes with three wires: red (5-24VDC power), black (ground) and yellow (Hall effect pulse output). Number of pulses over specified time interval is compared with standard (2.25 ml/pulse approx.) and current flow rate can be calculated. This output is dependent on fluid pressure, flow rate, orientation and location of sensor. (limitations and operating range is given in table below)

We have as example Arduino sketch that can be used to quickly test the sensor, it will calculate the approximate flow of water in liters/hour.

The pulse signal is a simple square wave so it’s quite easy to log and convert into liters per minute using the following formula:

$$\frac{pulse frequency}{7.5} = flow rate in \frac{L}{min}$$

### Features of YF-S201:

Model: YF-S201
Sensor Type: Hall effect
Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
Max current draw: 15mA @ 5V
Output Type: 5V TTL
Working Flow Rate: 1 to 30 Liters/Minute
Working Temperature range: -25 to +80℃
Maximum water pressure: 2.0 MPa
Output duty cycle: 50% +-10%
Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450

#### Connection of YF-S201 Water Flow Sensor:

Flow meter is shown in figure 1. its colored connection wires are for:

• Red wire : +5V
• Black wire : GND
• Yellow wire : PWM output

## Working of Water Flow Meter using Arduino and YF-S201:

In water flow meter, a small fan wings like rotor is placed in way of fluid. Shaft of this structure has magnetic link with Hall’s effect sensor. When rotor rotates, magnetic field cuts the sensor and when it comes in perpendicular, electrical pulses are generated. With each liter of fluid passing through this sensor, it shows 4.5 pulses on output side (as given in data sheet).  We note total pulses over a specified sample time and with comparison to base value, current water flow rate can be calculated (in liters per hours) with simple following formula:

### Connecting Arduino with Flow Sensor:

The connection of this flow sensor with Arduino is simple. There are only three wires coming from the sensor. The 5V VCC (Red wire), The GND (Black wire), and the signal/pulse (Usually yellow) line. Connect the VCC and GND of the flow meter to the Arduino’s VCC and GND. The pulse line of the flow rate sensor is connected to the Arduino’s digital (pin 2 in this case). The Arduino’s digital pin 2 serves as an external interrupt pin (interrupt pin 0).

Upload the water Flow Meter Code to the Arduino. The code uses an external interrupt on the Arduino’s digital pin 2. This is used to read the pulses coming from the flow meter. When the Arduino detects the pulse, it immediately triggers the pulse Counter () function. This function then counts the total number of pulses.

Dividing the total pulse count obtained by 4.5 will give you the total amount of liquid passing through it in liters per minute. Dividing that by 60 will give you the flow rate in liters per hour, which gives us the total amount or quantity of water/liquid that has passed through it. (Reading is accurate within range of +-3%)

Use this Arduino flow rate sensor with a solenoid valve to monitor and control the water used. we can use it in our gardening system, or interface it with an LCD display for other applications that require to measure water flow rate and quantity.

## Code for Arduino Based Water Flow Meter:

You can download basic sketch and working code (for learning purposes) of arduino based water flow meter in attached document. You can extend this code for your own convenience.

For More Articles and projects stay tuned with us. Like our facebook page to stay tuned.
Share your experience with world with engineerexperiences.com 🙂

## 7 thoughts on “Arduino based Digital Water Flow Meter (DIY)”

1. Veerendra says:

It is very helpfull to us, can you please give some more applications and difference between yf-s201 watet flow meter and earlier techniques like mechanical type or ultrasonic type flow meter.

2. anthony atkinson says:

hi when I verify the code i get the following error

L was not declared in this scope

anybody got any ideas.

cheers

anthony

1. The L/mint in the command
l_mint = (flow_frequency * 1/ 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in
L/mint
Should be in the same line, like that :
l_mint = (flow_frequency * 1/ 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/mint

1. Oops! Line chars limitation make me do the same mistake.
Try this :
l_mint = (flow_frequency * 1/ 7.5); // (Pulse frequency x 60 min) / 7.5Q
// = flowrate in L/mint

3. Tony says:

When the power is turned off, the water consumption value must be memorized. When the power returns, the stored value is added to the consumption. How do I do this?

1. Pehaps these links may help ( remove the spaces between the words ) :

https:// www. arduino. cc/ en/ Reference/ EEPROM
https:// http://www.arduino. cc/ en/ Tutorial/ EEPROMWrite
https:/ /www.arduino. cc/ en/ Tutorial/ EEPROMRead
https:// randomnerdtutorials. com/ arduino- eeprom- explained- remember- last- led- state/
https:// http://www.norwegiancreations. com/ 2017/ 02/ using- eeprom- to- store- data- on- the- arduino/

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