How to Use Water Flow Sensor - Arduino Tutorial

119,659

440

24

About: Arduino Tutorials by Codebender.cc 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

Share

    Recommendations

    • First Time Author

      First Time Author
    • PCB Contest

      PCB Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    24 Discussions

    0
    None
    Palant1r

    Question 6 weeks ago

    Hi,
    I am looking at using this type of setup to keep track on how much beer is left in pint in a cask in my local club, any tips and help with the sketch would be of great help. I will have to include a reset button for when the barrel is changed and a over-ride switch for when the pipes are cleaned.

    Thanks
    Palant1r

    0
    None
    nassersoltani

    2 months ago

    Hello my friend.

    I plan to write a program to control the pressure of water with pi3 in the
    node. I do not know how to install node.

    I wrote a program to control the brightness and temperature with the Node Red.
    This is to complete my project. .. Unfortunately, I do not have full
    proficiency in English. Also, I can not write a command to do it. Please help me

    0
    None
    MohammadA538

    5 months ago on Step 5

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

    0
    None
    gd_

    Question 5 months ago

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

    0
    None
    edca

    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
    0
    None
    Abu Bakar Saeededca

    Reply 1 year ago

    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

    0
    None
    josmeijer1Abu Bakar Saeed

    Reply 5 months ago

    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)

    0
    None
    meach51

    6 months ago on Step 5

    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!

    meach

    0
    None
    shifashifu.24

    Question 10 months ago on Introduction

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

    0
    None
    biplab15jrc

    1 year ago

    Hi,

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

    Velocity=((1000x1)/25)60=0.7cm/sec

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

    Velocity=((1000x8)/25)60=5.3cm/sec

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

    Please help me.

    Thanks

    Untitled.jpg
    0
    None
    DiegoF3

    1 year ago

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

    0
    None
    BenE19

    2 years 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?

    0
    None
    WORMSS

    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
    0
    None
    RFcontrolledSwitchWORMSS

    Reply 2 years ago

    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.

    0
    None
    DougL2

    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
    0
    None
    pollux64DougL2

    Reply 2 years ago

    Insterrupt Service Routine
    */
    void pulseCounter()
    {
    // Increment the pulse counter
    pulseCount++;
    }

    0
    None
    travlinjohn

    2 years ago

    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

    0
    None
    MehmetE14

    2 years ago

    can I use it to determine gas flow ?

    0
    None
    Wild-Bill

    2 years ago

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