How to Use Water Flow Sensor - Arduino Tutorial





Introduction: How to Use Water Flow Sensor - Arduino Tutorial

About: Arduino Tutorials by Team

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



    • Clocks Contest

      Clocks Contest
    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    22 Discussions

    Can i use this sensor as a gas flow measuring??


    Question 15 days ago

    How can I speed up the rate the data is showing up? Would changing the baud rate to 9600 be ok?


    1 year ago

    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.

    2 replies

    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 rather think that the flow sensor you use is different from the one in the tutorial. Apparently it delivers 9 pulses per litre instead of the 4.5 from the example so I would change

    float calibrationFactor = 4.5; to

    float calibrationFactor = 9;

    But I am still a complete noob on Arduino programming

    (just logical thinking)

    Thank you for taking the time to write this up. As a physicist, I undertand Hall Effect, but the application and sample code for arduino really speeds things up!
    FYI I am building a very complex project that involves boiling liquid, cooling flow, pumps and ethanol output ;) It is taking some time, which I have. People like you make the whole hobby so much more worthwhile, thanks again!


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


    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...


    1 year ago

    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?


    2 years ago

    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.

    2 replies

    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.


    2 years ago

    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.

    1 reply

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

    Click on the Edit button then scroll down to the bottom of the code, highlight "117" and press enter. The editor adds lines to the instructable

    can I use it to determine gas flow ?

    Thanks. I have been thinking of automating the water measuring and temperature control in mashing/sparging process in my beer making.


    2 years ago

    Isn't there a serious pressure limitation on these flow sensor ? Something like 1 or 1.5bar max while the "city" pressure is 3 bar. Hence limiting this flow sensor to specific closed circuit without pressure changes. I dont know of a cheap flow sensor that supports higher pressure.

    Anyway, thanks for this tutorial

    1 reply

    No, The limitation is on the pressure difference from one side to the other not the total pressure available. Working fine on garden hose at 60 PSI.