Water Flow Sensor YF-S201 Arduino Interface

It is Very simple to Measure the water or liquid flow by using water flow sensor YF-S201 with Arduino, this Article describes about the water flow sensor and How the water flow sensor works then how to interface water flow sensor with Arduino.

To take control on volume we need to measure, water is essential to every thing, here this article helps you to built water flow meter to measure the volume of water flow through pipelines.

How water flow Sensor Works

This illustration gives detailed working method of hall effect sensor based water flow sensor, a turbine wheel embed with magnet is placed on a closed plastic envelop and a Hall effect sensor placed, When the water flows through the pipeline, it makes the turbine wheel to rotate and hence the magnet flux interferes the hall sensor, the rate of interference is depends on the speed of water flow, so the hall effect sensor produce pulse signal output, this pulse output can be calculated as water volume.

YF-S201 water flow sensor

This water flow sensor has only three wires and it can be easily interfaced between any microcontroller and Arduino board. It requires only +5V Vcc and gives pulse output, the sensor needs to be tightly fitted between water pipeline.

Arduino Hookup

Connect the +5V wire to Arduino power pin 5V and Ground pin to Gnd then connect Signal pin to Digital pin D2, this sensor has control circuit hence there is no need for pull up resistor, some sensor requires pull up resistors refer datasheet of water flow sensor before concluding hookup.

Arduino Code for water flow meter


Arduino Water flow meter
YF- S201 Hall Effect Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int l_hour; // Calculated litres/hour
unsigned char flowsensor = 2; // Sensor Input
unsigned long currentTime;
unsigned long cloopTime;
void flow () // Interrupt function
void setup()
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   attachInterrupt(0, flow, RISING); // Setup Interrupt
   sei(); // Enable interrupts
   currentTime = millis();
   cloopTime = currentTime;
void loop ()
   currentTime = millis();
   // Every second, calculate and print litres/hour
   if(currentTime >= (cloopTime + 1000))
      cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
      flow_frequency = 0; // Reset Counter
      Serial.print(l_hour, DEC); // Print litres/hour
      Serial.println(" L/hour");


  1. ronald mhlanga February 5, 2018 Reply
    • Ribeiro T. June 1, 2019 Reply
  2. Rick February 13, 2018 Reply
  3. Muhammad Abdullah April 27, 2018 Reply
    • adminAuthor April 27, 2018 Reply
  4. Hassaan July 15, 2018 Reply
    • Renan October 31, 2018 Reply
  5. Math July 30, 2018 Reply
  6. Anusron August 18, 2018 Reply
  7. Mugheera Saleem December 10, 2018 Reply
  8. Mario December 29, 2018 Reply
    • Ribeiro T. June 1, 2019 Reply
  9. Muhammad Misbah January 27, 2019 Reply
  10. N March 9, 2019 Reply
  11. eng ahmed jameel March 9, 2019 Reply
  12. ojo April 7, 2019 Reply
  13. Walter Segovia May 20, 2019 Reply
  14. subhash October 12, 2019 Reply
  15. Stephen Coulson February 6, 2020 Reply
    • Stephen Coulson February 6, 2020 Reply
  16. Mitch August 21, 2021 Reply
  17. VR June 1, 2022 Reply

Add a Comment

Your email address will not be published. Required fields are marked *