Pet water bowl monitor using HX711 and ESPHome

I’ve seen folks make sensors that could tell water level using a conductivity sensor, but I wanted one that was independent of the bowl, couldn’t be inadvertently knocked out of the bowl by excited dogs, and allowed the bowl to be cleaned easily. I figured since water is 1kg per Liter, it should be easily monitored with a load sensor.

So, I grabbed some load sensors, HX711, and an esp32 and viola! a dog bowl sensor that will not only let me monitor things on the dashboard, but I have an automation that will push a critical alert to me and flash an indicator light if the water gets below 10% level.

I started with two platforms made of bamboo cutting boards because the water bowl is on an uneven waterproof mat on my floor. Sandwiching the load sensors between the rigid boards would give me an even weight distribution.

I wired up four sensors, one in each corner of the platform, following the wiring diagram from circuitjournal. Hot glue kept everything in place

Then I wired it to the HX711 and wired them to my esp32, putting them in a small project box for neatness.

To keep the two platforms aligned, I used three pass-through pins so the dogs wouldn’t knock the sandwich apart.

esp32 code was super basic, here is the important part. I calibrated the sensor to read an empty bowl as 0 and a full bowl as 100 using calibrate_linear.

# Dog Dish configuration entry
sensor:
  - platform: hx711
    name: "dogBowl Weight"
    dout_pin: 25
    clk_pin: 26
    gain: 128
    update_interval: 60s
    filters:
      - calibrate_linear:
        - -83000 -> 0
        - -163800 -> 100
    unit_of_measurement: percent
    accuracy_decimals: 0

    # Uptime sensor.
  - platform: uptime
    name: dogBowl Uptime
    update_interval: 600s

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: dogBowl WiFi Signal
    update_interval: 600s

My automation is super basic: if the bowl is below 10% for 10 minutes, it sends me a critical alert and starts blinking the alert light incessantly. I put in the 10 minute delay to allow for pulling the bowl from the sensor for refilling it.

alias: dog water critically low
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.esphome_web_8888d0_dogbowl_weight
    for:
      hours: 0
      minutes: 10
      seconds: 0
    below: 10
condition: []
action:
  - service: notify.mobile_app_phonename
    data:
      message: Hey, the dog water is critically low
      title: Dog Water Low!
      data:
        push:
          interruption-level: critical
  - repeat:
      sequence:
        - service: light.turn_on
          metadata: {}
          data:
            flash: long
          target:
            entity_id: light.alert_light
        - delay:
            hours: 0
            minutes: 0
            seconds: 20
            milliseconds: 0
      until:
        - type: is_value
          condition: device
          device_id: device
          entity_id: dogbowl_entity
          domain: sensor
          above: 30
mode: single


Then a basic gauge on the dashboard:

type: gauge
entity: sensor.esphome_web_8888d0_dogbowl_weight
name: Water Dish
min: 0.4
max: 100
needle: true
segments:
  - from: 0
    color: red
  - from: 10
    color: '#edde5e'
  - from: 30
    color: '#32d0fa'
unit: '%'

4 Likes

Nice project. You should be aware that these sensors are known to drift a bit with time. You may find you have to implement a tare function to overcome this (set a zero offset when a button is pressed). You could even implement an auto tare function like that found here: GitHub - markusressel/ESPHome-Smart-Scale: An ESPHome based Smart Scale.

Hi Tom,

I’m fine with drift. This is measuring approximate water level in a water dish for a dog.

As far as auto-tare, that won’t work at all, because the bowl is always on the sensor, and will hopefully always have water in it.

If I notice that drifting becomes a big issue, I may put in a manual tare, but until then, I’m good.

1 Like

@rocket How did you power your project? I’m thinking about following your path, but there isn’t convenient power where the doggo feasts.

If anyone has recommendations for batteries I’d appreciate it, planning on picking up some 3.7v LiPo and using the onboard charging circuit of the ESP32C3 or C6. I know there may be lower current approaches, but I don’t mind a recharge every few months.

I just recently built such dog water bowl. I used auto tare option, mentioned above. You say that won’t work…not true…i guess (hope) you clean bowl regularly/every now and then, correct? I built system so that when i remove bowl to clean it system goes to zero with auto-tara function. I changed auto-tare start weight settings so that it starts only below 0.3kg (weight of dry bowl) - default is under 10 kilos, if i remember correctly, which is way too high.

Funkmechanic: using batteries you’ll have to use sleep function, otherwise you’ll charge batteries every few hours, not months… i think that for this purpose it’s quite enough to wake up system once every 5! 10, 15 minutes or so and check/report state.

power outlet nearby with a usb adapter. Sorry, I know nothing of battery charging.

Auto-tare would need to work several times a day to be accurate, as the calibration changes depending on temperature.

So, nah, I don’t clean the dog bowl 4 times a day.

As I mentioned before, I don’t need absolute accuracy. If I’m within 15%, I’m just fine for this application.

These two statements are somewhat contradictive, don’t you think?
It depends on the size of your bowl, but you don’t need accuracy to gramms in any case (as you said), as we don’t measure cocain :rofl:. You only need info to, say, 100g accuracy, that’s already overkill, even 0.5kg would be ok (but, as said, depends on bowl size). I have set my alarm below 2kg, but i have two goldens and large, 7L bowl…

Also - the tara function in above github project is in 100g steps anyway if i remember correctly, so that’s pretty much accuracy of this project.

And, no, you don’t need to clean bowl 4times a day - at least not for tara function. Fluctuation is not so fast, it’s more like it shifts a bit with … days, weeks, not hours.
So if you clean bowl only once a week (hopefully not…) even that’s quite ok for tara to function properly (i clean it once a day generally). I have this system built over a month now and it works perfectly. I’ve had a float switch before and this works way better, and also i don’t have that nasty float in my bowl on the way. That switch was also pretty interesting to my dogs and it happened that they threw it out or shifted so it reported false alarms.

nah, I don’t think the two statements are in opposition.

I don’t need absolute accuracy, and auto-tare would need to work several times a day to be accurate are both true.

fluctuation is only visible on this sensor over day with temperature that I’ve noticed. I can see in the graph when the morning sun stops hitting the door near the bowl because the weight will slowly drop.

but cool that you have found a use for the tare when you clean the bowl. I only have my sensor update every 5 minutes, and that is much more time than it takes to bowl clean. But I can see on the graph whenever the dog takes a drink :slight_smile:

if one want fewer diy, there is a kit: Gravity: I2C 1Kg Weight Sensor Kit (HX711) - DFRobot