Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

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.

GPIO

Community draft — report a mistake

CategorySensor
InterfaceGPIO
Voltage5–18 V (use 5 V)
Typical price₹250

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

PinWhat it does
VCCRed wire — 5 V supply (about 15 mA)
GNDBlack wire — ground, shared with the board
SIGYellow 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.

↑↓ to move · Enter to open