The sensor s output pin is connected to pin 2 of.
Arduino water flow sensor code.
In this tutorial you will learn how to use one water flow sensor with an arduino board the water flow sensor consists of a plastic valve body a water rotor and a hall effect sensor.
In this project we will interface yfs201 hall effect water flow sensor with arduino for measuring flow rate and volume of water or any other liquid this is a very wonderful project that can be used in industry or at home or at water flow measurement application in water tap tunnel river etc.
Wrote serial port let s prepare the circuit.
It draws a maximum of 15 20ma at 5v dc input.
Water flow sensor for flow rate volume measurement using arduino code along with.
Connect the vcc red and gnd black wires of the water flow sensor to the 5v and gnd of arduino and link pulse output yellow wire of the water flow sensor to arduino s digital pin 2.
The output of the project is to display the quantity of water flowing through the sensor in litres per hour as shown below.
This is used to read the pulses coming from the flow meter.
How to use water flow sensor arduino tutorial.
Note that the water flow sensor is not a power hungry type.
Uploading the flow meter code to the arduino and measuring water flow rate.
For this purpose using interrupts is a best choice.
The complete water flow sensor arduino code is given at the bottom of the page.
S this output goes to any analog signal on arduino.
The explanation of the code is as follows.
In this project use the yf s201 1 2 inch water flow sensor to measure the water flow rate l min and display it on an lcd.
The code uses an external interrupt on the arduino s digital pin 2.
Upload the flow meter code to your arduino.
Anyone can do it.
This type of flow sensor is designed to measure the volume of liquid traveling past a given point a great way to keep tabs on how much water your drip irrigation system is using or any other project were the flow of liquid needs to be tracked.
There is a small calculation in the code which i will explain in the further sections.
We are using the header file of the lcd which eases our interfacing the lcd with arduino and the pins 12 11 5 4 3 9 are allotted for data transfer between lcd and arduino.
When the water flows through the rotor rotor rolls and the speed.
The water sensor has 3 output pins.
In order to obtain this there is a small calculation.
Communication started with 9600 baud void loop int sensor analogread a1.
In this tutorial we will be hooking up a flow sensor to an arduino uno to measure liquid flow.
The code for the arduino water flow sensor interface is given below.
When the arduino detects the pulse it immediately triggers the pulsecounter function.
Incoming analog signal read and appointed sensor serial println sensor.