ESPHome water level sensor

I used on of those pressure transducers (5v, 5psi) to measure my 1.8m hight water tank level, connected to a Wemos D1 mini running ESPHome. Very simple to set up as a voltage sensor as the transducer simply outputs a voltage proportional to the pressure. However I’m finding it is not consistent, and varies by >30% all the time. I’m not sure why but maybe the supply voltage is not stable enough, or perhaps the influence of atmospheric pressure. Has anybody managed to get it working accurately?

I’d imagine that the atmospheric pressure is your issue. This is why when we use pressure transmitters to determine level in cases like this we (in industrial applications etc.) use pressure transmitters which give a value relative to atmospheric, so the output is automatically compensated.

I have this sensor hooked up to a 8266. Works perfectly with a 3,000 gallon 8 ft tall tank. Basically rock solid

2 Likes

Hi @teich, how did you connect it? And can you share the esphome config?

I read on the page:
We sold this product together with our Gravity: Analog Current to Voltage Converter. The converter can convert current into voltage signal which can be read…

Didi you do this? Or hook it up to 8266 directly?

There is literally a connection diagram on the page!

I know, but that’s not the question. It is WRT this item: https://www.dfrobot.com/product-1863.html
and if you do need that converter yes or no.

You do need that (or a similar conversion circuit, which can be done with a couple of resistors) because your ESP cannot read current directly, only voltage

The DFRobot website isn’t 100% clear - the throw in liquid level transmitter comes with the current to voltage converter. Click on the ‘shipping list’ on the right side of the page.

The ESPHome code couldn’t be easier. Here is my config

One note on wiring - you need both a 24V power supply (for the sensor) and a 3.3/5V supply (for the ESP). You could of course step down the 24V or up the 3.3. In my case I just used an old POE injector lying around and a USB for the ESP.

1 Like

Here is a what the last 4 days of data from the sensor looks like.
I’ve had it installed for a month now, but only setup Influx/Grafana last week to capture longer term data.

I’m keen on using a pressure sensor due to the unreliability of an ultra sonic. Should I get one with an amp 4-20ma output or 0.5-5v output.
Will the specific sensor determine the calculation I need to apply for the output reading?

I hope it comes back into stock, that looks very easy. In my case when the water level drops I need to go change the filter.

Looks like it’s in stock right this second.

1 Like

I tried the Grove Water Level Sensor, and it is completely unreliable with ESPs, so i am throwing them in the garbage bin and trying the sound option.

What a bummer, it looked so good on paper and on demo videos. Thanks for the info.

That is why i went for it, it looks sort of professional and the code seems to be straight forward … Only i tried 2 of them and multiple ESP32s/8266s, I couldn’t get any of them reliable enough (was zero or a ghost number).

@teich
Have you just used template sensors to get other values? Percentage, volume etc?
I’d be keen on seeing those formulae if you’re happy to share trying to work out what I need from the arduino code on the product wiki and I’m not quite getting there
For water depth, if sensor on the bottom of tank:
Depth(mm)= ((X/120)-4 ) x (5000/16)

  • not sure where the 16 comes from though

My dfrobot pressure sensor has just arrived so will hopefully get something assembled today

I take the voltage as the only ESP sensor, and then translate into percentage in Home Assistant.. the numbers came from measurmemnts - I held the sensor at surface level and then when tank was full looked at voltage.

Ah ok, I’m going to apply a different approach I think. I’d like to know how many litres, as well as a percentage.
I’ll use either the voltage or convert back to current to determine the height of the water and then use that measurement to calculate litres; Few different options for percentage I’ll try a few different ways and see what the simplest is.
Mines going to be used to determine water level in 2 x 5000gal water tanks that supply all the water to my house

Once you know the height of the water, conversion to litres, percentage, kilograms, whatever is simplicity itself. I assume a regular shaped tank, but even something irregular is still integrable.

yep, its getting the height of the water that will take me the most time, from there the calcs are easy
@teich how come you multiply the output voltage by 3.3?