YF-S201 water flow sensor (½″)
YF-S201 Hall-effect flow sensor wiring (red, black, yellow), the 7.5 × L/min pulse formula, counting with an interrupt, 3.3 V boards and calibrating it.
Community draft — report a mistake
3.3 V or 5 V? Powered from 5 V, the pulse output can swing close to 5 V. On ESP32 and Pico feed SIG through a 10 kΩ / 20 kΩ divider (or a 1 kΩ / 2 kΩ one). On Uno connect it directly.
Inside the plastic body is a small turbine with a magnet; a Hall sensor outputs one pulse every time the magnet passes. Count pulses per second and convert: flow (L/min) = pulse frequency (Hz) ÷ 7.5, which works out to about 450 pulses per litre. It handles about 1–30 L/min on ½″ pipe.
Count pulses with an interrupt (attachInterrupt(digitalPinToInterrupt(pin), count, FALLING)), then once a second read and reset the counter. Polling with digitalRead() misses pulses at high flow.
It’s used for water-consumption meters, borewell and overhead-tank fill monitors, and “dry run” protection that switches a pump off when no water is flowing. Expect ±10 % accuracy out of the box; calibrate with a bucket for anything better. The sensor isn’t food-grade certified, and sand or debris will jam the rotor — fit a mesh filter upstream.
Prices are indicative (Nov 2026) and vary by seller.
Pinout
| Pin | What it does |
|---|---|
VCC | Red wire — 5 V supply (about 15 mA) |
GND | Black wire — ground, shared with the board |
SIG | Yellow wire — pulse output from the Hall sensor, one pulse per rotor magnet pass |
Use it with
Common errors
Flow reads zero even with water running
Below about 1 L/min the rotor doesn’t spin. Also check the arrow on the body points with the flow, and that SIG is on an interrupt-capable pin with attachInterrupt().
Total litres are 10–20 % off
The 450 pulses-per-litre figure is nominal. Fill a 10 L bucket, count the pulses, and use your own pulses-per-litre number.
Counts jump when the pump or relay switches
Noise on a long cable. Use shielded cable, add a 10 kΩ pull-up and a 10 nF capacitor from SIG to GND at the board, and ignore pulses closer than 1 ms apart.