Arduino Water Flow Sensor

 1. Introduction


Water management is very important in homes, industries, and agriculture. In this project, we design an Arduino-based Water Flow Measurement System using a flow sensor to calculate flow rate (L/min) and total water consumed (liters).

This project is useful for:

  • Monitoring water usage in homes
  • Detecting leakage
  • Smart irrigation systems
  • Industrial flow measurement

2. Components

  • Arduino UNO / Nano
  • Water Flow Sensor (YF-S201)
  • 16x2 LCD Display (optional but recommended)
  • 10K Potentiometer (for LCD contrast)
  • Connecting wires
  • Breadboard
  • Power supply

3. Circuit and Connections

Arduino Uno Pinout Diagram
Pinout Diagram of Arduino Uno

Pinout Diagram YF-S201
Pinout Diagram YF-S201

16X2 LCD Pinout Diagram
Pin-out Diagram 16X2 LCD
🔌 Sensor Connections:

  • Red → 5V
  • Black → GND
  • Yellow → Digital Pin 2 (Interrupt Pin)

📺 LCD Connections (Optional):

  • VSS → GND
  • VDD → 5V
  • VO → Potentiometer
  • RS → Pin 12
  • EN → Pin 11
  • D4 → Pin 5
  • D5 → Pin 4
  • D6 → Pin 3
  • D7 → Pin 6

4. Detailed Step By Step Circuit Working

The water flow sensor (YF-S201) contains a rotating turbine inside. When water flows through the sensor:

  1. The turbine rotates
  2. A Hall effect sensor generates pulses
  3. Each pulse represents a small quantity of water
  4. Arduino counts these pulses
  5. Using calibration, flow rate is calculated

👉 More water flow = more pulses


5. Libraries to be included

#include <LiquidCrystal.h>

6. Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

volatile int flow_frequency;
unsigned int l_hour;
float total_liters = 0;

unsigned char flowsensor = 2;

unsigned long currentTime;
unsigned long cloopTime;

void flow () {
flow_frequency++;
}

void setup() {
pinMode(flowsensor, INPUT);
digitalWrite(flowsensor, HIGH);

lcd.begin(16, 2);
lcd.print("Water Flow");

attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING);

currentTime = millis();
cloopTime = currentTime;
}

void loop () {
currentTime = millis();

if(currentTime >= (cloopTime + 1000)) {
cloopTime = currentTime;

l_hour = (flow_frequency * 60 / 7.5);
total_liters += l_hour / 60.0;

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Rate:");
lcd.print(l_hour);
lcd.print(" L/hr");

lcd.setCursor(0,1);
lcd.print("Total:");
lcd.print(total_liters);
lcd.print(" L");

flow_frequency = 0;
}
}

7. Detailed Step By Step Code Working

  • flow_frequency → counts pulses from sensor
  • Interrupt function flow() → increments pulse count
  • Every 1 second:
    • Flow rate calculated using formula
    • Display updated on LCD

👉 Formula used:

  • Sensor gives ~7.5 pulses per liter/min
  • Converted into liters/hour

8. Working Principle

The project works based on the Hall Effect Principle.

  • Water rotates turbine
  • Magnet passes Hall sensor
  • Pulse generated
  • Arduino counts pulses
  • Converts into flow rate

9. Advantages

  • Simple and low cost
  • Accurate measurement
  • Real-time monitoring
  • Easy to expand (IoT, logging)

10. Disadvantages

  • Requires calibration for high accuracy
  • Affected by impurities in water
  • Not suitable for very high pressure

11. Applications

  • Smart water meters
  • Industrial liquid measurement
  • Agriculture irrigation systems
  • Water usage monitoring in homes

12. Conclusion

This project demonstrates how to measure water flow using an Arduino and a simple sensor. It is a highly practical system that can be extended to IoT-based monitoring and automation.

à´¤ുà´Ÿà´•്à´•à´•്à´•ാർക്à´•ാà´¯ി ഇലക്à´Ÿ്à´°ോà´£ിà´•്à´¸് ലളിതമാà´¯ി പഠിà´•്à´•ാം.

Empowering students in Kerala with hands-on technical skills.