ESPHome water level sensor

If your tank is deep and has incoming water( causing ripples which can cause problems with ultra sonic) I think the throw in is the way to go.

To save you from scrolling? Why stop there? Maybe we can schedule a time to have someone come build and imstall it too? Hell I say they throw in a back massage with a happy ending too! You cant be expected do all that manual labor! Scrolling??? You might get carpal tunnel or break a finger nail from all that work. Who the hell do these people think they are on here!?!? You just give me the names of the people who expected you to do any kind of work or scrolling and ill take care of them your Majesty!

2 Likes

If your mom isnt bringing lunch down to the basement on time either, you just let me know. Ill straighten that out too!

2 Likes

Sorry to be a pain but would anyone be able to adapt this yaml so that I get the following outputs?

Water Volume in L
Water Level in M
Tank %

captive_portal:

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "INA19 Current"
      id: raw_current
      filters:
        - multiply: 1000  # conversion to mA
      unit_of_measurement: mA
    bus_voltage:
      name: "INA219 Bus Voltage"
    shunt_voltage:
      name: "INA219 Shunt Voltage"
      filters:
        - multiply: 1000  # conversion to mV
      unit_of_measurement: mV
    max_current: 400mA
    update_interval: 10s

  - platform: template
    name: Water gauge
    unit_of_measurement: cm
    accuracy_decimals: 0
    update_interval: 30s
    filters:
      - sliding_window_moving_average:
          window_size: 10
          send_every: 5
    lambda: |-
      auto current = id(raw_current).state;
      return 100 * current / 5;  // Sensor: 4-20 mA, factor 100 to cm convert, range=5m

Would something like this work?

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "INA19 Current"
      id: raw_current
      filters:
        - multiply: 1000  # conversion to mA
      unit_of_measurement: mA
    bus_voltage:
      name: "INA219 Bus Voltage"
    shunt_voltage:
      name: "INA219 Shunt Voltage"
      filters:
        - multiply: 1000  # conversion to mV
      unit_of_measurement: mV
    max_current: 400mA
    update_interval: 10s

  - platform: template
    name: Water gauge
    unit_of_measurement: cm
    accuracy_decimals: 0
    update_interval: 30s
    filters:
      - sliding_window_moving_average:
          window_size: 10
          send_every: 5
      - calibrate_linear:
        - 0.210 -> 0
        - 0.880 -> 1.570
    lambda: |-
      auto current = id(raw_current).state;
      return 100 * current / 5;  // Sensor: 4-20 mA, factor 100 to cm convert, range=5m

  - platform: template
    name: Jojo Tank Volume
    unit_of_measurement: "litres"
    lambda: |-
      return 2 * 3.14159265 * 0.71 * 0.71 * id(raw_current).state * 1000;

  - platform: template
    name: Jojo Tank Percentage
    unit_of_measurement: "%"
    accuracy_decimals: 0
    lambda: |-
      return (id(raw_current).state) / 1.570 * 100;

  - platform: wifi_signal
    name: "Jojo Volume WiFi Signal Sensor"
    update_interval: 60s

switch:
  - platform: restart
    name: tankvolume

Throw-in is my preferred and has been working great since installed Sept 2021.

1 Like

Hey,

Would you mind sharing further insight on what your spreadsheet looks like?
I’ve connected mine up with the INA219 - just need to figure out how to do the calibration bit.

I don’t have it anymore but it was basically following something like this:

https://www.chemistrygeek.com/linear.htm#:~:text=To%20draw%20a%20straight%20line,the%20"Show%20Equation"%20box

Where for me X value (Column A) was the INA219 current and the Y value (Column B) was the measured height. I took multiple measurements as the tank was filling.

You can then use a lambda in ESPHome or adjust the template to spit out a volume (gallons, liters, etc) instead of a height to report in HA.

1 Like

Thanks for the input - just for clarity, your template makes reference to the current. Must I use this or voltage as mentioned in your most recent reply?

template:
  - sensor:
      - name: "Water Tank Level"
        unique_id: "water_tank_level_sensor_inches"
        unit_of_measurement: "inches"
        state: >
          {% set height = ((states('sensor.ina219_current')|float * 5.0663) - 24.86) |round(2) %} #This equation was derived in a spreadsheet based upon actual water height and ina219 current values
          {% if 0.000 <= height <= 72.000 %}
            {{ height }}
          {% else %}
            unknown
          {% endif %}

Current measurement. My mistake.

1 Like

Perfect, thanks for confirming

Oh, you’re one of those types.

Fairly simple question I thought. Sorry to ruin your day.

That may have been a little over the top but, come on you kind of set yourself up for some wise a$$ comment. Maybe It bothers me more than it should but, it just seems like soooo many people on here are just unwilling to do anything. They cant use a search box, look at the docs, read the forums or use the search box here, or even use google. I guess if others dont care then they must not feel like theyre being taken advantage of but, thats how i see it a lot of times. It just aggregates me when it appears someone doesnt want to try but they expect others to answer their questions.

You are well far from the truth, I help numerous people out with HA. I have quite an advanced setup and am very familiar with home automation having done it for 12+ years, starting with openhab and eventually moving to HA. I’ve built many custom integrations with esp devices. Don’t judge someone just because they ask a fairly simple question - basically this thread appears to be THE most popular and detailed when it comes to various people trying various methods to get water tank levels, I am just not interested in reading 500+ posts when someone may just say hey, the best method we found was xyz. I already started reading the first 50 or so posts, was none the wiser.

Well that was kind lf the reason I explained myself. I was in the wrong, i made a snap judgment. Thats fair, this post has been going on forever. I see your point. For whatever its worth. Which one is best I think depends on each person and what kind of access they have to it as well as how accurate they want it to be. There’s a lot of different ways to monitor water level.

1 Like

Think I’ll go with the accuracy of a pressure sensor and use a Shelly uni, as per this fellow kiwis video…

A bit more expensive than an ultrasonic sensor but more reliable. No power at the tank so will build 12V battery and solar pv into the solution

The VL53L4CD was another option but it seems to only have maximum distance of 1.3m

Thats probably a good call. Ive never been a big fan of those ultrasonic sensors and i hear theyre kinda iffy when used on water.

What kind of water tank is this for? Is this like an underground tank? Rain water tank? RV water tank?

5500 litre rainwater tank, emergency backup water, about 2m tall

nice. I have one of these that I collect rain water in. I havn’t really had the desire to track the water level outside of the float switch I put in there to kill the pump if it get’s to low. I started running 1" PVC from it and then underground and it goes to a bank of 5 12v solenoids to water my flower beds and trees. Not trying to show boat, just making the case that you can get crafty with a water tank and do some cool stuff.
Screenshot from 2024-02-20 20-31-18

1 Like

show and tell. my underground tank looks like a submarine … the volume calculations for a cylinder on its side was a bit more complicated than I anticipated…

Our tank is 5,000 gallons (18.927 liters) that our well (bore) pumps into for domestic use.

1 Like