Recent project that a combination of HA and ESPHome made much easier than I expected. Central heating is oil fired - and our tank has no sight tube. When installed it did have a remote level sensor, but the batteries in the sender died a while back and I hadn’t got round to replacing them - and the inside element was a rather bulky ugly plug.
Time for a proper sensor…a waterproof SR04 compatible sensor TE501 , a D1 mini and a 7 Neopixel disc (left over from previous projects) makes a compact oil level sensor.
SR04 was mounted in the filler cap with plenty of hot glue to seal. D1Mini (powered by an old USB charger) and the Neopixels are in a water proof box on the adjacent garage. The neopixels are bright enough to shine through without a problem. I added a DS1820 temp sensor because why not.
The d1mini converts the distance to a % - I dont allow for the odd shape of the tank just a simple % of distance to empty and luckily that is more or less exactly 25cm to 125cm for this tank so its very simple.
HA converts the % fill to an “OK”/“Alert”/“Critical” badge and turns on the light/sets color when it changes status via NodeRed. The light is also turned for a few minutes when the door/gate adjacent is opened as a reminder of current state.
Yes you need the little board. That’s then just 4 pins to the D1mini 5v,Ground, echo and trigger. The latter go straight to a pair of GPIO and you just tell ESPhome which 2 pins you’ve used.
Thanks for posting, this is what i am looking to build for a watertank… (just without the light).
I have only recently been introduced to ESPHome (have a lot of components running MQTT), and would like to build your solution. Could i please ask for your guidance and assistance which others could potentially benefit from as well.
I can work out how to get esphome onto the D1Mini (youtube is a lot of help here), and i am guessing the Template Sensor will slot into my configuration.yaml file. Is this all the config which is needed?
Could you please post a schematic of your wiring and the components you used, as i can see what look like two resistors on the breadboard which i need help with.
Many thanks for this @DeanoX! Managed to get it incorporated into Home Assistant without the LED light with no issues apart from a few niggling things - Now I can rest assured that we will never run out of Oil for Heating and Hot Water!
The Oil Tank level graph always shows a value of 0 which is I think what it uses for the OK/Warning, is there a way for this to show the percentage graph which clicking on the Oil Tank Level indicator? Funnily enough in the History state, it does show the oil level in percentage.
I just need to wire in the thermometer, didn’t have the required resistor to wire that in, so just awaiting that arriving and it will be fully commissioned.
In the “lambda” calculation, 2.03 (and 1.78) is the height of my water tanks in meters. 0.23m is the distance between the highest water level and the sensor. From there i calculate roughly the % full right in the NodeMCU.
I have had this on for a few months now and it’s been doing its job. One sensor failed (looked rusted a bit) a few weeks back and i have had to replace it…If this happens too often i will look at the suggestion above to replace them with the TE 501 (thanks for the tip !)
why don’t you calibrate the measured distance of the sensor since you have installed also a temp sensor? SR04 always assumes speed of sound to be 340m/s and calculates range with time * Speed / 2
Did something similar but i haven’t installed yet a temp sensor in the tank… I use for now exterior temp from weather sensor:
measured SR04T distance:
{{states(‘sensor.ch_oil_sr04_distance’) }}
Hi, I tried to use your formula to calculate the level, but the problem is if the level falls to the bottom, then it still shows + - 5%. I have different dimensions but the principle is the same (1.43-x + 0.08) /1.43x100.
If the level is full (1.43-0,08 + 0,08) /1.43x100, it is beautiful 100% but if it falls to the bottom (1.43-1.43 + 0,08) /1.43x100 the result is 5,594% which is wrong . I haven’t improved the formula, but can you look at it? Thanks
Hi @Jiri_Stransky : let me understand your case -
Your sensor is placed 0.08 over the maximum level of liquid?
The Maximum level of liquid is 1.43 between zero and full ?
If that is the case, then if the liquid goes to zero, the sensor will measure a distance of 1.43+0.08 or 1.51…right ? So (1.43-x+0.08)/ 1.43*100 becomes (1.43-1.51+0.08) and that is zero…
My sensor is located 0.08 above the maximum level. 1.43 is the height where the sensor is located, so the maximum level is 1.43 - 0.08. So I probably didn’t understand in the description that this number is the height of your water tanks. I understood it as the height of your tank. So it’s the height of your water column.
I just tried this formula as you described it and it works. So thank you.
Otherwise one person from the Internet advised me one more elegant solution and that use this filter, which calculates everything automatically.
filters:
- calibrate_linear:
- 0 -> 0
- 6 -> 4000
And then another came up with this formula: value_template: '{{(1 - ((value_json ["SR04")] "Float-8) / 143)) | multiply (100) round (0)}} '
It may be useful. Otherwise, for example, I’m still sending my code, where I converted everything into liters and for sure I measure the level in cm oil and the distance of the sensor to the surface.
Still going strong - been through a couple of cycles of tank fill/empty. I wish it was a better / more steady reading as it can fluctuate. But haven’t got round to improving the smoothing yet.
I have it working, but readings go from 1.2m to 1.02m in height. with results in 38% to 51% in the readings.
Anyway to do an average sensor or something like that?
How do you calibrate the screw on the ultrasound PCB?
any other thing to improve readings?
In my case it is just inaccurate by seconds, trying to use the “filter” sensor to clean it up… but havnt quite got into the filtering part with success :S