Min menu


Arduino Water Flow Sensor Interface – Hookup Guide & Tutorial


In this project, I will show you how to interface a Water Flow Sensor with Arduino. Using this Arduino Water Flow Sensor tutorial as a reference, you can implement a system which can measure the quantity of water (or any liquid) flowing through a pipe.

Circuit Diagram of Arduino Water Flow Sensor Interface

Components Required

  • Arduino UNO
  • YF-S201 Water Flow Sensor
  • Connecting Wires

Circuit Design

Connect the Red and Black wires of the YF-S201 Water Flow Sensor to +5V and GND. Since I will be using the Interrupt feature of the Arduino, only Digital I/O Pins 2 and 3 are possible to connect to the Output of the Water Flow Sensor.
In this project, I have connected the Output of the Water Flow Sensor (Yellow Wire) to Digital I/O Pin 2 of Arduino UNO.


The code for the Arduino Water Flow Sensor Interface is given below. There is a small calculation in the code, which I will explain in the further sections.
const int watermeterPin = 2;
volatile int pulse_frequency;
unsigned int literperhour;
unsigned long currentTime, loopTime;
byte sensorInterrupt = 0;
void setup()
pinMode(watermeterPin, INPUT);
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 ()