Blog

YF-S201 Water Flow Sensor – Complete Guide

Water Flow Sensor

YF-S201 Water Flow Sensor

Hall-Effect Pulse Output for Liquid Flow Measurement

The YF-S201 measures flow rate using a small pinwheel turbine mounted directly in the water path - as water flows through the sensor body, it spins this pinwheel at a rate proportional to how fast the water is moving, and a small magnet embedded in the pinwheel passes a Hall-effect sensor once per rotation, generating one electrical pulse per pass. Your microcontroller counts these pulses over a known time window (typically one second) and, using the sensor's documented pulses-per-liter calibration factor, converts that pulse count directly into a flow rate in liters per minute - and by keeping a running total of pulses over time, into cumulative volume as well, the same basic principle water utility meters use. Because it's a mechanical turbine rather than an electronic-only sensing method, it has real physical limits worth respecting: a minimum flow rate below which the pinwheel won't spin reliably, and a maximum rated pressure and flow rate beyond which the plastic housing and turbine bearing wear out faster or fail outright.

1–30 L/min
Flow Range
Hall-Effect Pulse
Output
~450 pulses/L
Calibration Factor

Key features

Hall-Effect Pulse Output

A clean digital pulse train, one pulse per turbine rotation.

Simple Flow Rate Calculation

Pulse frequency converts directly to liters/minute with one constant.

Cumulative Volume Tracking

Running pulse totals give total liters dispensed over time.

Wide Flow Range

Rated from roughly 1 to 30 liters per minute.

Easy 3-Wire Connection

Power, ground, and a single digital pulse output.

Widely Documented

A long-standing hobbyist favorite with abundant example code.

Technical specifications

Supply Voltage 5V – 24V DC
Flow Rate Range 1 – 30 L/min
Output Digital pulse (Hall-effect, open-collector)
Calibration Factor ~450 pulses per liter (commonly used approximation)
Max Working Pressure ~1.75 MPa
Operating Temperature 0°C – 80°C
Accuracy ± 10% (typical, calibration-dependent)
Pipe Thread 1/2" (G1/2) standard fitting
Package Plastic inline flow sensor body

Pinout

PinFunction
Red VCC power supply
Black Ground
Yellow Signal - pulse output

Applications

Automated water dispensing systems Garden and agricultural irrigation flow monitoring DIY water usage meters Aquarium and hydroponic system flow control Beverage and liquid dispensing machines Leak-detection projects (flow when there should be none)

What's in the box

1x YF-S201 water flow sensor with 1/2" fittings

Downloads

Datasheet (PDF) Arduino Flow-Rate / Pulse-Counting Example Sketch
🔌
Pin Connections
1 Table
Pin Connections Table 1
BoardSensor PinConnection
YF-S201Red/Black/Yellow5-24V / GND / board interrupt-capable pin
📟
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black
7 Examples • C/C++ | Boards: Arduino Uno, Arduino Nano, Arduino Mega, ESP32, ESP8266, STM32, Raspberry Pi Pico
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - Arduino Uno
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - Arduino Nano
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - Arduino Mega
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - ESP32
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - ESP8266
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - STM32
YF-S201 Water Flow Measurement Sensor with 1-30Liter/min Flow Rate - Black - Raspberry Pi Pico
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_arduino_uno.inoArduino Uno
655 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin 2 on Arduino Uno (needs an interrupt-capable pin)
6#define FLOW_PIN 2
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_arduino_nano.inoArduino Nano
656 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin 2 on Arduino Nano (needs an interrupt-capable pin)
6#define FLOW_PIN 2
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_arduino_mega.inoArduino Mega
656 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin 2 on Arduino Mega (needs an interrupt-capable pin)
6#define FLOW_PIN 2
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_esp32.inoESP32
651 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin 27 on ESP32 (needs an interrupt-capable pin)
6#define FLOW_PIN 27
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_esp8266.inoESP8266
653 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin D5 on ESP8266 (needs an interrupt-capable pin)
6#define FLOW_PIN D5
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_stm32.inoSTM32
653 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin PA1 on STM32 (needs an interrupt-capable pin)
6#define FLOW_PIN PA1
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
📄 File: yf-s201_water_flow_measurement_sensor_with_1-30liter/min_flow_rate_-_black_-_raspberry_pi_pico.inoRaspberry Pi Pico
661 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Signal pin 3 on Raspberry Pi Pico (needs an interrupt-capable pin)
6#define FLOW_PIN 3
7volatile unsigned long pulseCount = 0;
8
9void countPulse() { pulseCount++; }
10
11void setup() {
12 Serial.begin(115200);
13 pinMode(FLOW_PIN, INPUT_PULLUP);
14 attachInterrupt(digitalPinToInterrupt(FLOW_PIN), countPulse, FALLING);
15}
16
17void loop() {
18 delay(1000);
19 noInterrupts();
20 unsigned long count = pulseCount;
21 pulseCount = 0;
22 interrupts();
23
24 float litersPerMin = count / 7.5; // YF-S201 datasheet: ~7.5 pulses per liter/min
25 Serial.print("Flow: "); Serial.print(litersPerMin); Serial.println(" L/min");
26}
Hall-effect water flow sensor - counts pulses proportional to flow rate.
The widely-quoted ”450 pulses per liter” figure is a commonly-used approximation, not a guaranteed-exact constant for every unit - for any application where absolute accuracy actually matters, calibrate your specific sensor against a known volume, such as timing how many pulses it takes to fill a measured 1-liter container. Pulses arrive quickly enough at real flow rates that counting them reliably in code needs a hardware interrupt (attachInterrupt) rather than polling the pin in a plain loop, or fast pulses will be missed. And install it with the flow-direction arrow molded into the housing pointing the correct way, keeping debris out of the line, since the small turbine can jam or read inaccurately if grit gets into the flow path.