Interfacing of Water Flow Sensor (YF-S201) Module with Arduino
Water Flow Sensor (YF-S201) Module
The YF-S201 water flow sensor allows Arduino projects to measure the rate of water flow through a pipe. It’s a compact, low-cost device ideal for water usage monitoring, automation, and conservation applications.
Working Principle of Water Flow Sensor
The YF-S201 sensor contains a rotor and a Hall Effect sensor. When water flows through the sensor, the rotor spins, generating pulses. These pulses are proportional to the flow rate. Arduino reads the pulse frequency and converts it into liters per minute.
Features of YF-S201 Sensor
Pulse Output
- Water passes through the sensor body.
- Rotor spins and interrupts the magnetic field.
- Hall effect sensor produces pulse output proportional to flow rate.
Non-Invasive Measurement
- Sensor connects inline with water piping.
- Only mechanical parts inside are rotor and shaft.
- Electrical part (Hall sensor) is isolated from water.
Requirements
1. Arduino Board
2. YF-S201 Water Flow Sensor
3. Jumper wires
4. Breadboard (optional)
Pin Configuration of YF-S201 Sensor
YF-S201 Water Flow Sensor
- VCC: Connect to 5V on Arduino.
- GND: Connect to Arduino GND.
- OUT: Connect to any digital input pin (e.g., D2).
Wiring the Water Flow Sensor to Arduino
Connect the sensor's VCC to the Arduino’s 5V pin, GND to GND, and OUT to a digital pin like D2. You may use an interrupt on this pin to accurately count pulses, especially for precise flow rate calculations.
Algorithm
Initialize Sensor and Variables
- Define the input pin for pulse reading.
- Set up interrupt service routine for counting pulses.
- Initialize serial monitor for output.
Calculate Flow Rate
- Use the pulse count in a fixed time interval.
- Apply calibration factor (e.g., 7.5 for YF-S201).
- Convert to liters per minute or milliliters per second.
Display Output
- Print flow rate and total volume on serial monitor.
- Use LCD or OLED for physical display (optional).
- Store data if long-term tracking is needed.
Test and Calibrate
- Run water through the sensor at known volume.
- Compare actual vs measured flow.
- Adjust calibration constant as needed.
Applications of YF-S201 Water Flow Sensor
- Water dispensing systems
- Irrigation control systems
- Home water usage monitoring
- Leak detection setups
- Smart aquariums and hydroponics
- Industrial fluid monitoring
Conclusion
The YF-S201 water flow sensor is a practical and affordable way to add water monitoring features to your Arduino project. With proper calibration and setup, it provides reliable real-time flow data for various automation and conservation systems.