Article covers measuring water flow rate using flowmeter & Arduino.
Disclaimer
1. This step-by-step how-to covers lab setup and not the field setup or test.
2. This how-to does not cover the calibration of flow meter.
3. This does not cover the working principles of flow meter.
Working sample
Before we proceed further, let us take a look at what our end result would look like.
Items Needed
- Arduino Uno
- Hall effect flow meter sensor.
Pre-requisites
This post assumes you already have,
Arduino Editor installed on your laptop.
Your laptop connected to Arduino using the USB cable.
Basic familiarity with Arduino programming using C++
Technical details
How flow meter works?
This post does not go into details of how flow meter works. There are numerous materials available on the internet.
One such example: https://www.seeedstudio.com/blog/2020/05/11/how-to-use-water-flow-sensor-with-arduino/
Schematic & Wiring diagrams
This is how the final setup looks like:
How-to steps
Step 1: Connecting Arduino to flow meter
Water flow sensors normally have three leads. +ve, -ve and interrupt.
Interrupt output from flow meter sensor send a certain amount of HIGH signals depending on the flow rate, and it needs to be connected to Arduino's interrupt pins.
Arduino Uno has two interrupt pins, pin #2 and pin #3. These pins are referenced as 0 and 1 in the c++ code, which you can see in the sample code below.
Arduino Uno | Flow meter | Remarks | Wire color |
5 V | DC + | 5 V | red |
GND | DC - | 5 V ground | black |
9 | signal | Number of signal outputs vary depending on the water flow rate | Yellow |
Step 2: Flow meter sensor
Flow rate is measured based on the specification you can see on the flow meter.
In the above diagram, you may notice,
F=(7.5 * Q), Q=L/Min.
F - Frequency
Q - Flow rate
Using above spec,
Q (flow rate) = F / 7.5 liters per minute
Step 3: Arduino C++ I2C code
There are no new libraries to be downloaded. Code is straight forward.
~~~~~~~~ C++ Code
Step 4: Testing the flow meter
Now the setup should be ready. When the C++ code runs,
1. Interrupts are activated for 1 second through "delay(1000)" command in the code.
2. When there is an interrupt signal in Arduino's pin #2, the funtion 'calculateNumberOfPulsees()' gets called, which increments the counter variable by 1.
3. After 1 second, the interrupt is stopped, and we proceed to calculate the flow rate.
4. After calculating the flow rate, the counter is reset to 0.
Refer accompanying video to see a demo of this. Instead of water, I've used the air flow through the meter to activate the flowmeter.
Closing note
Hope this post gives you the basic details of measuring flow rate using hall effect flowmeter and Arduino.
Thanks,
(3) Music by QubeSounds @ pixabay
Comments