『Flow Meter Yf S201 Arduino Tutorial: Writing Pulse Counter Sketches for Compact Micro-Flow Projects』Related information(clamp on meter|electromagnetic meter|venturi meterrotameter|orifice meter|ultrasonic flow meter|mass flow meter|coriolis mass flow meter|coriolis flow meter|magnetic flow meter|magmeter flow meter|magflow flow meter|mag meter flow meter|electromagnetic flow meter|vortex flow meter|turbine flow meter|thermal mass flow meter|thermal flow meter|rotameter flow meter)

Flow Meter Yf S201 Arduino Tutorial: Writing Pulse Counter Sketches for Compact Micro-Flow Projects
Quick Answer: The YF-S201 is a Hall-effect turbine flow sensor with a pulse output for water from 1 to 30 L/min. Connect the yellow signal wire to Arduino digital pin 2 and count rising edges in an interrupt sketch. Flow rate in L/min equals pulse frequency in Hz divided by 7.5. The sensor suits bench tests, small water dosing loops, and compact micro-flow projects, but not custody transfer or hot chemical service.
This tutorial covers wiring, pulse counting logic, and calibration checks. Silver Instruments sells industrial flow meters for larger pipes and harsher fluids. The YF-S201 often appears in pilot rigs and compact micro-flow projects. Engineers like it because the square wave output works with simple microcontroller interrupts.
What You Need Before Wiring the YF-S201
Use a YF-S201 sensor, an Arduino Uno or Mega, three jumper wires, and a stable 5 V supply. The sensor accepts 5 to 18 VDC. The current draw is low, usually under 15 mA. The black plastic body has 1/2 inch hose barbs. The pulse factor is around 450 pulses per liter, but this value varies by batch.
Do not use this sensor with diesel, solvent, or oil unless you verify the wetted materials. The standard rotor and chamber are built for clean water. A paint manufacturer in Vietnam ran an YF-S201 on a solvent pilot line. The rotor swelled after two weeks and the pulse rate dropped by 20 percent. We replaced that loop with an oval gear flow meter for diesel.
Wiring the YF-S201 to Arduino Without Pull-Up Problems
Wire the red lead to 5 V, the black lead to GND, and the yellow signal wire to digital pin 2 on the Arduino Uno. Pin 2 is interrupt 0. Set the pin mode to INPUT_PULLUP in the sketch. The YF-S201 output is open collector NPN. Without a pull-up, the signal pin floats and the count becomes unstable.
If you power the sensor from 12 V, keep the grounds common between the sensor supply and Arduino. The signal wire still goes to digital pin 2. The logic level stays at 5 V because the pull-up is on the Arduino pin. In practice, the internal pull-up works for a wire run under 1 meter. For longer cables use a 10 kOhm external pull-up close to the Arduino. Do not feed 12 V into the Arduino signal input.
Pulse Counter Sketch Logic That Avoids Missing Pulses
Use an interrupt service routine. Store the pulse count in a volatile unsigned integer. On the rising edge of the signal, increment the count. The main loop samples the count once per second, calculates frequency, and converts frequency to flow rate.
The core logic looks like this. volatile unsigned int pulseCount = 0; void countPulse() { pulseCount++; } In setup, attach interrupt 0 to countPulse on RISING. In loop, set pulseCount to zero, wait 1000 milliseconds, then read pulseCount. Divide the count by 7.5 to get L/min for a 450 pulse per liter sensor.
Noise can cause double counting. Add a 0.1 uF capacitor from signal to GND if the wire run is short. Most engineers skip this part on a bench test. For a wire longer than 2 meters, use shielded

Flow Rate Formula and Calibration Check
The standard formula is flow rate L/min = frequency Hz / 7.5. At 7.5 Hz the flow is around 1 L/min. At 150 Hz the flow is around 20 L/min. Do not trust the printed K factor until you run a calibration check. Fill a 1 liter beaker while the Arduino counts pulses. A good sensor gives about 450 pulses. If the count is 438 or 468, change the divider factor to match the actual K factor.
For batching, count total pulses instead of frequency. Divide the total count by the K factor to get volume. This method avoids errors from a short sample window and works better for compact micro-flow dosing projects.
When a YF-S201 Is Too Small for the Job
The YF-S201 is a plastic turbine sensor. It handles clean water and low flow. It is not for hot water above 60 °C, corrosive chemicals, high pressure, or oil with viscosity above 5 cP. The flow range stops at 30 L/min. The pipe connection is 1/2 inch ID. For a DN25 industrial line, the sensor body becomes a flow restriction.
Silver Automation Instruments supplies industrial flow meters for these larger or harsher loops. For water and wastewater, a DN25 electromagnetic flow meter with 4-20 mA HART output has no moving parts and handles 0.2 to 10 m/s. An oval gear flow meter gives repeatable batch volume for chemicals and higher viscosity. Gas or steam calls for a vortex flow meter with ATEX Zone 1 certification. Send us your pressure in bar, temperature in °C, pipe size in DN, and flow range. We will recommend a meter and quote same day.
Silver Instruments Contact for Industrial Flow Meters
If the YF-S201 pulse counter is for a test rig and you later need a process meter, contact Silver Automation Instruments. We are a flow meter manufacturer and supplier for water, oil, gas, chemical, and food plants. Call Tel: +86-25-68650347. Message WhatsApp: +86-25-52155837 or WeChat: +86 15365082610. Our engineers reply with model numbers and price.
We serve industrial end users and distributors in Southeast Asia, Oceania, Latin America, Africa, and the Middle East. You can check the full range at flow-meter.com.au.
FAQ
What is the YF-S201 pulse output? The sensor outputs a square wave. Pulse frequency is about 7.5 Hz per L/min. The signal is open collector NPN and needs a pull-up resistor.
Can the YF-S201 measure diesel or oil? The standard version is for water. Diesel or solvent can swell the rotor and cause a low reading. Use an oval gear flow meter for those fluids.
How do I convert pulses to flow rate on Arduino? Count pulses in one second. Divide the count by 7.5 for L/min. The constant changes if your K factor is not 450 pulses per liter.
Why does my YF-S201 give unstable readings? The pull-up is often missing. Enable INPUT_PULLUP or add a 10 kOhm resistor from signal to 5 V. Also check the rotor for debris.
What is a better industrial replacement for a YF-S201? For DN15 and DN25 water lines, use an electromagnetic flow meter. It has no rotor, no pressure drop, and works with dirty water.

Hot Blog
Related AD
