ESPHome water level sensor

See the note on the esphome page:

Not sure your specific application, but for me height was easy. When installed and tank full whatever the reading is was the height.

Ah yep. Thanks.
I’m struggling with height because I won’t be able to know what the reading at full height is until it’s bucketing down with rain and I can go out and confirm the tanks are full.
The formula on the dfrobot page doesn’t seem to yield any results either.

This is the formula I think I need to use, just need to search back in my brain how to solve for x given the mA reading

Linear mA out = 4 + (16 x ((Rdg – Low Limit) / (High Limit – Low Limit)))

Linear mA out = 4 + (16 x (((X/120*1000) – 0) / (5000 – 0)))

Hi
Sorry I really am a newby to this. Do you hav se photos of your setup please? I need the same system.

As an FYI, I’ve come This ultrasonic sensor with a stand off

My DF Robot sensor arrived, but I missed the part about 24V PSU, so will need to wait until next weekend to have it working. The ESPHome setup looks easy, and I will add this to an existing device. My goal is to tell if the water level for my pond pump is getting low, which normally means the filters need cleaning, but can mean the pond is getting low. Either needs me to fix it, and I should be able to tell them apart.

My data is extremely sporadic.
Edit: I’m using the DFrobot sensor
This is readings from the last 2 days. It’s set at 10min intervals which is much more frequent than required the graph on top overlays the voltage recorded from the sensor with a pressure reading from another sensor to see if there’s any correlation.
The bottom graph has the volume calculation from voltage, and then a filtered voltage. The water level seems to rise through out the day, could be from increase in temps through the day but we are using water during the day as well.
The data that comes with the sensor didn’t work for me and the min/max current voltage readings must not be linear because no calculations I did worked until I took a reading from the bottom of the tank, and then at the top of the water and made a linear equation. I’m still waiting for enough rain for my tanks to be full to get a max voltage reading and redo the formulas. Overall it’s more reliable than an ultrasonic but I’m not really happy with it, I might try a cheaper version that doesn’t account for adjustments in atmospheric pressure.


I can’t get it right, can someone help me with this, please
I have an IBC tank 1050l 120cm high with the sensor at the top of the tank. Full tank 1000l = 110cm that gave me only 10 cm gap to the sensor, The minimum distance for the sensor to take any read is 20 cm +/- 950l, how to calculate water level with smaller than required sensor distance?

@teich could the sensor you got be powered by only exactly 24 volts?

The reason I ask is the listing for the product linked to now says Operating Voltage: 12-36V.

No idea - I’d trust the specs on the website. I happened to have a 24v power supply lying around. Didn’t try or look to closely for anything else.

@teich Does it say in the documentation how much power this sensor uses? Or did you happen to measure it?

I am guessing you have power near your water tank as you say you used a 24V POE injector power supply. I am not sure I will have what in my setup. Or did you run a network cable out to the water tank to supply the power. That might be easier than running an AC line.

I am looking at a board that can adjust the input voltage up or down to use with this sensor and an ESP8266. That way I could get both voltages from one supply.

Also do you know if the sensor is power all the time or only when a reading is taken?

Just trying to see if it is feasible to run this on a battery and what kind of battery life can be expected vs. the number of readings taken.

@MrJelly17 I have seen others add a pipe on top of the tank to house the ultrasonic sensor and get the require minimum sensor distance. If you are not using an ultrasonic sensor but a pressure sensor then that should be at the bottom of the tank or attached to the bottom to get correct reading.

The sensor is always powered as it’s in a seperate power supply (24v) it’s the esp that determines when the reading is taken. This has no affect on the power supply to the sensor

I have been using waterproof ultrasound meter for my sewage tank and with winter coming the condensated water on the sensor made measures practically useless :frowning:
So after reading this thread I have order pressure sensor with hope that this will fix my solution.
FYI, I have order this one:

1 Like

I ordered the sensor and am getting it setup, just waiting for a 24v power supply. I just want to know what percent full my tank is (I don’t need any volume measurements).

Is it legitimate to measure the voltage of the sensor when the tank is full and again when empty? Would that give me two values I could use to create a floor and a ceiling with?

Yes, that’s spot on. What I did was pull the sensor all the way up till it was ~2 feet into my tank, since that’s what I would consider ‘empty’ and measured that value vs actually having my tank be empty.

@hummingbear which sensor did you order? But yes that will work perfectly. If all you need is percentage.
Since mine was installed months ago we’ve not had enough rain in one lot to fill the tanks so I’m still waiting on my full measurement to recalibrate. I’m using a linear equation to get water height above sensor, so I can work out volume.
But for percentage only the to measurements will be fine

I ordered this sensor that @teich posted higher up in this thread.

I’m in an interesting bind as I’ll be running this completely off battery, so I’ll have the sensor behind a relay that only turns on when the ESP8266 wakes from deep sleep. I’m curious to see how much power it all draws and how long it will last.

For anyone who is curious I’m using this relay with my ESP8266 and the sensor I linked above. Below is my ESPHome config

substitutions:
  <<: !include secrets.yaml

esphome:
  name: testwatertanksensor
  platform: ESP8266
  board: nodemcuv2
  # Send power to sensor by enabling relay on boot
  on_boot:
    then:
      - output.turn_on: water_sensor_power
      - delay: 5s

# Enable logging, api, ota, captive_portal
logger:
api:
ota:
captive_portal:

# wifi settings
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pw

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Testwatertanksensor"
    password: !secret ap_pw

# mqtt settings
mqtt:
  broker: 192.168.0.247
  username: !secret mqtt_un
  password: !secret mqtt_pw
  discovery: True

# Deep sleept
deep_sleep:
  run_duration: 90s
  sleep_duration: 300s

# Set relay as output component
output:
  - platform: gpio
    pin: 13
    inverted: True
    id: water_sensor_power

sensor:
  - platform: adc
    pin: A0
    id: "waterTankSensorVoltage"
    name: "Water Tank Sensor Voltage"
    icon: "mdi:water-percent"
    filters:
    - multiply: 3.3
    - median:
        send_first_at: 3
1 Like

Humingbear,
this is one of those projects in my half completed list. I am keen to see yur wiring in relation to battery running.
Patraff

Just an update as today I have received my sensor and did testing with 70cm pipe full of water. Positively surprised from results!
I was moving sensor down the pipe full of water and each 10cm down I was measuring the current. My measurement were less then 3% different from the calculated current (based on the water level). I am almost sure that those differences are related to the way I was done my measurement (not very precise). What is nice is that at the bottom of my pipe (70cm) the current was 6,24 mA which 100% equal to 70cm depth from data sheet.
Next steps is to make power and configuration on ESP and putting sensor to my tank. :slight_smile:

1 Like

Just waiting for a few parts in the mail, I’ll post photos of my setup once I have it going!