ESPHome water level sensor

Dang! Someone overcompensating for some other undersized component??? I do the same thing ; ) since 2" isnt very impressive… lol

Thats cool. Do you live off the grid or whats the deal with needing that much water holding capacity?

We’re on 40 acres. No city water out here. It’s for 2 homes and all our domestic & homesteading needs at the moment like livestock water, orchard & garden irrigation.

HA for me stands for Homestead Assistant with all the other things I am using it for.

1 Like

That seems smart to me. The less dependent you are on Uncle Sam has to be better. Do you do your own solar or electricity too?

Oh, nice submarine! Looks definitely very similar as my Carat :slight_smile: Are you planning to share some calculations for cooperation?

I am in the middle of building my rain water tank sensor (QD) over RS485 (carat sumbarine) into home assistant. I bought a QD water sensor with RS485 protocol as I want to try this type of communication - and If I am successfull, I will post it here. It is all just training for me for much harder task to monitor bore well water level (30+m deep, 12cm diameter, far from house, 8cm concrete lid, no electricity…)

We have plans for 2 ground mount solar arrays. I’ll definitely be integrating that into HA.

Hello everyone, I need your help with my project.

I am using the “HLK-20M24 AC-DC 220V to 24V” with “INA219” and the “TL-136”. The problem is that I am getting negative values in the current without any changes with the sensor inside or outside of water. I am using the following code in ESPHome:

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "Depósito Current"
      id: watertank_current
      accuracy_decimals: 5
      unit_of_measurement: "mA"
      filters:
        - multiply: 1000 #convert from Amps to mA
      #- median:
      #    window_size: 5
      #    send_every: 5
      #    send_first_at: 3
    power:
      name: "Depósito Power"
      accuracy_decimals: 5
    bus_voltage:
      name: "Depósito Bus Voltage"
      accuracy_decimals: 5
    shunt_voltage:
      name: "Depósito Shunt Voltage"
      accuracy_decimals: 5
    max_voltage: 32.0V
    max_current: 400mA
    update_interval: 5s

This was the problem…

Hello @maple550 sorry I didn’t pick up your reply. Indeed we have the same tank. I can give you full yaml for working out litres. Will post tomorrow

Hello I used lots of templates; the calculation is actually quite complicated for a cylinder on its side plus the volume of the tower bit at the top up to the overflow. Therefore I broke the calculation down into parts, which made it much easier to see where I was going wrong.

Also if you are still setting yours up; it would be worth remeasuring the internal length and diameter. I wasn’t able to get back inside because it was already filled up with water.

There is an automation at the end that switches off the pump if the water level gets below 1,000 litres. My pump is a bit of a pain to reprime when air has got inside.

Please ask questions.

ads1115:
  - address: 0x48
    continuous_mode: on

sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 4.096
    name: "Water Tank Level"
    id: wtd
    resolution:  16 bits
    internal: true
    unit_of_measurement: 'm'
    accuracy_decimals: 6
    icon: "mdi:water-percent"
    update_interval: 1s
    filters:
      - calibrate_linear:
          - 0.028 -> 0
          - 2.275 -> 1.98
#      - delta: 0.3%
      - sliding_window_moving_average:
          window_size: 60
          send_every: 1
#      - lambda: if (x <> 0.05) { return x; } else { return 0; } 


  - platform: template
    name: "Water Tank h1"
    id: h1
    internal: true
    lambda: !lambda |-
      const float h3 = id(wtd).state;
      if (h3 < 1.98) {return h3;} else {return 1.98;};
    accuracy_decimals: 4
    update_interval: 1s

  - platform: template
    name: "Water Tank h2"
    id: h2
    internal: true
    lambda: !lambda |-
      const float h4 = id(wtd).state;
      if (h4 < 1.98) {return 0;} else {return (h4-1.98);};
    accuracy_decimals: 4
    update_interval: 1s

  - platform: template
    name: "Water Tank Volume"
    id: WTF
    unit_of_measurement: 'L'
    icon: 'mdi:water-percent'
    device_class: volume_storage
    state_class: measurement
    lambda: |-
      const float r = 0.99;
      const float l = 2175;
      return (0.331831*id(h2).state)+(((sqrt((2*r*id(h1).state)-powf(id(h1).state,2))*(id(h1).state-r))+(powf(r,2)*(3.141592653-acos((id(h1).state-r)/r))))*l);
    accuracy_decimals: 0
    update_interval: 2s
    on_value_range:
      below: 1000
      then:
        - homeassistant.service:
            service: switch.turnoff
            data:
              entity_id: switch.shelly_watertankpump
2 Likes

