Close
0%
0%

YDrip

An open source water meter that detects leaks and measures usage

Similar projects worth following
YDrip is an open-source water meter designed to detect costly water leaks and track your home water usage. The hardware design is flexible enough to easily repurpose it for measuring residential gas and electricity meters, as well as any signal that requires continuous reading while maintaining a long battery life. Existing commercial devices lock data your behind proprietary apps, may require professional installation, and can be expensive. YDrip aims to solve these issues and more.

FAQ

What problem does it solve?

YDrip primarily addresses the issue of costly water leaks and provides real-time usage information to help homeowners identify ways to conserve water. It can also assist municipalities in reducing consumption when deployed at scale, as population growth and changing climates continue to put a demand on water reserves. For example, Arizona recently implemented restrictions on new home construction as they face challenges related to declining groundwater levels.

How do most people deal with leaks and monitor usage today?

Many municipalities still rely on manual reading of meters by human operators. This means homeowners are charged based on estimates from past bills and only discover the actual cost 1-2 months later. By that time, a water leak could have already caused significant financial losses.

The minority of municipalities that have installed smart meters often lack effective leak notification systems. Their websites can be difficult to use, and reporting delays of hours or days are common. Additionally, profit incentives often don't align with conservation efforts, which is why some municipalities have started to decouple the profit motive.

Beyond leak detection, it is challenging to experiment with habit changes to reduce consumption without near real-time data.

What are the problems with existing solutions?

Existing commercial devices have various limitations:

  • They often restrict access to your data through proprietary apps.
  • Some require internet connectivity, turning what should be an appliance into a device with an expiration date tied to the company's lifespan.
  • If data is accessible, it is often difficult to integrate it into other services.
  • Some devices necessitate professional installation and can be expensive.
  • The non-invasive solutions that do exist for reading water meters, there are few to none available for gas meter reading.

How does YDrip solve these limitations?

  • The YDrip firmware is open source meaning you are free to use your data how you like. Opt-in hosted solutions will be available for those that want a turn-key solution.
  • YDrip will always function without an internet connection on your local network.
  • ESPHome and Home Assistant compatibility will be supported at launch.
  • The next version of YDrip will support non-smart mechanical gas meters without using light to read the dial which can be inaccurate and hard to install.

Requirements

YDrip shall:

  • 🗹 be open source
  • 🗹 be compatible with a wide range of water meters that have a rotating magnet mechanism
  • 🗹 function without an internet connection
  • 🗹 be wireless for remote monitoring of water usage and leak alerts
  • 🗹 allow users to customize settings such as leak detection sensitivity and data transmission frequency 
  • 🗹 be compatible with popular home automation platforms, such as Home Assistant
  • 🗹 be battery operated with a life span measured in months
  • 🗹 send leak a notification as soon as one is detected
  • 🗹 (in progress) low cost
  • 🗹 (partial) include algorithms to detect abnormal water usage patterns that could indicate leaks or unusual consumption
  • ☐ be waterproof and withstand outdoor temperatures

Current System Design

Hardware Design Decisions

The main limitations on the hardware designs are affordability and battery life. Many IoT devices require a hub to bridge the low power RF like LoRa to WiFi/Ethernet. This increase cost and complexity for an initial prototype. However, using WiFi presents challenges with power consumption. An ultra low power reprogrammable digital logic chip was chosen to offset this. It allows for maximum flexibility while using less power than general purpose CPU for meter reading.

An ultra sensitive tunneling magnetoresistance (TMR) sensor was chosen for maximum measurement distance, which reduces the need for excessive signal amplification.

Software Design Decisions

The choice of ESPHome software...

