How to Use Water Flow Sensor - Arduino Tutorial

220,375

468

38

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

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • "Can't Touch This" Family Contest

    "Can't Touch This" Family Contest
  • CNC Contest 2020

    CNC Contest 2020

38 Discussions

1
harshitr3
harshitr3

Question 2 months 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 8 months 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 7 months ago

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

0
ReynaldyM
ReynaldyM

Reply 5 months ago

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

have information how to fix that?

0
Damianikin
Damianikin

5 months 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
guptaragini637
guptaragini637

Question 6 months ago on Step 3

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

0
jserra85
jserra85

9 months 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 10 months ago

would it be possible to create this code in javascript ?

0
VicerExciser
VicerExciser

Answer 9 months 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 1 year ago on Introduction

How i connect digital display to aurdino and water flow senser

1
Juliopasos
Juliopasos

Question 1 year ago on Step 1

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

0
Veny_Vena
Veny_Vena

1 year 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 1 year 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
nassersoltani
nassersoltani

1 year 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
MohammadA538
MohammadA538

2 years ago on Step 5

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

0
gd_
gd_

Question 2 years ago

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

0
edca
edca

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

0
Abu Bakar Saeed
Abu Bakar Saeed

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