Maker Portal

View Original

Water Metering with the WaWiCo USB Kit and Raspberry Pi

See this content in the original post
See this content in the original post

See this content in the original post

The main part used in this project is the WaWiCo USB Water Metering Kit, which can be found in our store in either pre-assmebled form or DIY kit form. The WaWiCo kit uses a MEMS microphone attached to the user’s piping system to listen for water flow via a computer’s USB port. A Raspberry Pi is used to read the USB signal in our case. Finally, a hall sensor water meter is used as a comparison against the acoustic WaWiCo device. The full parts list is given below to follow along in our analysis:

  • WaWiCo USB Water Metering Kit - $35 (Pre-Assembled), $20 (DIY Kit)

  • 3/4" Hall Effect Flowmeter - $11.99 [Amazon]

  • 3/4” Fitting, Barbed to NPT Female - $6.38 [Amazon]

  • 3/4” ID Clear Vinyl Tubing - $24.99 (25ft) [Amazon]

  • Raspberry Pi 4 Computer - $52.99 (2GB), $61.88 (4GB), $88.50 (8GB) [Amazon], $55.00 [2GB from Our Store]

See this product in the original post

For the DIY kit, the MEMS microphone needs to be powered from the USB sound card using the following pinout convention:

The wiring, with the inclusion of the 3.3V regulator, is given below between the MEMS microphone and USB sound card:

In the pre-assembled kit, the wiring is done for the user.

See this content in the original post

An abridged version required for the software installation can be found at the WaWiCo USB Water Metering GitHub Page:

See this content in the original post

See this content in the original post

The flow meter being used as a comparison with the WaWiCo water metering kit must first be calibrated to ensure that the comparison between the two is valid. The way we calibrate the flow meter is by first looking at the relationship between the output signal and the actual flow rate measured by the actual fluid accumulation over time. For our flow meter, the relationship between flow rate and electronic output is given as follows:

See this content in the original post

Since we’re interested in shorter time periods (other than L/min), we can convert the approximation of flow rate Q in L/s:

If your calibration coefficient is not available, then the coefficient above may need to be calibrated. The way this can be done is through integration of the flow rate over time to a given measured volume. In our case, we are using a 3L container to measure water flowing through the mechanical flow meter. A photo of the flow meter and 3L container is shown below, for reference:

The code used to calibrate the flow meter is given below, which can also be found on the GitHub page:

See this content in the original post

Below is a short GIF of the flow meter and calibration code running on a Raspberry Pi (ssh from laptop):

See this content in the original post

The variable ‘conv_factor = 1.0/(5.5*60)’ contains the sensor calibration coefficient, which in our case is 5.5. If the user is unaware or skeptical of their sensor calibration coefficient, this number should be altered based on a series of measurements at different volumes measured by the graduated container. For our sensor, the coefficient of 5.5 was correct and thus, we were able to verify it with several volumetric measurements using the script above. Therefore, going forward, we know that the code above with the calibration coefficient is accurate and can be used for flow measurement comparisons with the WaWiCo water metering kit.


See this content in the original post

Now that we have a mechanical flow meter for comparison working on the Raspberry Pi, we can start to look at the similarities and correlations between the mechanical flow meter and WaWico acoustic flow meter. This will allow us to establish correlations between the behavior we see from the mechanical meter and the acoustic meter positioned along the piping system or faucet (as we have it).

See this content in the original post
See this content in the original post

The code to correlate the two is also given below (and on the GitHub page), where the GPIO 23 on the Raspberry Pi is used to read the mechanical flow meter:

See this content in the original post

An example plot from the correlation analysis is given below:

In our example plot above, our correlation between our faucet mechanical flow rate and our WaWiCo acoustic signal shows fairly high correlation, ρ = 0.85, for the region 5kHz-8kHz, and perhaps 10kHz+, with a region of anti-correlation in the 9kHz region. This is important for monitoring flow in the future, as we can monitor this region and determine if water is flowing or not.

Note #1: the correlation coefficient ranges from -1 to +1, where +1 indicates the two signals are correlated and -1 indicates the two signals are negatively correlated. Ideally, we want the highest correlation either in the positive or negative direction, as the higher value indicates a better correlation between the two signals (even if negatively, i.e. in opposite sign).

Note #2: Another important note is that the longer the script runs, the more information the analysis will have for analyzing the piping system and correlation between mechanical flow meter and acoustic response. That being said - there also must be a diverse set of data inputted to the system, meaning - no flow periods, water flow periods, background noise and disturbances indicative of the normal environment need to be part of the testing. This will create a better correlation between the response and actual flow, while minimizing interference and false-trips during noisy non-flow periods.


See this content in the original post

In this section, we implement a Goertzel algorithm for finding the power contained within a frequency range found from above. Then, this power is used to compare with the mechanical flow meter in order to determine the viability of water metering using the amplitude of the response from the Goertzel calculation.

The code used to acquire both the frequency band from the Goertzel algorithm and the flow rate from the mechanical meter is given below (and on the project GitHub page):

See this content in the original post

The Goertzel algorithm is often used to evaluate a selected frequency band of terms of the Fast Fourier Transform (FFT) [read more about the Goertzel algorithm and its applications in acoustics here]. Parameters of the Goertzel algorithm, such as the spacing between frequencies is controlled by the sample rate and the recording length of the audio signal. The specifics of the Goertzel algorithm are not covered here, but the function contains comments that explains some of the procedure.

Below is an example output of the analysis done to compare the Goertzel response over the 7.5kHz - 8.5kHz region and the mechanical flow meter:

The plot above allows us to make several statements about the relationship between flow rate and power in the frequency bands of interest:

  • When the flow rate is low, the acoustic device shows little amplitude change

  • Each flow rate has a range of Goertzel amplitudes that indicate flow

  • The algorithm is not susceptible to false positives (i.e. no flow = very low Goertzel amplitude)

  • It may be hard to distinguish between flow rates, but more needs to be done to verify this (perhaps different frequency bands can determine this?)

  • The flow meter is not very sensitive over the short term period used here ( ≈ 93ms), perhaps longer periods could give better resolution in Q

  • The faucet being used is somewhat turbulent, which may describe the difficulty of resolving flow at higher flow rates

  • The experiment above can also be run for different frequency ranges, which may contain more information

  • A possible explanation for the wide Goertzel response in the middle flow rates may be explained by lags between audio input and mechanical flow meter


See this content in the original post

In this tutorial, a mechanical flow meter was introduced as a comparison to the WaWiCo USB Water Metering Kit. The WaWiCo USB kit listens to your pipes via an acoustic signal, while the mechanical meter uses the actual flow of water to approximate flow rate. The goal of this tutorial was to bring the WaWiCo acoustic listening method closer to an actual water meter by developing routines that correlate the mechanical flow of water through a hall-effect turbine to the acoustic vibration or water flow measured by the WaWiCo flexible acoustic device attached to the piping system. The advantage of the WaWiCo method is that it requires no changes to the user’s piping system. No plumbing required, no invasive cutting, and no disruption to the user’s daily water use. Conversely, the mechanical flow meter must be placed inline with the flow. This is the great advantage to the WaWiCo method and the USB water metering device!

See this content in the original post

See more from WaWiCo:

See this content in the original post