Thank you for posting this. I’m a bit of a newbie and while I have a level sensor set up and measuring I have tried to compile the sketch you posted but fail.
Can you please tell me how you compiled the sketch.
Can someone help make my formula perfect?
I now have my new/“almostfinal” setup finished (sensor hooked up, tank, pumps, tubing flow sensor & flow limiter all in place.
Maybe someone can help me to make it even better.
so here are my infos:
EX: 8cm (sensor to max water level)
TD: 46 cm (empty bottom of tank)
TC:72 Litres (44cm deep (36cm max water level) by 40cm wide by 50cm long tank)
Minimum water level (so the pump is still submerged): 13 cm
I still get a 1% error and almost 1 litre error (not so bad but not perfect)
this is the empty tank snapshot:
heres my code:
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s
- platform: dht
pin: GPIO 13
model: dht11
temperature:
name: "Temperature_01"
humidity:
name: "Humidity_01"
- platform: ultrasonic
trigger_pin: GPIO 5
echo_pin: GPIO 4
name: 'Water tank Level'
unit_of_measurement: '%'
accuracy_decimals: 1
update_interval: 1s
icon: mdi:water-percent
filters:
- lambda: return ((((x*100)-8)-(46-8))/(46-8))*-100;
- sliding_window_moving_average:
window_size: 10 #creates a moving average of the last 10 values
send_every: 1 #sends the moving average at every measurement (but only if it passes the delta filter below))
send_first_at: 1 #after startup immediately start sending the result rather than wait for the first 10 measurements
- delta : 0.05 #only send the result if the level difference with the last sent result is higher than this
- filter_out: nan
- platform: ultrasonic
trigger_pin: GPIO 5
echo_pin: GPIO 4
update_interval: 2s
name: 'Water Tank Volume'
unit_of_measurement: 'l'
icon: mdi:cup-water
accuracy_decimals: 2
filters:
- lambda: return ((((x*100)-8)-(46-8))/(46-8))*-70;
- sliding_window_moving_average:
window_size: 10 #creates a moving average of the last 10 values
send_every: 1 #sends the moving average at every measurement (but only if it passes the delta filter below))
send_first_at: 1 #after startup immediately start sending the result rather than wait for the first 10 measurements
- delta : 0.05 #only send the result if the level difference with the last sent result is higher than this
- filter_out: nan
Thank you in advance for the help, also i want to give big thanks to everyone in this wonderful community for all the help and learning opportunities!
Thank you very much for nice project. Everything done like described. Everything is working, but… till power-cycle. After power cycle ESP not booting. Only reset (RST–>GND) help to boot again.
my config posted here was working and just stopped out of the blue, now the numbers are all off, and random it seems… connection times out… the whole thing just broke !
So I finally got around to installing this yesterday. I installed sensors on an 800 gal and 400 gal tanks. Here are some pics of my setup.
I also did a sensor calibration at different depths and noticed that as you measure further from the sensor the delta error increases (see table below).
Does anyone know how to apply corrections to output for errors that vary (maybe in lambda function)?
Just in case people in this topic haven’t seen it.
As an alternative you can use a pressure sensor. You just throw it in your water tank so that it drops to the bottom and for me it measures the water depth with a precision of about a millimeter!
Really!!! I cant seem to be able to figure out how to make it work for me!
would you mind sharing that part of your config, i’ve been pulling my on this for days now!
got this model:
I think we’re talking apples and pears.
You are looking for a solution that can measure flow rate.
What I am using is a solution that can measure pressure differences and translate that into water levels (how much water is in the tank).
My code is a bit different, but I’m using a dedicated ADC (costing around $1) because it is much more precise.
Here’s the bit of code I use to get the voltage reading from the ADC:
sensor:
- platform: ads1115
multiplexer: 'A3_GND'
gain: 4.096
id: zwemvijver_voltage
name: "zwemvijver Level Voltage"
icon: 'mdi:swim'
unit_of_measurement: 'V'
update_interval: 1s #the delta filter will ensure it only sends values when something changes.
filters:
- sliding_window_moving_average:
window_size: 10 #creates a moving average of the last 10 values
send_every: 1 #sends the moving average at every measurement (but only if it passes the delta filter below))
send_first_at: 1 #after startup immediately start sending the result rather than wait for the first 10 measurements
- delta : 0.0015 #only send the result if the voltage difference with the last sent result is higher than this
I then have a lot of code to transform that voltage into centimeters, liters, percentage etc but first step for you is to make sure you get the voltage reading from the ADC
I believe I put the rest of my code in the other topic for which I shared the link earlier.
Here’s my set-up. As you can see I have multiple pressure and temperature sensors hooked up to my ESP8266 so it looks rather complex. The ADS1115 is in the upper left corner.
On some of the components you will see some short strands of wire that lead to nowhere? That is because I changed my design many times to get to the final design and I was too lazy to try to remove the wires on these components.
I want to have a backup because i live on the 3rd floor and if theres an overflow or anything i want to be as safe as i can be, plus im curious as how that works.