I’m going down the path of a QDY30A 0-10V water level sensor from Aliexpress https://www.aliexpress.com/item/1005004607235726.html and a Shelly Uni (gen1) https://www.aliexpress.com/item/1005002821852797.html Both can run on between 12-36VDC which is handy, as I don’t have AC voltage where the tank is so will run off battery and solar PV.

I’ve measured the draw from both water sensor and shelly devices and it ranges from about 12mA to 29mA, (mostly around 13-15 with jumps up to 29). If I take an average of say 20mA at 12.6V then the power requirement is about 1/4 of a watt. I’m looking at a 5000mAh battery on Aliexpress which will mean it should last about 10 days without charge - however tbh, its only NZ$17 more for a 30000mAh battery https://www.aliexpress.com/item/1005004951030650.html so theoretically for stuff all extra cost I could just go overkill and have ability to run for 2 months without charge. Is it really needed though? Just conscious of batteries performing optimally at 80%+ charge.

Solar charger, looking at this (18V module) https://www.aliexpress.com/item/1005005496178546.html
For PV, I have all sorts of small panels floating around

Is anyone running their sensors off battery and can offer any tips or share their experience on what they’ve found?

Chimeranzi
I have a gravity throw in sensor connected to a Shelly uni. It is running off a 12 volt lead acid battery with a small 18v solar panel.
The Shelly uni unfortunately doesn’t have a sleep mode and constant wifi connect sucks power. One of my projects is to put an esp32 with relay inline. The esp would then wake the sensor and shelly only once per day for a period of 5 minutes. This should be enough to provide a stable reading.
At the moment my automation just triggers when readings fall below 11,000 litres - the trigger turns on my pump switch (sonoff basic) for a period of 3 hours. This tops my tank back up to about 20,000 litres.
Has been running without issue now for nearly 8 months. The only issue is that the system runs when enough voltage is availble in the battery. On sunny days this is usually about midday. On cloudy days or rainy (quite often here) the system may not get enough juice to start so there may be a few days where a reading isn’t taken.
I’ll get around to it.
Pat

1 Like

Thanks for the reply. I actually have had all the parts arrive (the links that I posted prior) and wired up and running in my lab, testing it at present. I fully charged the battery and turned it all on at 9:30am this morning (9 hours so far), I’m leaving it to see how long it all runs for until the battery dies (or nearly dies, dont really want to go below 80% DoD to be fair) so am checking voltage daily.

I’d say a “30000mAh lithium battery” from Aliexpress is “marketed up” quite a bit so I’m expecting half that amperage, and if my calculations are correct this should run for 4 weeks without any sunlight. So the 18V 10W Solar panel I have should keep it topped up nicely once it’s installed. I’ve also created a case for it all that I’m 3D printing at present.

Will post photos when its all done.

Your idea on ESP32 and relay is an option and one I saw someone else mention on another post, but TBH I’m trying not to overcomplicate this :slight_smile: A typical lead acid is only about 50% DoD, so you will find a Lithium battery maybe a better option.

Of course, the BEST solution would be if Shelly programmed up a sleep mode for the Uni and released an updated firmware for it…!!!

Can’t you just flash ESPhome on the older model Uni to use the sleep function? The newer Plus Uni is ESP32 based.

Wasn’t aware of that. Will have a look, thanks!

As mentioned earlier, Shelly Uni, 12V Lithium battery and 18V MPPT solar charger in 3D printed case, Uni connected to submersible 0-10V 4-20mA Hydrostatic Level Sensor (currently with 18v DC power supply) but will be using solar PV panel to charge. So far so good, battery lasts ages with DC power off. Ironically waiting for the rain to stop so I can install it :slight_smile:

FYI they make these level sensors now with a 0-3.3V output and powered by 5V. Would be much easier to connect to an ESP.

Select the 3.3V option

1 Like

How are you collecting the data? Using wifi?
Pat

Yeah wifi via the uni. I’m going to have to recalculate my numbers… :frowning: I’ve ordered a 12-24VDC PCB step up converter for starters. Even though both devices are advertised that they can run at between 12-36V, as I’m running off a 12V battery as soon as I get too much under voltage (in the mid 11s at a guess) it drops off. So running at 24V should help heaps (the amperage is super low) Also didn’t account for sensor using 10V at 100% water volume (again low amps, but effects voltage) so that creates an under voltage fairly quick. So to add, as someone suggested above, I’ll be flashing with Tasmota and using esphome plus sleep mode to conserve battery life.

I’ve read through the whole topic and it seems 0-10V are more reliable than 4-20mA. A lot of people reported a drift with 4-20mA.

Is there someone who used both and confirm that I should get 0-10V over 4-20mA?