Real-Time Water Flow Meter Using Arduino and Raspberry Pi

↑ Click on the above “IEEE China” to subscribe for free
WeChat public account has been fully upgraded!

A new commenting feature for WeChat articles has been added, and everyone is welcome to participate in comments. Every day, one lucky fan will be drawn from the previous day’s commenters to receive a 10 yuan McDonald’s electronic coupon. Join in quickly!

Real-Time Water Flow Meter Using Arduino and Raspberry Pi

Real-Time Water Flow Meter Using Arduino and Raspberry Pi

Real-Time Water Flow Meter Using Arduino and Raspberry Pi

Author: David Schneider

California is currently experiencing a severe drought. Everyone is eager to respond to the water-saving initiative, but it’s not easy to implement since water usage is billed monthly, causing a delay in information. Of course, one can also check and record the water meter readings regularly to track usage more frequently. But who will be so conscientious to follow through? So I created a water meter that can display household water usage in real-time. The system I made does not require plumbing modifications; it transmits data through the home wireless network, allowing readings to be viewed from any internet device in the house. Now, if my teenage kids waste water while showering, I can monitor the usage and give them a lesson!

To measure the flow of municipal water supply, I installed a digital compass, which is a dual-axis magnetometer that I bought from SparkFun Electronics for use as a compass. Now SparkFun no longer sells this device, but you can buy a tri-axis magnetometer at a lower price (15 dollars), and I think its actual performance might be similar or even better.

Considering how mechanical water meters work, the role of the magnetometer is irreplaceable. To isolate the gears inside the meter from the water environment, the rotor is usually connected to a magnet, which is housed in a separate box through which the water flows. As the water flow drives the rotor to turn, the magnet connected to the rotor will turn and drive another magnet inside the meter. This way, the two magnets will create a magnetic field around the meter, and the strength of the magnetic field depends on the speed of the water flow.

At first, I thought the magnetic field generated by the magnet coupling mechanism would produce a strong signal outside the meter, but this magnetic signal was actually quite weak. There could be several reasons for this: the metal casing outside the meter isolates the magnetic field inside; the moving components inside the meter may contain various metal parts, which would produce higher frequency pseudo magnetic fields. At least, that’s what I could think of. In short, the final signal effect was poor.

Therefore, my first challenge was to program the Arduino on the magnetometer to convert the noisy magnetic signal into a flow rate signal. I initially considered selecting the dominant frequency corresponding to the flow rate through Fourier transform, but ultimately chose auto-correction. That is, the program multiplies a short sample of the signal with a delayed sample to get the result. To find the dominant frequency, the Arduino code increases the time interval between the two samples and looks for peaks in the final effect. This method requires less programming and is more sensitive to noise and harmonics.

Testing on the garden hose showed that this method can distinguish variations in water flow. The lower limit of measurement depends on the time the Arduino collects data before processing. I set it to 3 seconds, which can almost be precise to every drop of water. However, when the flow rate is very high (at that time I was using an outdoor faucet without a hose), my system encountered problems.

You might think that measuring the signal generated by fast water flow is easier than measuring low-speed flow, but that’s not the case. When the water flow is extremely fast, the rotation speed of the magnets inside the meter exceeds the fastest sampling rate of the magnetometer, leading to aliasing (in those old Western movies, when the wagon reaches a certain speed, the wheels appear to rotate backward instead of forward due to this phenomenon). Therefore, when the water flow exceeds a certain rate, the measurement data becomes invalid.

As long as the water pipe does not burst, the flow rate in our house will not reach a speed that affects the measurement data, so I decided to ignore this limitation and further investigate the communication issue of the signal. I also installed an Arduino and magnetometer in the water meter; how to power them was another problem to solve, as the water meter is completely separate from our house.

I used a 15-meter long four-wire telephone line to solve this problem. Two wires provide 9 volts DC to the Arduino; the other two are used to send the signal output (converted to RS-232 voltage using another regulator board purchased from SparkFun) to the Raspberry Pi next to the porch’s regular AC outlet. This way, I have two “wall power points” to easily power the Raspberry Pi and Arduino; and the Raspberry Pi is very close to the router, allowing it to connect to the home wireless network.

I programmed the Raspberry Pi using Python, supporting single-page display, creating a web application using the Flask framework, displaying flow rate and total water usage on the webpage, updating every 10 seconds, and including a button that can reset the water usage to zero.

I haven’t tried to calibrate the settings to display the data in more intuitive units, such as liters per minute, so that the total water usage at any moment can be displayed in arbitrary units. However, the combination of Raspberry Pi and Arduino has already performed excellently in measuring and notifying water flow. Now we can all compare who saves more water while showering.

Real-Time Water Flow Meter Using Arduino and Raspberry Pi

Welcome to follow us! Please leave a message during working hours: MondayFriday from 9:00 to 16:00

WeChat ID: IEEE China

Real-Time Water Flow Meter Using Arduino and Raspberry Pi

Long press the QR code to follow WeChat interaction

↓ Click on the “Read the original text” below to see more

Leave a Comment

×