YF-S201 WATER FLOW SENSOR INTERFACE WITH ARDUINO
Today we will learn about YF-S201 water flow sensor device. What is YF-S201 water flow sensor device? and how does it work? as well as how to interface flow sensor with Arduino?. Most of you people must have gone to get petrol oil in the car or bike and you will see that if you ask the petrol filling employees to fill the amount of petrol. Then the worker sets the same amount of money on the panel installed in the machine. Then the petrol filling system automatically fills the same liter of oil in the tank of the bike or car in a few seconds, neither less nor more. Or you must have seen the water dispenser machine on the public place that after depositing some money in the machine, the water dispenser machine automatically fills the same amount of water in the glass or bottle. Your termite must have thought that how petrol pump machines or water dispatcher machine fills the liquid in the exact amount. All this is due to the water flow sensor installed in the machine. Water flow sensor senses the flow of liquid.
I am already some articles published based on Arduino projects. If you want to make projects. so you go read articles and try it.
What Is YF-S201 Water Flow Sensor?
YF - S201 Water flow sensor is an electronic device. The water flow sensor measures the flow rate and volume of any type of liquid or water. For example water, petrol, diesel, chemical etc. which is in liquid form. YF-S201 hall effect water flow sensor is covered with an entire plastic body. There is a plastic fan inside it and a permanent magnet is attached to that fan part. And there is a hall effect sensor. Whose job is to measure the process of water coming out from inside the water flow sensor,that how many liters of water have passed through that sensor. Water flow sensor operates in 5v. And this sensor can accurately measure 1 - 30L/ min of water. And water flow sensor can withstand pressure up to <_ 1.75 MPa.
How Does Work?
Water flow sensor is internally divided into two parts. 1st circuit part. The hall effect sensor is there in the circuit part. And in the 2nd part there is a water propeller. The hall effect sensor is placed perpendicular to the water propeller, and the propeller is attached to a shaft, and a permanent magnet is also perpendicular attached to one part of that propeller.When water starts passing through the propeller inside the water flow sensor, the propeller starts rotating under the pressure of the water. Which is a magnet attached to the propeller, so whenever the propeller spins, the magnets in the propeller also start rotating together. We all know that magnets generate electromagnetic flux.When the water passes through the water flow sensor, the turbine and the magnet rotate under the sensor, and due to the emf being generated from the magnet, when the emf comes in contact with the hall effect sensor, the hall effect sensor generates pulse. Read that pulse with the help of Arduino and calculate the pulse with some mathematical formula and measure the flow rate and volume of water, how much liter of water has passed through the sensor. Hall effect sensor has three terminals, one is ground and one is for power supply and one is pulse output pin.
Application
- Water Dispenser Machine
- Coffee Machine
- Soda Machine
- Irrigation System
- Industries etc.
Component Required
- Arduino Uno
- YF-S201 Water Flow Sensor
- +5V DC Power Supply
- Some Jumper Wire
Pin out Of YF-S201 Water Flow Sensor
It has three pins GND pin VCC pin and Pulse output pin.
VCC Pin - To provide 5v dc power supply.
GND Pin - To provide ground.
Pulse Output Pin - To receive pulse signal.
Circuit Diagram
In the circuit above we can see how the water flow sensor is connected to the Arduino and a 12V battery is used to supply the DC power to the circuit. If you want, you can also use a 5V charger instead of the 12V battery. Here the + (plus) terminal of 12V is connected to the Vin pin (input voltage) of the Arduino, and the - (minus)terminal of the 12V battery is connected to the GND pin of the Arduino. Vcc pin of YF -S201 hall effect water flow sensor is Connected to 5v pin of arduino,and GND pin to GND pin of arduino,and pulse output pin of water flow sensor is connected to digital pin D5 of arduino.
Code
const int watermeterPin = 5;
volatile int pulse_frequency;
unsigned int literperhour;
unsigned long currentTime, loopTime;
byte sensorInterrupt = 0;
void setup()
{
pinMode(watermeterPin, INPUT);
Serial.begin(9600);
attachInterrupt(sensorInterrupt, getFlow, FALLING);
currentTime = millis();
loopTime = currentTime;
}
void loop ()
{
currentTime = millis();
if(currentTime >= (loopTime + 1000))
{
loopTime = currentTime;
literperhour = (pulse_frequency * 60 / 7.5);
pulse_frequency = 0;
Serial.print(literperhour, DEC);
Serial.println(" Liter/hour");
}
}
void getFlow ()
{
pulse_frequency++;
}
0 Comments