How to Use Water Flow Sensor - Arduino Tutorial





Introduction: How to Use Water Flow Sensor - Arduino Tutorial

In this tutorial you will learn how to use one water flow sensor with an Arduino board.

The water flow sensor consists of a plastic valve body, a water rotor and a hall-effect sensor. When the water flows through the rotor, rotor rolls and the speed of it changes with a different rate of flow. The hall-effect sensor outputs the corresponding pulse signal.

This type of sensor can be found on different diameters, water pressure (MPa) and flow rate (L/m) ranges. Make sure to select one that will cover your needs. The sensor that I have it has 20mm diameter, <1.75Mpa water pressure and ~30 L/m flow rate range.

In this tutorial we will use the serial monitor for printing the water flow rate in liters per hour and the total of liters flowed since starting.

So let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Water flow sensor
  • 3 breadboard cables

Step 2: The Circuit

The connections are pretty easy, see the above image with the breadboard circuit schematic.

Step 3: The Code

Here's the code, embedded using Codebender!

Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino with this sketch!

You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code. For example you can change in the line 58 the "1000" ms delay time.

Step 4: Serial Monitor

Press the connect button below to start the serial communication.

Connect your sensor with your water tap, or just blow on it.

Note: The back side of the sensor show with one arrow the correct flow side.

Step 5: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use the water flow sensor.

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!

Find more useful Arduino Tutorials here



    • Epilog Challenge 9

      Epilog Challenge 9
    • Paper Contest 2018

      Paper Contest 2018
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.



    How can find the leak in the area between two sensors?? What changes should me made with the code???



    I used this codes but it doesn't work accurately. I tested 1 liter of water to the sensor but the output became 2 Liters. What should I do? Thanks.

    You have to replaced 1000 by 800 to get accurate value, for more accuracy think there must be more little up and down required in 800 value


    I am very new with Arduino and also hobbyist, so i cant improvise codes.

    I need to calculate velocity (cm/sec) of the water passing through a squire box, (5cm). (I attached a diagram.)

    As we know 1cm cube area holds 1ml water; so box with WxHxL 5x5x1=25cm cube area hold 25ml water.

    So calculation will be Velocity=((1000ml x Flow rate L/min)/25)/60=Velocity cm/sec.

    Example: If water flowing 1 Lt/min ....then...


    If water flowing 8 Lt/min ....then...


    I need to include this calculation instead of Total volume (TotalMilliLiters),

    Please help me.



    Should I make any change in the code, other than the pin number, to use on pins 5 or 6? I can't make it work...

    I'm looking for something similar that can determine the water either going into or out of the hot water heater. Does this sensor have the proper diameter and will it impede the pressure of the water? Also can it work on the hot side of the water line?

    What does the `frac` variable on line 85 supposed to do? I think I am being a derp and not following the code correctly.. Any help?

    Also, nice little tutorial, I will try and find one that can easily fit a UK garden hose attachment to. I don't actually NEED it for my project, but I can use it as a confirmation that when I turn the valve on, it actually IS going on. May flash up some red LED's if things are not flowing as expected.. Thank you for the idea.

    frac doesn't appear anywhere in the sketch other than the declaration as an unsigned int so it must be some left over code from testing etc.

    Thank you, I thought it was me not understanding it..

    nice project but with that plugin to show the code there is an advertisement at the bottom blocking that last bit of code from view. Maybe add a dozen or so CR lines to the bottom of the sketch so we can read it as posted.

    Insterrupt Service Routine
    void pulseCounter()
    // Increment the pulse counter