Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›Water Flow Sensors (YF-S201)

Component guide · Beginner · 3 min read

Water Flow Sensors (YF-S201)

Wiring and Code

By Geekobot Learning Team · Updated 24 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWiringCode for flow rate and total litresCalibrating and fittingCommon mistakesFAQsParts and next steps
Short answer

A water flow sensor such as the YF-S201 has a small turbine with a magnet. Each turn passes a hall sensor that outputs a pulse, so the pulse rate is proportional to flow. Common datasheets give roughly 7.5 Hz per litre per minute, or about 450 pulses per litre, but each sensor differs. Count pulses with an interrupt and calibrate with a measuring jug for good accuracy.

Key specs at a glance

Supply
About 5 to 18 V; 5 V works with Arduino
Output
Open-collector pulses (pull-up needed if none on board)
YF-S201 range
About 1 to 30 L/min, G1/2 inch thread
Pulse factor
About 7.5 pulses per second per L/min (calibrate)
Wires
Red +V, black GND, yellow signal
Accuracy
Typically within ±10 % uncalibrated; better after calibration
01

Wiring

Connect red to 5 V, black to GND and yellow to an interrupt pin (D2 on an Uno). If the module has no pull-up, add a 10 kΩ pull-up to your logic voltage. For a 3.3 V board, pull up to 3.3 V instead of 5 V; the hall sensor output only pulls low, so this is safe on most versions. Check yours with a meter first.

02

Code for flow rate and total litres

Count pulses in an interrupt and convert once a second.

Litres per minute and total volume · Arduino C++Verify & upload in Electrolark
const byte PIN = 2;
const float PULSES_PER_LITRE = 450.0;   // calibrate this
volatile unsigned long pulses = 0;
float totalLitres = 0;

void onPulse() { pulses++; }

void setup() {
  Serial.begin(9600);
  pinMode(PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PIN), onPulse, FALLING);
}

void loop() {
  delay(1000);
  noInterrupts(); unsigned long n = pulses; pulses = 0; interrupts();
  float litres = n / PULSES_PER_LITRE;
  totalLitres += litres;
  Serial.print(litres * 60.0); Serial.print(" L/min, total ");
  Serial.print(totalLitres); Serial.println(" L");
}
03

Calibrating and fitting

  1. 1
    Run water through the sensor into a measuring jug and record the total pulses for, say, 2 litres.
  2. 2
    Divide pulses by litres and use that number in your code.
  3. 3
    Fit the sensor with the arrow in the flow direction and the turbine horizontal. Use PTFE tape on threads.
  4. 4
    Air bubbles, very low flow and debris all reduce accuracy; add a strainer before it.
  5. 5
    These sensors are not rated for drinking-water approval or billing. For hot water or food use, choose a sensor rated for it.
04

Common mistakes to avoid

  • !Using the datasheet pulse factor without calibrating.
  • !Fitting the sensor backwards against the arrow.
  • !Polling the pin instead of using an interrupt.
  • !Pulling the signal up to 5 V on a 3.3 V board.
  • !Using it below its minimum flow and getting no pulses.
05

Frequently asked questions

How many pulses per litre does a YF-S201 give?

About 450 in common datasheets, but calibrate yours with a jug.

Can I use it with ESP32?

Yes. Pull the signal up to 3.3 V and use any GPIO with an interrupt.

Does it work with hot water?

Standard plastic versions are rated for modest temperatures. Check the datasheet for the limit.

Why does it read zero at low flow?

The turbine needs a minimum flow to spin, about 1 L/min for the YF-S201.

Can I measure diesel or oil?

Not with a standard water sensor. Viscous or flammable fluids need a meter rated for them.

Parts for this guide

Search the store for the parts named above, or ask Geeko AI which one fits your project.

Terms in this guide

Hall effectThe small voltage produced across a conductor or sensor in a magnetic field. Hall sensors use it to detect magnets or measure current without electrical contact.InterruptA hardware signal that makes the microcontroller pause its program and run a short function immediately, for example when a button pin changes.Pull-up resistorA resistor from a signal line to the supply that keeps the line high when nothing pulls it low.Open-collectorAn output that can only pull LOW; it needs a pull-up resistor to go HIGH. Many sensor modules and the LM393 comparator work this way.CalibrationMeasuring a sensor against known conditions so its raw numbers can be converted into meaningful values, such as dry and wet readings for a soil sensor.

Projects that use it

Put this into practice: 20 step-by-step builds in our project library use parts from this guide.

Intermediate · 1–2 hoursWater flow meterView projectIntermediate · 1–2 hoursWi-Fi water usage meterView projectIntermediate · 2 hoursOne-button glass fillerView project
Browse all 20 projects

Keep learning

Component guideBeginnerHall Effect Sensors and Reed SwitchesA Hall effect sensor detects a magnetic field with no contact.3 min read · SensorsHow-toBeginnerMini Water Pumps for Arduino ProjectsA mini submersible pump is a small DC motor that pushes water when it sits underwater.3 min read · Motors & MotionComparisonBeginnerSoil Moisture SensorsResistive (YL-69) vs capacitive v1.2/v2.0 soil moisture sensors: why resistive probes corrode, Arduino and ESP32 wiring, dry and wet calibration, auto watering.3 min read · SensorsComponent guideBeginnerESP32 GuideThe ESP32 is a low-cost 3.3 V microcontroller from Espressif with built-in Wi-Fi and Bluetooth, used for IoT devices, smart-home controllers and web dashboards.5 min read · Boards & MicrocontrollersComponent guideIntermediateWaterproof Ultrasonic SensorsWaterproof ultrasonic sensors such as the JSN-SR04T and A02YYUW put the transducer in a sealed probe on a cable, so they can measure water level in a tank or work outdoors.3 min read · Sensors

Sources

  • YF-S201 hall-effect flow sensor datasheet
  • Allegro hall-effect sensor application notes

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWiringCode for flow rate and total litresCalibrating and fittingCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹187

YF-S201 Water Flow Sensor 1–30 L/min Black – Hall Effect Pulse Output

Run itChange the inputs and watch the output
Serial monitor9600 baud
6.00 L/min, total 0.10 L

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question