Parts

Water flow sensor, YF-S201

Hall-effect water flow sensors: a pinwheel in a pipe pulses SIG as the water turns it, 7.5 pulses a second per liter a minute on the YF-S201.

This part has a page of its own, with a note on using it and a circuit to try: the part page.

A pipe section with a magnet on a pinwheel and a Hall sensor outside it, and three wires. The default is the black YF-S201 (G1/2); the model setting also offers the small YF-S401 (1/8 inch), the brass one inch YF-B10 and the two inch YF-DN50. Aliases: YF-S201, YF-S401, YF-B10, YF-DN50, Hall flow meter, water flow meter.

Water through the pipe turns the wheel, and each turn passes the magnet by the Hall sensor, which pulls SIG low and lets it go: a square wave whose frequency is the flow. The sketch counts the pulses on an interrupt and divides.

Pins

Pin What it does
VCC Supply, the red wire: 5 V to 18 V on a YF-S201, 5 V to 12 V on a YF-S401, 3.5 V to 24 V on a YF-B10 or YF-DN50.
GND Ground, the black wire.
SIG The pulses, the yellow wire.

Properties

model is which sensor it is: YF-S201 (the default), YF-S401, YF-B10 or YF-DN50.

flow is the flow it starts with, in liters a minute, from 0 to the model's top: 30, 6, 50 or 200.

While it runs

The slider is the flow through the pipe, and the wheel in the window turns with it. Its scale follows the model.

What the model gets right

From the spec sheets and listings, which are all the paperwork there is:

Model Pipe Formula (F in Hz, Q in L/min) Pulses a liter Range
YF-S201 G1/2 F = 7.5 x Q 450 1 to 30 L/min
YF-S401 1/8 inch F = 98 x Q 5880 0.3 to 6 L/min
YF-B10 G1, brass F = 8 x Q - 4 about 476 2 to 50 L/min
YF-DN50 G2 F = 0.2 x Q 12 10 to 200 L/min

The YF-S401's figures are DFRobot's (SEN0216). The YF-B10's are the SEA listing's and most sellers'; an older one-page sheet gives 6 x Q - 8, so calibrate a real one. Under 0.5 L/min its formula gives no pulses, and neither does the model.

The output. High over 4.5 V and low under 0.5 V on 5 V, 50% duty: an open collector with a pull-up inside, here 10 kohm to VCC (an assumption). A sketch's own INPUT_PULLUP changes nothing.

What it does not model

A real sensor's accuracy, 3 to 10% (the model's pulses are exact, so calibrate a real one with a measuring jug); the low flow at which a real wheel stops turning; the water pressure; and a wheel that spins on for a moment after the tap closes.

Common mistakes

Powering it from 12 V with SIG straight into a 5 V board: the pull-up inside goes to VCC, so the pulses then reach 12 V. Run it from 5 V.

Counting pulses in loop() with digitalRead(). At 30 L/min a YF-S201 makes 225 pulses a second, and a YF-S401 at 6 L/min 588; use attachInterrupt().

Dividing by 7.5 for every model. Each one has its own factor; a YF-DN50 makes only 12 pulses a liter, so count over a few seconds.

See it in action

Water meter shows the flow and the liters so far on an I2C LCD. Open it at /templates. The tutorial Arduino water flow sensor walks through it.