Introduction: How to Use Water Flow Sensor - Arduino Tutorial

Picture of 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

Picture of What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Water flow sensor
  • 3 breadboard cables

Step 2: The Circuit

Picture of 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

Picture of 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

Comments

edca (author)2017-02-24

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.

Abu Bakar Saeed (author)edca2017-10-06

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

biplab15jrc (author)2017-08-20

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

DiegoF3 (author)2017-02-05

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

BenE19 (author)2016-11-11

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?

WORMSS (author)2016-06-06

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

DougL2 (author)2016-06-05

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.

pollux64 (author)DougL22016-06-05

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

travlinjohn (author)2016-06-05

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

MehmetE14 (author)2016-06-05

can I use it to determine gas flow ?

Wild-Bill (author)2016-06-05

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

dn'co (author)2016-06-05

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

RonS11 (author)dn'co2016-06-05

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.

ElijahH3 (author)2016-06-02

Thank you so much for this! This is what I was looking for, thank you so much for posting this instructable!

LiamOSM (author)2016-05-27

Here's a link to buy the flow sensor, from Adafruit:

https://www.adafruit.com/product/828

About This Instructable

70,886views

420favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: