ESPHome water level sensor

Anyone using this type of sensor in a diesel tank?
I have played with ultrasonic and ToF sensors but no luck. I found this sensor QDY30A on aliexpress.
https://a.aliexpress.com/_ExO1lge
Specs say it is compatible with diesel.
Sellers confirms it. Should get one or forget about and look for other solutions?

I’d imagine it would be fine with diesel since diesel really isn’t very nasty on materials at all.

Agreed diesel should be fine - these are industrial sensors designed for non-corrosive fluids. I do wonder how the ā€œrubberā€ boot and plastic/nylon sheath will survive extended submersion in fluids other than water.

My water tank monitor (ESP32 / 4-20mA TL136 with I > V converter) has been running for over 3yrs now. I’ve had to replace the TL136 drop-in sensor once, with new unit in use over 6 months. This sensor is powered just under 12V DC (11.6V) and has been rock solid. Most sites say 24V DC is required, but the supplied spec sheet says 12V - 36V. [It also says measuring range is 0 - 500m, so don’t believe everything you read!]

A few people have discussed power supply options; I use a recovered DC plug-pack from an old modem with 12VDC 2A output and a buck board to supply the 3.3V and 5V lines. The board was this one:-

which supports 800mA output but I noticed it was running very hot when I added an ESP8266 to the cabinet for some other monitoring, so replaced it with a $5 buck board (https://www.aliexpress.com/item/1005009534551340.html) that supports 2A per rail.

These boards are by far the easiest way to give you the supply lines you need for various MCUs and sensors.

Plenty of rain to test things out recently:

I’ve set tank full at 3.2VDC (ESP32 accepts this) and tank empty at 0.3VDC so I can trigger if the voltage drops below this - such as for a faulty sensor unit.

I will get mine in a week or two. I will probably try to add a diesel resistant hose to protect the cable.

sorry for late reply but i had a 15V power supply lying around im only putting 15vdc thru my transducer its rated 12-32v. its still working just fine almost 3 yrs now.

Hey guys,

I’m transitioning from the unreliable ultrasound sensor to the 4-20mA sensor.

Just need a bit of sanity check

I’ll be using a buck converter to step down 12v to 5v (for ESP32) and since I don’t have a current to voltage converter. I’ll use a 165Ī© resistor

Diagram in my head:

  • 12V+ → sensor RED
  • 12V+ → buck IN+
  • PSU GND → buck IN-
  • Buck OUT+ (5V) → ESP32 5V/VIN
  • Buck OUT- → ESP32 GND
  • PSU GND tied to buck OUT- and resistor bottom (leg connected to GND)
  • Sensor BLACK, resistor top (connected to the sensor’s BLACK wire), and ESP32 ADC pin all joined at the same connection point

Please correct me if I’m wrong and if anyone has a wiring diagram that has buck converter and resistor. That would be great

If your buck converter is not isolated then Buck in (-) and Buck out (-) will be connected.

Thanks mate, are you sure about the resistor sharing the same ground?
Shouldn’t it be between sensor black and ADC?

Yes I’m sure.

The current loop marked in green will generate the voltage shown in blue that the ADC will measure:

Great,

Couple quick questions, Sorry I’m not too savvy when it comes to wiring diagrams

Just wanted to confirm that the GND that goes to sensor, it ties both top and bottom of resistor to the sensor black?

Also, the ground to buck, is that connected to in our out GND, or both?

No. That is not what is shown at all. One end of the resistor goes to ground, the other end goes to the A0 input and the 4-20mA sensor output.

And I have no idea what you mean by ā€œsensor blackā€.

For ease of use I would just buy a Shelly uni. Both it and the 4-20mA sensor will run on the saem voltage and you just join cables. flawless for me for 18 months now

Would you mind sharing your circuit and describing the power supply? I use a 4-20mA sensor and a Shelli Uni too but have a heck of a time with noisy result signal. When my house A/C starts up the signal spikes. I have tried many things in the electronics like RC filters etc as well as trying to filter out ā€œimpossible water level changesā€ in Home assistant. I’ve tried a few different 18-24v laptop power supplies, always noisy. If I run it on battery I get clean no data. Using the power supplies connected to house mains I can even detect my electric kettle in the (noisy) data! With no heavy use appliances running in the house the data is stable (within 1%).
Many thanks.
Julian

Julian
Power supply is a meanwell 24v. This power supply is in a shed away from any large house voltage usage. I send that voltage through app 35m of cat6 underground cable (cable rated for underground use). I have an external antennae out of a junction box mounted on a pole near my tank (this is a header tank about 30m up the hill). The junction box does not receive direct sun - shaded by a solar panel used for something else. The box also has some moisture pads in there for those steamy days. The vent pipe for atmosphere also is in this box.
My uni capably connects to an external Unifi AP located about 30m away - at the house.
I am curious - in your code you do have some broad filters and averaging?

Thanks for the reply Patrick
Yes I have tried various methods for smoothing but the real electrical spikes in the data are sometimes hard to filter from real rainfall events.

Here is an example of a few days with a full tank, steadily dropping as we use water, and a single rainfall event in the middle. The left side should have no rises at all except for the rainfall event. The 4 large spikes are my AC heatpump coming on at 8pm.

The more smoothing I add the less accurate the output in a real rainfall or usage event - must wait for the display level to catch up to reality.

The Shelly and the power supply are in a plastic box at the tank about 10m from the house and AC units. Since I can see other appliances in the house spiking the data and physical shields haven’t helped I think the noise is over the electrical cables not the air. I see no atmospheric pressure or temperature signals in the 4-20mA tank pressure signal.

The tank level display is very useful to us on a daily basis - just would be good to tweak it that final bit so that we don’t see ā€œimpossibleā€ changes in level. I know, it’s only bouncing around about 1-3% once the huge spikes are removed. Maybe I should not be so fussy. Was just curious what others observe. My thoughts are that I really need to address the smoothness of the actual power supply. Maybe sometime! Cheers.

Do you have a capacitor across the 150 ohm load resistor to filter out noise?

1 Like

Yes, I have experimented quite a bit in that area. My power supply is 19.5v.
My lowest noise scenario I achieved is when the load resistor is 765 ohms and I put an RC between that and the adc input. The RC details are R=10k, C = 10uF and 47nF.

All of those values have been varied around a lot for testing. My sensor has a 5m range and I only need 2.5m for the tank level so I lose some resolution there. The 765 ohm load resister gives me the widest voltage range for the levels the tank can be at. It is no more stable when the load resistor is smaller.

When running on an 18v battery the circuit fluctuates only 0.02%. If that has a charger connected then the >1% fluctuation reappears.

Thanks for your input.

I wonder what the power supply internal to the Shelly is like - maybe it has an internal power supply that converts directly to 3.3V rather than to 5V followed by an LDO. Spikes on the power supply to the ESP32 will affect the ADC readings.

I agree. It is confusing though that I’ve seen multiple recommendations for using Shelly Uni with the 4-20mA pressure sensor. Presumably those who recommend it don’t see the fluctuations that I do.

Use a real good power supply like meanwell. Don’t have it near the uni otherwise some electro/radio interference is likely.

2 Likes