Close
0%
0%

Water Meter Monitor with Raspberry Pi Pico W

Use a raspberry pi pico w and a magnetometer to keep an eye on water consumption, in real-time!

Similar projects worth following
Using a raspberry pi pico w and a magnetometer, you can monitor your water consumption in real-time. This kind of project has been done before, but now with the raspberry pi pico w, it is easier than ever! This worked with my neptune 2237 water meter, and is entirely non-destructive. Just placed the magnetometer "close" to the meter, and took the measurements. The raspberry pi pico w can easily serve up a webpage showing the results. All done in micropython, with only the code on the github page.

Please check out the github repository, and the directions below.

The main idea is to have the raspberry pi pico w:

connect to the internet

synchronize the real-time clock

start taking magnetometer measurements in one thread

serve up the webpage in the other thread

Here are some references:

IEEE Article - David Schneider

Ed Cheung

I also created code that is just for a simple webserver if you are learning about the pico w for the first time.  Hackaday Web Server

Wow - got featured on hackaday.com - thanks!  Here is another project that was mentioned in the comments - check it out!

Remote Water Consumption Display - John Schuch

Also - you don't need both magnetometers - I used the old ST one because I had it.  The ST one is discontinued, so I also wrote up code for the currently available one that you can get from adafruit.

  • 1 × Raspberry Pi pico W
  • 1 × Magnetometer - LSM9DSO
  • 1 × Magnetometer - MMC5603, or adafruit 5579

  • Connection pictures

    sciencedude199003/28/2023 at 23:17 0 comments

    There was a request for a picture showing how to connect the sensor to the pico.  Please see the gallery.

  • Github update

    sciencedude199002/27/2023 at 13:45 0 comments

    Hi folks,

    I added a MMC5603 code snippet to github, and fixed an array error in the thread for the magnetometer.

    Cheers!

  • Website

    sciencedude199002/21/2023 at 17:58 0 comments

    Once the data has been logged, here is a view of the website.

    I also included "favicon.ico" in the github page, so when the browser grabs the html file, it can make a fancy tab...

    The bar-chart part of the HTML came from code pen

  • Measurements

    sciencedude199002/21/2023 at 17:00 0 comments

    First, I took measurements with the LSM9DS0 taking measurements as quickly as it could.  That is, ~100 Hz.

    Here is the water tap open a bit.

    Here is the tap fully open.

    The detection algorithm is pretty simple: Once you have a reading greater than 6050, look for a reading less than 2500.  Once you get less than 2500, look for a reading above 6050.  Once you get past 6050, increment a counter by 1, and start looking for <2500 again, and so on.  From each peak to peak (i.e., 1 count) is approximately 0.0657 L of water.  Pretty fine granularity!

View all 4 project logs

  • 1
    Setup

    Place the raspberry pi pico w on a breadboard.

    Place the magnetometer on the breadboard.

    Wire up SPI, or I2C.

    Code, code, and code - i.e., go to github and download the code.

View all instructions

Enjoy this project?

Share

Discussions

mike-2545 wrote 01/26/2024 at 19:11 point

I cannot get this to work, even got both magnetometers and still cannot get this to work.

  Are you sure? yes | no

sciencedude1990 wrote 02/21/2024 at 01:23 point

Oh snap.  Let me know how I can help.  I sent you a message in the private chat.

  Are you sure? yes | no

Bob wrote 06/06/2023 at 23:58 point

Excellent project; thank you for sharing. In case anyone would like a pointer to parts:

Adafruit has the following (May '23):

raspberry pi pico w - US$6

mmc5603 - US$6 (3-axis magnetometer)

PiCowBell Proto - US$2 (provides qwiic/stemma qt connector, reset button to rpi pico)

100mm qwiic cable - US$1 (other lengths available)

headers for pico and PiCowBell - US$1.25, US$1

shipping USPS ~US$6

~US$23 + tax

  Are you sure? yes | no

sciencedude1990 wrote 06/26/2023 at 02:02 point

Thanks!  Glad you liked it.  Thanks for pointing out the PiCowBell - that looks handy.

  Are you sure? yes | no

Lee Williamson wrote 06/03/2023 at 02:54 point

That's really impressive! The combination of the Raspberry Pi Pico W and the magnetometer opens up a lot of possibilities for monitoring water consumption. It's great to hear that you were able to successfully use it with your Neptune 2237 water meter in a non-destructive manner. I can imagine how convenient it would be to have real-time water consumption data readily available on a webpage.

The Raspberry Pi Pico W's versatility is truly remarkable. It's fascinating to see how it can be utilized in various projects, from simple sensor monitoring to more complex applications. Speaking of versatility, it reminds me of how a building elevator serves multiple purposes, providing both convenience and accessibility within a structure. Similarly, the Raspberry Pi Pico W serves as a versatile tool, enabling innovative solutions to everyday challenges. Keep up the great work, and I'm curious to know what other projects you have in mind using this amazing microcontroller!

  Are you sure? yes | no

sciencedude1990 wrote 06/17/2023 at 03:35 point

Thanks - glad you liked the project.  I also made a super simple oscilloscope: https://hackaday.io/project/191569-raspberry-pi-pico-super-simple-oscilloscope

  Are you sure? yes | no

mkmer wrote 03/15/2023 at 18:38 point

Bit "funny" - I solved this same problem with ESPHome and the HMC5883L - essentially the same solution without the need to code.  It's a solid way to measure, but I'm a bit skeptical of it accurately "counting" all of the edges when consuming 30GPM  (113.56 L/Min) ~ 28.8 counts/second.  This will be 34.6ms per pulse - 17.3ms polling to catch the lower transition.  If your hitting 100hz (10ms) - it should be fine by almost 2x, but I suspect the field will not reach the same peaks at that rate.  We'll see when it's time to run the sprinklers.

  Are you sure? yes | no

sciencedude1990 wrote 03/17/2023 at 21:03 point

I hadn't looked at ESPHome before - looks cool!

For your comment about the sample rate - yes, higher would be better, and then you could adjust the low/high threshold accordingly.  I wrote up the code for the MMC5603NJ and found you can easily get much higher than 100 Hz.

  Are you sure? yes | no

sciencedude1990 wrote 03/15/2023 at 14:51 point

Glad people liked the project, any questions or comments?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates