Kunkune

YF-S201 Water Flow Sensor: How to Measure Flow Rate

YF-S201 Water Flow Sensor: How to Measure Flow Rate

By Kunkune | Published: 2026-10-21

Category: How-to Guides

Learn how to set up the YF-S201 Hall effect water flow sensor with Arduino to measure flow rate from 0 to 30 L/min. Step-by-step wiring, code, and calibration tips.

Quick answer

To measure water flow rate with the YF-S201, connect its three wires to 5V, GND, and a digital pin on an Arduino, then read the pulse output and convert it to liters per minute using the sensor's calibration factor.

Why the YF-S201 works for flow measurement

The YF-S201 is a Hall effect flowmeter that outputs a digital pulse each time a rotor turns inside the sensor body. The pulse frequency is proportional to the flow rate, making it straightforward to read with any microcontroller that can count interrupts. It works with DC 5-18V, so it pairs well with Arduino's 5V supply.

One trade-off: the sensor is rated for clean water only. Particles or debris can jam the rotor, so always use a pre-filter if your water source isn't clear. Also, the factory calibration factor (usually around 7.5 pulses per liter) is approximate; for best accuracy, you should calibrate it by measuring a known volume of water.

How to measure flow rate with the YF-S201

  1. Wire the sensor to Arduino: Connect the YF-S201 red wire to Arduino 5V, black wire to GND, and yellow wire to digital pin 2 (or any pin that supports interrupts). The sensor draws about 15 mA, so the Arduino's 5V pin can power it directly. Common mistake: using a pin that doesn't support interrupts on your board. On Arduino Uno, only pins 2 and 3 work with attachInterrupt().
  2. Upload the pulse-counting sketch: Open the Arduino IDE and write a sketch that attaches an interrupt to the sensor pin. In the interrupt service routine, increment a volatile counter variable. In the loop(), calculate flow rate in L/min by dividing the pulse count over a fixed interval (e.g., 1 second) by the sensor's calibration factor (typically 7.5 pulses per liter). Checkpoint: Use the 'volatile' keyword for the counter variable, or the compiler may optimize it away, causing erratic readings.
  3. Calibrate for accurate readings: Run a known volume of water through the sensor (e.g., 1 liter) and count the total pulses. Divide the pulse count by the volume to get your actual calibration factor. Update the factor in your sketch. For the YF-S201, the factor usually falls between 6.5 and 8.5 pulses per liter. Common mistake: assuming the factory factor is exact. Calibration can improve accuracy by 10-20%.
  4. Test and interpret the output: Open the Serial Monitor (9600 baud) and run water through the sensor. You should see the flow rate update every second. Compare the reading to a known flow (e.g., from a measuring cup and stopwatch) to verify calibration. If you see no pulses, check wiring polarity. The sensor is polarity-sensitive: reversing 5V and GND can damage it.

Product used in this guide

  • 0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201: 0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201 Its 0-30 L/min range covers typical household flow rates, and the Hall effect output works directly with Arduino digital pins without extra components.
    0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201
    0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201

Shop Related Products

0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201

0-30L/pm Water Flow Sensor DC 5-18V Flowmeter Hall Effect Module YF-S201

$7.62 $11.90

Shop Now