By using a flow sensor with a microcontroller like Arduino, we can calculate the flow rate, and check the volume of liquid that has passed through a pipe, and control it as required.
Applications of Flow Sensor:
Apart from manufacturing industries, flow sensors can also be found in the:
· Agriculture sector,
· Food processing,
· Water management,
· mining industry,
· Water recycling,
· Coffee machines, etc.
In this project, we are going to build a water flow sensor using Arduino. We will interface the water flow sensor with Arduino and LCD, and program it to display the volume of water, which has passed through the valve. For this particular project, we are going to use the YF-S201water flow sensor, which uses a hall effect to sense the flow rate of the liquid.
The sensor has 3 wires RED, YELLOW, and BLACK as shown in the figure 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 flow sensor consists of a pinwheel sensor that measures the quantity of liquid that has passed through it.
The Working of the YFS201 water flow sensor is simple to understand. The water flow sensor works on the principle of hall-effect. Hall-effects the production of the potential difference across an electric conductor when a magnetic field is applied in the direction perpendicular to that of the flow of current. The water flow sensor is integrated with a magnetic hall-effect sensor, which generates an electric pulse with every revolution. Its design is in such a way that the hall effect sensor is sealed off from the water, and allows the sensor to stay safe and dry.
The picture of the YFS201 sensor module alone is shown below.
To connect with the pipe and water flow sensor, I used two connectors with a female thread as shown below.
According to YFS201 Specifications, the maximum current it draws at 5V is 15mA, and the working flow rate is 1 to 30liters/minute. When the liquid flows through the sensor, it makes contact with the fins of the turbine wheel, which is placed in the path of the flowing liquid. The shaft of the turbine wheel is connected to a hall-effect sensor.
Due to this, whenever water flows 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 flow rates in liter per hour(L/Hr) and then use simple conversion formula to find 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 flow sensor.
The connection of the water flow sensor and LCD (16x2) with the Arduino is given below in table format. Note that the pot is connected inbetween 5V and GND and pot’s pin 2 is connected with the V0 pin of the LCD.
I used a breadboard, and once the connection was done as per the circuit diagram shown above, my testing set-uplooked something like this.
In our project, we connected the water flow sensor to a pipe. If the output valve of the pipe is closed, the output of the water flow sensor is zero (No pulses). There will be no interrupt signal seen at the pin 2 of the Arduino, and the count of the flow_frequency will be zero. In this condition, the code which is written inside the else loop will work.
If the output valve of the pipe is opened. The water flows through the sensor, which in turn rotates the wheel inside the sensor. In this condition, we can observe pulses, which are generated from the sensor. These pulses will act as an interrupt signal to the Arduino UNO. For every interrupt signal (rising edge), the count of the flow frequency variable will be increased by one. The current time and clop Time variable ensure that for every one second the value of the flow frequency is taken for calculation of flow rate and volume. After the calculation is finished, the flow frequency variable is set to zero and the whole procedure is started from the beginning.
The complete work can also be found in the video linked at the bottom of this page. Hope you enjoyed the tutorial and enjoyed something useful, if you have any problems, please leave them in the comment section or use our forums for other technical questions
No preview (download only).