members
Basics: Project 071a Water flow sensor YF-S201
of Acoptex.com in UNO
Basics: Project 071a
Project name: Water flow sensor YF-S201
Tags: Arduino Uno, RPi 20, YF-S201, Hall Effect Water Flow Meter, Hall Effect Water Flow Sensor, Water flow sensor, 1-30L/min Water Flow Hall Counter, Sensor Water control, Water Flow Rate Switch, Flow Meter, Flowmeter Counter
Attachments: sketch1 and sketch2; sketch3 and sketch4
In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):
1.Arduino Uno R3 (you can also use the other version of Arduino)
2. Water flow sensor YF-S201 1pc
3.Arduino IDE ( you can download it from here )
4.Jumper cables M-M
General
We will learn how to connect Water flow sensor YF-S201 to Arduino board and use it to measure the water flow.
Understanding the Water flow sensor YF-S201
The Flow sensor is a device which is used to measure the water flow.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. Flow sensors use acoustic waves and electromagnetic fields to measure the flow through a given area via physical quantities, such as acceleration, frequency, pressure and volume. The sensors are solidly constructed and provide a digital pulse each time an amount of water passes through the pipe.
How does it work?
This picture gives detailed working method of hall effect sensor based water flow sensor, a turbine wheel embed with magnet is placed on a closed plastic envelop and a Hall effect sensor placed, When the water flows through the pipeline, it makes the turbine wheel to rotate and hence the magnet flux interferes the hall sensor, the rate of interference is depends on the speed of water flow, so the hall effect sensor produce pulse signal output, this pulse output can be calculated as water volume.
By counting the pulses from the output of the sensor, you can easily calculate water flow. 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. The pulse signal is a simple square wave so its quite easy to log and convert into liters per minute.
Flow rate can be determined inferentially by different techniques like change in velocity or kinetic energy. Here we have determined flow rate by change in velocity of water. Velocity depends on the pressure that forces the through pipelines. As the pipe’s cross-sectional area is known and remains constant, the average velocity is an indication of the flow rate. The basis relationship for determining the liquid’s flow rate in such cases is Q=VxA, where Q is flow rate/total flow of water through the pipe, V is average velocity of the flow and A is the cross-sectional area of the pipe (viscosity, density and the friction of the liquid in contact with the pipe also influence the flow rate of water).
Pulse frequency (Hz) F = 7.5 * Q, Q is flow rate in Litres/minute
Flow rate (litres/minute) Q = F / 7.5
Flow Rate (litres/hour) Q = (F x 60 min) / 7.5
Litres = Q * time elapsed (seconds) / 60 (seconds/minute)
Litres = (Frequency (Pulses/second) / 7.5) * time elapsed (seconds) / 60
Litres = Pulses / (7.5 * 60)
Pulse return period (seconds) T = 1 / F
The duration of the pulses is equal to the duration of the pauses (seconds) L = T / 2
Flow rate (litres/minute) Q = F / 7.5 = 1 / 7.5 * T = 1 / 15 * L
Since the pulse duration is read in μs, then: Q (litres / minute) = 10^6 / 15*L
Features:
- 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℃
- Working Humidity Range: 35%-80% RH
- Accuracy: ±10%
- Water pressure: less or equal to 1.75 MPa = 17.5 bar
- Output duty cycle: 50% +-10%
- Output rise time: 0.04us
- Output fall time: 0.18us
- Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
- Pulses per Liter: 450
- Durability: minimum 300,000 cycles
- Cable length: 15cm
- 1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread (∅20 mm (outside), ∅10 mm (inside)
- Size: 2.5" x 1.4" x 1.4" (65x36x36 mm)
- Weight: 43 g.
You can find the sensor datasheet here.
Calculation algorithms
There are two algorithms for counting sensor’s pulses.
1. External interrupt. If you count the number of pulses from the sensor using an external interrupt, then the sensor information lead must be connected only to that Arduino digital pin which uses an external interrupt. The advantage of this method is that all sensor’s pulses will be accounted, and for that we don’t need to suspend execution of the sketch. The disadvantage of this method is that not so many Arduino digital pins use external interrupts.
Signals and connections of the Water flow sensor YF-S201
The sensor comes with three wires: red (power), black (ground) and yellow (PVM, Hall effect pulse output).
Wiring
The following picture shows the needed connections with the Arduino Uno
The wiring depends on the algorithm which you selected for counting sensor’s pulses.
1. External interrupt
2. Measuring the pulse (pause) duration
Step by Step instruction
- Do wiring.
- Open Arduino IDE.
- Plug your Adruino Uno board into your PC and select the correct board and com port
- Open up serial monitor and set your baud to 9600 baud
- Verify and upload the the sketch to your Adruino Uno
- The sketch generates the measure of water flow which passes through the sensor by digitally reading the rotatory motion of the wheel inside the sensor. The result is in liters per hour.
Summary
We learnt how to connect Water flow sensor YF-S201 to Arduino board and use it to measure the water flow.
Libraries:
- No libraries required for this project
Sketch:
- See attachment on the begining of this project
Other projects of Acoptex.com










Viewed: 8715 times