『Flow Meter for Arduino Projects: Writing Code for YF-S201 Water Pulse Counter Sensors』Related information(v cone flow meter|rotary gas meter|gallon meter|gear meter|metal tube rotameter|glass tube rotameter|nutating disk meter|transit time ultrasonic flow meter|wedge flow meter|pd meters|hydraulic flow meter|ultrasonic water flow meter|water flow meter|air flow meter|magnetic water flow meter|oxygen flow meter|gas flow meter|argon flow meter|air velocity meter|gasoline flow meter|fuel flow meter|ultrasonic water meter|digital water meter|nitrogen flow meter|solid flow meter|Oxygen tank flow meter|digital water flow meter|diesel fuel flow meter|steam flow meter|02 flow meter|compressed air flow meter|oil flow meter|liquid flow meter)

Flow Meter for Arduino Projects: Writing Code for YF-S201 Water Pulse Counter Sensors
Quick Answer: The YF-S201 is a low cost pulse output water flow meter for Arduino projects. You read the pulse train with an interrupt pin and convert the frequency to flow rate in liters per minute. For industrial pipes, custody transfer, or aggressive fluids, use a Silver Instruments electromagnetic or vortex flow meter.
How the YF-S201 Sensor Generates a Pulse Signal
The YF-S201 water pulse counter sensor has a small rotor with a magnet. Water passes through the body and spins the rotor. A Hall effect sensor detects each rotation and outputs a square wave pulse. The nominal K factor is 7.5 Hz per liter per minute. That equals 450 pulses per liter. The rated flow range is 1 to 30 liters per minute. Working voltage is 5 to 18 volts DC. Maximum working pressure is 1.75 MPa. Use clean water only.
In practice, the K factor is not fixed. Each unit can drift by 10 percent. Mounting position and air bubbles change the result. We have seen this on customer sites many times. A small air pocket in the rotor chamber can shift the reading by 15 percent. That is not acceptable for a water bill or a chemical dose.
Arduino Wiring and Code Logic
Use three wires. Red goes to 5 volts DC or 12 volts DC. Black goes to ground. Yellow is the pulse output. Connect yellow to digital pin 2. Add a 10 kilohm pull-up resistor from yellow to 5 volts if your board does not have an internal pull-up. In code, set pin 2 as INPUT_PULLUP. Use an interrupt on RISING. Count pulses for one second. Convert the frequency to flow rate with this formula: flow rate in liters per minute equals pulse frequency divided by 7.5. For better stability at low flow, use a two second window.
Here is a short Arduino sketch.
volatile unsigned int pulseCount;
unsigned long lastTime;
void pulseCounter() {
pulseCount++;
}
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), pulseCounter, RISING);
lastTime = millis();
}
void loop() {
if (millis() - lastTime >= 1000) {
float frequency = pulseCount;
float flowRate = frequency / 7.5;
float volume = pulseCount / 450.0;
pulseCount = 0;
lastTime = millis();
Serial.print(flowRate);
Serial.println();
}
}
Do not use long delay functions. They block the pulse count and cause missed edges. Most engineers skip this part and then wonder why the total volume drifts.
Calibration and Common Sources of Error
Here is the thing. The YF-S201 is a plastic sensor. It is not a calibrated flow meter. The K factor has a tolerance. Low flow below 1 liter per minute gives unstable pulses. High flow above 30 liters per minute creates pressure drop and rotor wear. Water temperature above 80 degrees Celsius can soften the rotor. Air bubble

For better accuracy, run a bucket test. Collect a known volume of water. Compare the pulse count to that volume. Adjust the K factor in your code. Use a stopwatch and a weighing scale. A customer in Vietnam tested a YF-S201 on a cooling water skid last year. The unit showed a 12 percent error at 2 liters per minute. After a K factor correction, the error dropped to 4 percent. That was fine for a local display. It was not fine for billing.
When to Use an Industrial Flow Meter Instead
The YF-S201 fits training boards, garden irrigation, small cooling loops, and proof of concept projects. It does not fit hot water, corrosive fluids, food grade lines, ATEX Zone 1 areas, or custody transfer. If you need a 4-20 mA HART output, a local totalizer, or a DN15 to DN300 meter for a water treatment plant, select an industrial flow meter from Silver Automation Instruments. We supply electromagnetic flow meters, ultrasonic flow meters, vortex flow meters, and Coriolis mass flow meters. For a water utility in the Philippines, we supplied an electromagnetic flow meter with 4-20 mA HART and internal totalizer. The customer used it for raw water intake from a river.
Send us your pressure (bar), temperature (°C), pipe size (DN), and flow range. Tell us the fluid type and required accuracy. We will recommend a meter with the right liner, electrode, and output. Contact Silver Automation Instruments. Tel: +86-25-68650347. WhatsApp: +86-25-52155837. WeChat: +86 15365082610. You can also find product details on flow-meter.com.au.
FAQ: YF-S201 Pulse Sensor and Industrial Flow Meters
Can the YF-S201 measure flow below 1 liter per minute? No. The rotor stops or the pulse train becomes irregular below the minimum rated flow. Use a smaller pulse wheel meter or an industrial electromagnetic flow meter for low flow.
What is the K factor of the YF-S201? The nominal K factor is 7.5 Hz per liter per minute. That equals 450 pulses per liter. Check each unit because the actual K factor can shift by 10 percent.
Can I connect the YF-S201 directly to a PLC? Yes, if the PLC has a high speed counter input. Power the sensor with 5 to 18 volts DC. Check the signal voltage and add a pull-up resistor if needed. For a standard 4-20 mA analog input, use an industrial flow meter.
Is the YF-S201 suitable for hot water or chemicals? No. The body and rotor are made for clean cold water. For hot water or chemicals, use an electromagnetic or vortex flow meter with a suitable liner and electrode material.
How do I reduce false counts in Arduino code? Use an internal pull-up resistor, add a 100 nF ceramic capacitor across the signal wire, and keep the sensor cable short. A software debounce delay also helps. For long cable runs, use an industrial pulse output meter with stronger signal conditioning.

Current position > Product detail