ESPHome water level sensor

I know this was posted a long time ago but if you didn’t solve the problem, consider this: The ADC on 8266 devices is referenced to the supply voltage to the module. If this voltage is not regulated, then your readings will vary with variations of the supply voltage. I use inexpensive DC-DC converters based on the LM2596 chip to apply a very stable 5V supply to the 8266 device (in my case nodemcu or wemos D1.) I found this particularly useful for soil moisture sensors, but would be equally as useful in your application.

1 Like

Hi @rusty_away could that also possibly explain the drift I was seeing with temperature? Because the reference voltage from the power supply is varying with ambient temperature? I have ordered a LM2596 chip and will give it a try. Also do you know is the esp32 is less prone to drift as compared to esp8266?

Hi
Could you please add some photos on how you connected the Uni? Also, what did you do with the grd sensor on the uni? I am not getting reliable readings.

My understanding is that the ADC in an esp32 is actually less stable than the 8266. Yes, temperature may affect power regulation. Good luck with the lm2596.

I could use one of those

I am going to make. sensor for a 2500 L Diesel Tank for home heating, It is 1.5-1.8 meeter tall, 0.8 meeter wide.
What would you guys recommend, I have read a lot of inconsistencies with ultrasonic modules, and in a tank that is so narrow and so tall, I feel that I would get beams from the walls,
I was thinking on the submerged prove solution, though submerging the wire in diesel I dont know if that would kill either the sensor itself or the cable rubber (in 5 years time)
Also I am concerned about safety, flowing current through a fire hazard as Diesel is not a good option I guess (Gasoline would be worst I know)

So what options do you recommend? I currently have an analogical gauge made from a rope and a weight that floats, suspended from the top of the tank.

A sensor like this one should work.

Per the listing: This Transmitter Sensor has widely applications ,which works for oil, fuel, diesel, gas, water, air pressure, can be used in oil tank, gas tank, diesel tank etc

Though you may want to find one that has a lower PSI (like 5 PSI) rating since the tank only has a 1.8 meter height = 2.6 PSI and would probably give you better resolution.

I’m trying to set up something the same as this, getting stuck where I think I’ve got the right pins, and I’m occasionally getting readings, they’re just not sensible readings.

For a solid surface about 1.8m away I get:

[17:40:55][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:40:55][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.18865 cm with 6 decimals of accuracy
[17:40:55][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:40:55][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.44590 cm with 6 decimals of accuracy
[17:40:56][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:56][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:57][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:57][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:58][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:58][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:40:59][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:40:59][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.18865 cm with 6 decimals of accuracy
[17:40:59][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:40:59][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.44590 cm with 6 decimals of accuracy
[17:41:00][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:00][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:01][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:01][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:02][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:02][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:03][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:03][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:04][D][ultrasonic.sensor:036]: 'Tank Depth Sensor' - Distance measurement timed out!
[17:41:04][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:41:04][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.18865 cm with 6 decimals of accuracy
[17:41:05][D][ultrasonic.sensor:040]: 'Tank Depth Sensor' - Got distance: 0.00 m
[17:41:05][D][sensor:113]: 'Tank Depth Sensor': Sending state 0.42875 cm with 6 decimals of accuracy

This is the relevant part of the yaml config

esphome:
  name: tank
  platform: ESP8266
  board: d1_mini
sensor:
  - platform: ultrasonic
    trigger_pin: D6
    echo_pin: D7
    name: "Tank Depth Sensor"
    update_interval: 0.5s
    timeout: 6.0m
    pulse_time: 20us
    accuracy_decimals: 6
    unit_of_measurement: 'cm'
    filters:
     - filter_out: nan
     - multiply: 10000

Unless i’m not understanding the maths this should still get me the distance, and then I can update it to the volume and percentage once the distance is working reliably? But what’s it giving me if not the distance

Can’t see anything obviously wrong. You could set timeout down to 4m, the sensors probably won’t work to 6m anyway. Does increasing the update_interval help?

I’ve already replaced my waterproof sensors twice in three months. The new ones work reliably for a few weeks then start playing up. I’ve found the black paint on two of them developed a lot of small blisters on the front face (after a month or so atop the tank), whether this is cosmetic or causing the problem I don’t know.

After a few months of messing around with ultrasonics for water level measurement, with lots of unreliability and unexplained periods of hours/days with consistent timeouts and no readings, I’ve ordered a liquid pressure sensor and will try swapping to this in a few weeks.

1 Like

Did the same. I never had any problem with the ultrasonic sensor delaminating or otherwise degrading, but condensation affected it very badly, as did rain! When it rained the ripple from the water coming in to the tank really messed with the sensor. I couldn’t reliably set up any automations with it as it was.

In the end I ordered a throw-in pressure sensor. It works a treat and is millimetre accurate. I am so impressed that I ordered another four so that I have one in each of my tanks.

give a link to the sensor

This is the sensor. You should be able to source it in whichever country you live. In my case this was one of those rare occasions where I could buy the sensor from a “bricks and mortar” supplier in Australia and a better price than the Chines version (which was 304 stainless steel, not 316 as this unit is.)

Throw-in water pressure sensor

2 Likes

Instad of using the current to voltage converter board, why don´t you use just a simple resistor in series? With a 165 Ohm resistor, at a current of 20mA it returns 3,3 Volts over the resistor.

After toiling away with the ultrasonic, I’m going to bin it for a drop-in sensor… There’s too many variables with the ultrasonics that it’s not a solution I’d rely on!

@rusty_away if you wouldn’t mind mocking up a wiring / components diagram? Just curious what DC/DC converter you’re using.

Hi Gerhard. The I to V board comes with the kit anyway.

Are you looking for something like this? ESPHome water level sensor - #176 by quizzical

Hi jmjm

Here is the simplest way to do it. You can flash the nodemcu with tasmota or ESPHome, or write an arduino sketch if you are so inclined. In my case, I use an ADS1115 A to D converter just because it is more stable and accurate than using the analog pin on the nodemcu, which tends to have fluctuating readings if the supply voltage is not rock solid. I probably don’t need to because the LM 2596 DC-DC converter is pretty good.

To insert the ADS1115, wire Vin +ve and -ve of the ADS1115 to the 5.2VDC supply of the LM2596, connect the analog output of the current to voltage converter module to the A0 pin on the Ads1115, connect the SCL of the ADS1115 to D1 of the nodemcu, connect SDA of the ADS1115 to D2 of the nodemcu and finally, connect the ADDR (Address line) of the ADS1115 to ground (-ve) of the 5.2VDC output of the LM2596. Use tasmota-sensors.bin or the code (below) for ESPHome (after doing the preliminary config.)

i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

ads1115:
- address: 0x48
  i2c_id: bus_a

sensor:
- name: "Your Tank Name"
  platform: ads1115
  multiplexer: 'A0_GND'
  update_interval: 60s
  gain: 4.096
  unit_of_measurement: "V"
  icon: "mdi:gauge"
  accuracy_decimals: 3
  
  filters:
  - median:
      window_size: 7
      send_every: 4
      send_first_at: 3

Cheers

Rusty

12 Likes

You’re a legend @rusty_away - cheers.

which store was this?

surprise no one has made a plug and play version of this throw in sensor

Hi Britespark,

can you please post your working code for JSN-SR20 with Wemos D1 Mini?
If you have more infos regarding your setup or documented it somewhere it would be fine if you share it also :slight_smile:
I also ordered a JSN-SR20 and will test it in my water tank.

Thanks