Read more »

  • 1 × ESP32-S3 The ESP32 line was chosen for it's compatibility with open source software, WiFi capability and low cost. Using WiFi as the wireless protocol removes the need for a hub, which adds cost and complexity. However, this makes meeting battery life and range requirements more difficult vs a standard like LoRa.
  • 1 × SLG47004V A low cost programmable mixed signal logic chip used for deep sleep logic like rotation counting, interrupt generation and sensor duty cycling to reduce power. Most of the logic will be designed using digital logic because it is significantly lower power than a CPU. For example, the ESP32-S3 ultra low processor consumers 300uA. Digital logic can do much better.
  • 1 × ALT021-10E An ultra sensitive tunneling magnetoresistance (TMR) sensor. This is the only sensor I've found that is sensitive enough to measure the rotation of the water meter magnet without amplification. While this works in V2, the next design will include a small amplification stage to add room for margin.
  • 1 × PCF8563 Clock and Timer ICs / A basic real-time clock for clock generation for the SLG47004V​ and time keeping. The ESP32-S3 RTC does not have an external clock output so this IC was used.Real-Time Clocks
  • 1 × IN-PI22TAT5R5G5B An RGB LED for user feedback. Primarily chosen for it's low height to fit under the the LED lens.

View all 7 components

  • Hackaday Prize 2023: Green Hacks Recap

    ydrip10/10/2023 at 07:15 0 comments

    I wanted to provide a recap of the work done since being selected as a finalist for the Green Hacks contest. Here are the highlights:

    • Multiple revisions of the enclosure and circuit after testing
    • Redesigned the analog front end with auto DC offset calibration to reduce interference from the earth's magnetic field
    • Added amplification to the magnetic sensor output
    • Implemented a leak detection circuit using digital logic that doesn't require the CPU allowing ultra long battery life
    • Demonstrated passive gas meter reading by measuring small changes in the earths magnetic field caused by moving metal inside of the meter
    • Demonstrated smart meter electricity reading
    • Performed power measurements using the ESP32-C6 and WiFi 6, which will improve battery life and responsiveness once integrated into the software

    Why is it unique?

    This project was designed to solve the narrow issue of water leaks, but the resulting design has shown to be much more broad. The reconfigurable digital hardware provides a lot of flexibility for more ultra low power sensors applications some of which have been demonstrated.

    YDrip is a unique solution in many ways. First, passive gas meter reading is a totally unique use case with no commercial products on the market. Additionally. it has the capability to be a three in one device measuring all of the utilities.

    Next Steps

    Polishing up the software, getting ESPHome certified, designing a water proof enclosure and fixing a few minor hardware issues.

    Video Promo

  • Smart Meter Power Reading

    ydrip10/09/2023 at 16:40 0 comments

    The ultra low power reconfigurable digital logic in YDrip makes it possible to log more than just water usage. The design is great for any application that needs to do simple logic like counting, leak detection or more. Smart meter reading is one of those applications. Most smart meters work by flashing an IR led to indicate electricity usage. You could use a general purpose CPU and wake-up on a GPIO interrupt, but this means the power hungry processor will wake up multiple times a minute draining battery. With YDrip, we can program the digital logic to count for us and wake the CPU when necessary. Using this approach we only use 60uA while reading.

    I 3D printed an LED housing and clamp holder for testing. In hindsight, using two claps to hold the threaded rode would provide more stability for the LED.

    Three wires provide power, ground and signal from the YDrip expansion connector to the LED.

    Here is the github branch I made for the software modifications: 

    https://github.com/YDrip/ydrip-esphome/tree/smart_meter

  • Promising WiFi 6 Power Measurements with the ESP32-C6

    ydrip10/07/2023 at 02:26 0 comments

    Tldr: YDrip V3 was designed to be footprint compatible with ESP32-C6, which supports WiFi 6. A key feature of WiFi 6 is the ability for devices to sleep for extended periods while remaining connected. This solves the issue of not being able to communicate with the ESP32 while it's in deep sleep.

    Light Sleep

    One of the misconceptions about the ESP32 is that they are capable of running on batteries for long periods of time. They are IoT devices after all right? Unfortunately, the details get complicated when you actually try building an application. Let's use the ESP32-S3 as an example:

    The datasheet specifies a range of 7 to 240 microamps depending on the sleep state. However, you quickly learn that light sleep is the only possible mode if you plan on using WiFi (which is the main feature of ESP32). This is because the ESP has no way of saving the WiFi association information in deep sleep. In light sleep, the CPU powers down some components until the next beacon from the access point (100s of milliseconds). Here is an example of the C6 in light sleep mode.

    You can see the ESP32 wakes up many times to stay associated with the AP and uses an average of 23mA. This is better than the 100 mA you can expect without light sleep, but this is not low enough to be battery powered for months.

    Deep Sleep

    The other approach, which is what I chose for YDrip, is to go into deep sleep until you have data to report back and re-associate every time. There are two trade offs here. The first is boot and WiFi association uses a lot of power. Here is an example from an earlier measurement I took with V2.

    The ESP uses more than 150mA during boot for a few seconds. The total power consumption after establishments a connection is 100mA, but is highly dependent on how long the negotiation takes. The second down is you can't communicate with the device in deep sleep until it wakes. Not a great user experience if they need to change settings for example.

    WiFi 6 Solution

    Luckily, this isn't a problem that only affects the ESP32, which is why the WiFi Alliance has made some changes to the latest standard. Like I mentioned above, earlier versions of WiFi required devices to go into light sleep between beacons every few hundred milliseconds. WiFi 6 introduce the concept of Target Wake Time (TWT), which allows devices and access points to negotiate this sleep time instead. This means YDrip can sleep for extended periods of there is no water usage while still remaining connected.

    V3 is footprint compatible with the ESP32-C6 so I decided to get a TP Link AX180 WiFi 6 router and test it out. Support of C6 in ESPHome is still a work in progress so I used the itwt example from the ESP-IDF. These are the settings I used to configure TWT.

        /* setup a trigger-based announce individual TWT agreement. */
        wifi_phy_mode_t phymode;
        wifi_config_t sta_cfg = { 0, };
        esp_wifi_get_config(WIFI_IF_STA, &sta_cfg);
        esp_wifi_sta_get_negotiated_phymode(&phymode);
        if (phymode == WIFI_PHY_MODE_HE20) {
            esp_err_t err = ESP_OK;
            wifi_twt_setup_config_t setup_config = {
                .setup_cmd = TWT_REQUEST,
                .flow_id = 0,
                .twt_id = CONFIG_EXAMPLE_ITWT_ID,
                .flow_type = flow_type_announced ? 0 : 1,
                .min_wake_dura = 255,
                .wake_duration_unit = 0,
                .wake_invl_expn = 10,
                .wake_invl_mant = 16384,
                .trigger = trigger_enabled,
                .timeout_time_ms = CONFIG_EXAMPLE_ITWT_SETUP_TIMEOUT_TIME_MS,
            };
            err = esp_wifi_sta_itwt_setup(&setup_config);
            if (err != ESP_OK) {
                ESP_LOGE(TAG, "itwt setup failed, err:0x%x", err);
            }
        } else {
            ESP_LOGE(TAG, "Must be in 11ax mode to support itwt");
        }

    The plot above shows the device wakes up every 16 seconds and uses an average of 708uA while staying associated. This is a dramatic improvement over the 23mA we saw with light sleep. While it's not as low as the 50-100uA if we deep sleep until some water usage is detected, it's a great trade-off for users that want communicate with the device.

  • Water and Gas Meter Reading Demo + New Issues

    ydrip09/27/2023 at 18:30 0 comments

    Quick update on the status of V3 testing. Water and gas meter reading works. DC offset calibration is working well. The only new issue is the metallic housing on the AA batteries is causing significant interference with the mag sensor. Enough that it saturates the sensor beyond the offset calibration capabilities. I will either need to redesign the PCB and case to add more distance between them or switch to a different battery technology.

  • V3 Prototype - New Analog Front End + Refinements

    ydrip09/23/2023 at 18:35 0 comments

    V3 (beta) of YDrip has been assembled and tested. The main goal of this version was to add dynamic gain and DC offset control. This makes the design able to measure gas meters and water meters with weak magnets from a larger distance.

    Read more »

  • Passive Gas Meter Reading

    ydrip09/09/2023 at 21:08 0 comments

    One of the larger goals for this project is to build an ultra low power platform to measure a variety of sensors. The next logical step after water meters is measuring gas meters for a few reasons. There are no passive devices on the market that do this for 'dumb' mechanical meters as far as I know. Second, natural gas companies usually charge months after a home owners usage (similar to water), which can lead to surprise bills. However, gas meters work a bit differently than water meters, which presents new challenges.

    Source: Wikipedia

    Basic mechanical gas meters use a diaphragm that expands and contracts with the flow of gas. This in turn moves levers and gears to eventually turn a mechanical dial indicating the usage. There are no magnets in this design so I decided to measure the change in the earth's magnetic field caused by the moving metallic parts instead.

    In the previous two post I discussed how the earth's magnetic field was adding a variable DC offset depending on the orientation of the sensor. In this case, I'm using it to my advantage. I'll do a more detailed write up on how I modified the design to do this in the next post. For now, check out the video demo above.

  • Ultra Low Power Design with Mixed Signal Programmable Logic

    ydrip08/31/2023 at 01:19 0 comments

    The most interesting aspect of YDrip is likely its programmable logic. This is where a lot of the heavy lifting happens, including tasks such as leak detection and revolution counting. While it's possible to use a low-power microcontroller as an alternative, the drawback is that it would significantly increase power consumption. This isn't ideal for a product designed to remain operational over many months. Some microcontrollers, like Atmel and TI's MSP, come with customizable hardware blocks capable of performing basic functions like hardware-based counting. However, their capabilities are somewhat limited. This is why I ultimately decided to opt for a complete hardware solution.

    My initial approach was to use discrete logic chips until I found the GreenPAK product line from Renesas. Specifically, the SLG46826 model. It's reconfigurable, energy-efficient, and cost-effective ($1.60 for individual units). The package includes features such as analog comparators, counters, logic gates, oscillators, and more.

    Analog to Digital


    Starting from the left, the sine wave from the TMR sensor is fed into one input of the analog comparator. The other input is a reference voltage of 1600mV, which is the midpoint of the signal. Any voltage from 32mV to 2V can be selected in increments of 32mV. In earlier designs I used two comparators. One for each differential output of the TMR sensor and XOR'd them together. This provided no benefit so I removed the second one. Using a differential signal would help if the difference between them was amplified, but I was not doing that at this point. Here is an example of a differential signal:

    The red signal is the difference between the two signals above it and is twice as large. This improves the signal to noise ration and shows why differential outputs are used.

    Pulse Counting and Leak Detection

    The high/low output of the comparator splits into two paths. The top path measures the total water usage. It consists of two programmable 8 bit counters. When they overflow that triggers a third counter configured as a one shot counter to send a short wake-up pulse to the ESP32S3.

    The bottom path is the small leak detection logic. It low pass filters and counts the pulses. This filter is configurable via I2C. That value gets stored in two 8 bit counters and another one shot counter is used to send a leak interrupt signal.

    Wake-Sleep Controller

    A critical part of achieving a long battery life is duty cycling the magnetic sensor. It draws about 300uA. The wake-sleep controller can duty cycle power to the sensor and have the analog comparator only sample during 'on' times. This brings the system power down to only 55uA! See the previous post about power consumption. The main clock for the system is brought in from an external 32kHz RTC because the internal low power 2kHz oscillator is a little too slow. 

    Clock Divider

    Finally, a series of flip flops are used to divide down the 32khz clock to 64Hz. This slow clock is used to detect long running leaks by the low pass pulse filter.

    Conclusions

    By utilizing a mixed signal programmable logic IC this design was able to achieve a standby current of 55uA while also maintaining a variable wake-up time and leak threshold. Almost all of the logic blocks have been utilized in the SLG46826 making maximum use of it's capabilities.

  • V2.5 Prototype - Adding Mag Sensor Amplification

    ydrip08/24/2023 at 19:35 0 comments

    Sponsor


    This version of YDrip was kindly sponsored by PCBWay. They have been my PCB vendor for version 1 and 2 so I'm thrilled they decided to sponsor the manufacturing for v2.5. I've used them in the past because their website provides real-time updates with the status of your product and their support engineers provide great design feedback to make sure their are no manufacturing delays. The ordering process is also extremely easy with their KiCad plugin, which automatically packages your board design, opens a browser, and adds it to your shopping cart.

    v2.5 prototype STL printed enclosure and PCB

    This was my first time ordering 3D printed STL parts from PCBWay and I'm very satisfied with the result. The 0.8mm lip that connects the two halves of the enclosure printed perfectly along with all of the ribs for rigidity. Their part finishing is also well done with no signs of support marks or warping. The PCB quality is what you've come to expect with no flaws and good enough dimensional accuracy to friction fit into the case. Thanks PCBWay.

    Fully assembled enclosure

    Electronic Design Changes

    The ALT021-10E is an ultra sensitive magnetic sensor (0-0.25 mT). It's so sensitive that I've been able to use it without an amplification stage which has reduced BOM costs and complexity. Unfortunately, I've run into a few problems.

    1. The earth's magnetic field can interfere with measurements depending on the device position.
    2. Some water meters have very weak magnets that are not measurable with the current design.

    To fix these issues, I decided to add an op-amp to amplify and offset the output signal. I chose the SLG88103104 from Renesas which has a stunning 375 nA quiescent current per channel. It also has a shutdown pin which I can duty cycle with the sensor, but it almost wouldn't make a difference in the total power budget.

    The opamp is setup as a differential amplifier with both sides of the wheatstone bridge sensor going to the +- inputs of the amplifier. (Ignore the resistor values. They are just place holders)

    A better design would use an instrumentation amplifier to avoid loading the wheatstone bridge which could reduce accuracy if not take into account. One way to mitigate this is by using much larger input resistors than the bridge resistance (10k in this case). Here is an example from the datasheet. This app note from TI goes into more details about the tradeoffs for each approach.

    This is great, because instrumentation amps cost more and drain more power. The addition of the amp solved my initial problems, but I ran into new ones.

    New Problems...

    Up until now I've been reusing some parts like the mag sensor since they were out of stock at the time. This meant I didn't have to deal with device to device variances which would impact my amplifier design. Silly mistake.   

    The ALT021 wheatstone bridge DC offset variance is +- 20mV. We can see that in the datasheet and following plots.

    Green & Yellow = Sensor 1

    Pink & Blue = Sensor 2

    Blue plot is behind the green. See the measurements window on the bottom right for the DC offset

    Sensor 1 has a difference of 27mV between differential pairs and sensor two has a difference of 9mv. Here are the same devices rotated by 90 degrees.

    There is a 2mv - 4mv change due to the earth's magnetic field.

    This last plot is with a magnet spinning near the sensors.

    In a perfect world both signals would be centred around Vcc/2 or 3.3V/2 = 1.65V with no magnetic field. The problem starts when you try to amplify the difference between the two differential pairs. The difference in DC offset between sensor 1 and sensor 2 will also get amplified resulting in an output signal with an even larger offset. Here is a simulation with sensor 1.

    The bottom two lines are 50mV sine waves with 180 degree offset at 1.41V and 1.68V (sensor 1). We can see the output signal (green) is offset by about 2.6V. Let's take a look at sensor two which...
    Read more »

  • Low power small leak detection

    ydrip07/19/2023 at 15:25 0 comments

    I have made modifications to the programmable logic to identify minor leaks and trigger the ESP32-S3 to alert the user, which will have a significant positive impact on battery life. Software-based detection can identify large leaks when the ESP32-S3 wakes up to report regular usage. For instance, if the usage remains consistently high for an extended duration, however this is not implemented yet. All variables can be customized through the YAML file.

    Here is what the Home Assistant Card looks like


    Source: https://github.com/YDrip/ydrip-esphome/commit/77c73d2ae2ac85a2539d3d88513e001614a7b9a4

  • Green Hacks Contest Submission

    ydrip07/03/2023 at 23:05 0 comments


    I wanted to share that this project will be submitted into Hackaday's Green Hacks contest. This opportunity came at the perfect time because the costs for the development of version 3 of YDrip will be significant. This version will be weatherproof and potentially capable of reading diaphragm-style gas meters (some testing is still required). To achieve this, I am planning on injection molding the enclosure, which has a significant upfront cost.

    The theme of the contest is to:

    Build a hardware solution that recycles electronics, makes energy harvesting or storage more efficient, or contributes to the sustainability movement.

    YDrip contributes to the sustainability movement by giving home owners and business the tools to reduce water consumption. It does this in two ways. The first is by detecting leaks before they turn into costly problems. The second is by giving users real-time water usage data to empower individuals to make informed decisions to conserve water. By visualizing consumption patterns and setting goals, individuals can modify their behavior and adopt water-saving practices. This can include water decisions about whether it is time replace that appliance or how long to water the lawn.

    A Unique Solution

    The YDrip project addresses a gap in the open source market by offering a versatile solution. Its low-cost and low-power design, combined with programmable digital logic, enables it to be repurposed for various applications. For instance, the hardware's fundamental elements can be utilized to monitor gas meters, and by adding an IR LED, it becomes capable of measuring smart electricity meters. This flexibility and adaptability make YDrip a valuable option for a range of monitoring needs.

