How to Use Water Flow Sensor - Arduino Tutorial

250,064

482

43

Introduction: How to Use Water Flow Sensor - Arduino Tutorial

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

2 People Made This Project!

Recommendations

  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • Toys & Games Contest

    Toys & Games Contest
  • Home Decor Challenge

    Home Decor Challenge

43 Comments

0
Lochiengs
Lochiengs

Question 12 days ago on Step 2

Where is the circuit diagram?

0
egamerz231
egamerz231

6 months ago

Anybody can help me. I try to combine this code with other sensors code. And it all end up sayin that the pulseCounter are not declare

0
DJ600
DJ600

Reply 5 months ago

You probably missed the last lines of code where the function is defined.

0
teckmarine1
teckmarine1

Question 9 months ago

Hi, how did you calculate the 4.5 for the calibration factor? I have purchased a slightly different sensor (as it better fitted the requirements for my project) but it's showing me moving thousands of litres? I can use a measured amount (I.E. fill a 2L water bottle and count the pulses) but this seamed a little mad? Any help would be massivly appricated!

0
guptaragini637
guptaragini637

Question 1 year ago on Step 3

This code are not give the output for nodemcu .What is the reason ?

0
teckmarine1
teckmarine1

Answer 9 months ago

It's taken me a couple of weeks to rebuild this so it works with a Node MCU, but in basic you need to look into how NodeMCUs process interupts, as they are a little different to the arduino, Hopefully I will upload the code once the projects done

1
harshitr3
harshitr3

Question 1 year ago

I have a project to be made i.e. water Billing System using RFID(Mfrc522) on Arduino NANO. There is one difficulty that I haven't been able to overcome. I hope someone could help me out.
Project flow:
  1. water or any liquid flows through the sensor and quantity of water gets recorded
  2. now according to quantity of water flown there is price decided
  3. this price needs to be deducted by swiping rfid card
  4. ISSUE:
  5. i haven't been able to control interrupts
  6. my program calculates the water flown
  7. REQUIRED:
  8. edit code such that it as soon as water flows through it, it calculates and ask the user to swipe the card, and as user swipes an amount deducted and process continues.
https://arduino.stackexchange.com/questions/75761/arduino-project-interrupt-error
Check out above link

PLEASE PLEASE HELP ME
0
mzsolnay
mzsolnay

Question 1 year ago on Step 3

I was stuggeling for quite a time to get my flow sensor working. Tried several tutorials and sample code's I found online, this one was the most promising, and most well detailed and explained. Nevertheless it did not worked, values vere keep showing as "0", nothing happened. Until I tried to changed this line:
"byte sensorInterrupt = 0; // 0 = digital pin 2"
to this:
"byte sensorInterrupt = 2; // 0 = digital pin 2"
Now, numbers are coming, it seems to work. I still don't understand why (*), and I am still not sure if the values are correct, but this I'll be able to check via mesurement (pour some liters thru the sensor and see, what happens)

Was there an error in the sample code?

Thanks again for the good tutorial I learned a lot from it !

0
GutoSCS
GutoSCS

Answer 1 year ago

I did the same but it still not working though. Value never change from zero....

0
ReynaldyM
ReynaldyM

Reply 1 year ago

its not working aswell to me, the value still same = 0

have information how to fix that?

0
Damianikin
Damianikin

1 year ago

Hi
Can this be used as a simple switch to turn on an extractor fan without having to use code and a board?
Thanks Damian

0
jserra85
jserra85

1 year ago

The code in this tutorial may be confusing for some. The signal pin from your flow meter should be assigned to the pin you define for sensorInterrupt on line 12 of the sample code. I was setting my 'signal pin' and defining the variable on line 13.

0
shimza99
shimza99

Question 1 year ago

would it be possible to create this code in javascript ?

0
VicerExciser
VicerExciser

Answer 1 year ago

Running Javascript directly on an Arduino? No. But you could look into a library like "Johnny-Five" which does allow you to run an application written in Javascript on your computer and have it issue run-time instructions to an Arduino over a USB connection. Probably not what you're looking for.

0
olitesbeam
olitesbeam

Question 1 year ago

This is to help me with my school project. I will appreciate any tutorial

3
olitesbeam
olitesbeam

Question 1 year ago

Hello, please how do i code two flowsensors so that i can initialize a condition that if the flow rate is different i can know for leakage detection

2
YousafK4
YousafK4

Question 2 years ago on Introduction

How i connect digital display to aurdino and water flow senser

1
Juliopasos
Juliopasos

Question 2 years ago on Step 1

Great project. How can I connect 4 sensors to the same Arduino?

0
Veny_Vena
Veny_Vena

2 years ago

Hello,
Thanks for the knowledge shared. Well am curious about something concerning the flow rate sensor. I have studied it working principle and in brief the measurement starts when the propeller in it rotates by the passage of liquid. The question is what if there is air flowing and it is strong enough to make it rotate i hope the magnetic field will be generated and the same information as if liquid is passing will be sent to the hall effect sensor and proceed with the measurements. How is the flow rate sensor counter balancing that effect?...thank you in advance i hope to hear from you soon .
venancekafwenji95@gmail.com

0
Palant1r
Palant1r

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