View all 17 project logs

  • 1
    V3 Prototype - Hardware Build Instructions

    1. Download the gerber files from Github: https://github.com/YDrip/ydrip-pcb/archive/refs/tags/v3_prototype.zip

    2. Zip up the gerber directory and upload to PCBWay.

    3. The options should be auto detected from the gerber files. Order the PCBs

    4. Order the parts from the BOM from Digikey.

    5. Place each component matching the reference designator from the BOM to the images below.

    Top

    Bottom

    5. Solder the parts using a hot air gun or reflow oven.

  • 2
    V3 Prototype - Enclosure Build Instructions

    1. Download the STEP files from Github: https://github.com/YDrip/ydrip-enclosure/archive/refs/tags/v3_prototype.zip

    2. Print upper_cover.stp & bottom_cover.stp using PCBWay's rapid prototyping service using SLA. It should cost around $5 each after requesting for a quote. It is possible to print using FDM (not from PCBway due to accuracy constraints) if you have a good printer.

    3. Print Strap.stp using TPU if your printer is capable.

  • 3
    V3 Prototype - Software Build Instructions

    1. Install ESPHome. Using Docker is the easiest method.

    2. Download YDrip source into the esphome directory: https://github.com/YDrip/ydrip-esphome/archive/refs/tags/v3_prototype.zip

    3. From inside of the YDrip directory run:

    esphome  run --device /dev/ttyUSB0 ydrip.yaml

     4. Install 3 AA batteries to power up the device.

    5. Install Home Assistant on your PC or Raspberry Pi. Guide

    6. After logging in to Home Assistant select

    Settings > Devices & Services > Add Integration



    Search for ESPHome

    7. It should ask you for your nodes IP address. You can find this from the serial console of the device. However, the device should auto detect in a few seconds. Select configure.

    8. YDrip should be added to your home screen. Next, install the device around your water meter with the LED facing up. It should be as close as possible to the brass housing.

    9. Select, "Start Cal" from home assistant and run a faucet fully open. Select "Stop Cal" and turn off the faucet. This calibrates the DC offset circuitry to reduce interference from the earths magnetic field. It must be done anytime the device is moved.


    10. The ESP32 will go into deep sleep until wakeup_pulse_count revolutions of the magnet inside of the water meter. Some magnets have multiple poles so you may get multiple pulses per revolution. Determine how many revolutions equal a gallon by settings this number to 1 and using a specified amount of water.

View all 3 instructions

Enjoy this project?

Share

Discussions

stefan.schnitzer wrote 10/07/2023 at 05:35 point

Great project and neat implementation.  I tried to build something like that a few years back -> https://hackaday.io/project/179532-retrofit-waterstop 

  Are you sure? yes | no

nodemcu12ecanada wrote 06/23/2023 at 18:18 point

Just reading the water meter remotely with a WiFi cam can be helpful at detecting leaks early.

https://hackaday.io/project/175152-detect-water-leaks-with-a-10-wifi-webcam

  Are you sure? yes | no

ch.dugasduvillard wrote 06/09/2023 at 06:40 point

Hi, I'm very interesting by your project. I'm looking to create something similar since a long time.

Can I ask you how you get the value from meter ? I have 2 meters at home one for heat water and one for cold water that I'd like to connect.

Thanks.

  Are you sure? yes | no

ydrip wrote 06/09/2023 at 19:23 point

That's interesting. I've never come across different meters for hot and cold. Do you mind posting the model number and which country you're in?


Most water meters have a spinning disk inside of the brass housing (on the left in my first picture) that spins based on the volume of water passing though it. The city installs a reader on top of the brass housing which reads the number of rotations. That info is read by a utility worker every few months or sometimes transmitted over-the-air to the water company.


The difficulty with building your own device is proximity to the magnet. The city reader is usually in the way so you need to position any 3rd party reader on the side, which means you need a very sensitive sensor. I'm planning on posting more details here and on my website about all of this.

  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