Water Level using 3 sensors

Hello… Looking for help on how to make this work,

i have a water tank, i used a Esp8266 with 3 XKC Y25 sensor

the 3 sensors are working has expected, Wet / Dry

i am looking to take advantage of the dual status and merge the 3 sensors to get more level

Exemple : Sensor 1 Wet = 100 %
Sensor 1 Dry = 80 %
Sensor 2 Wet= 60 %
Sensor 2 Dry = 40 %
Sensor 3 Wet = 20 %
Sensor 3 Dry = 0 %

captive_portal:
web_server:
port: 80

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO16
    mode:
    input: true
    pulldown: true
    device_class: moisture
    name: “Liquid Sensor 16”

  • platform: gpio
    pin:
    number: GPIO02
    inverted: true
    mode: INPUT_PULLUP
    device_class: moisture
    name: “Liquid Sensor 02”

That is an incomplete logic table.

SW3 SW2 SW1 Vol
x x 1 100
x x 0 80
x 1 x 60
x 0 x 40
1 x x 20
0 x x 0

1 = wet
0 = dry
x = unknown

Please fill in the unknowns.

since there are only three sensors that are at increasing heights the table is easy (and does not support the requirements)

L3 L2 L1 Level
0 0 0 0%
0 0 1 20%
0 1 1 50%
1 1 1 80%
SW3 SW2 SW1 Vol VOLUME
x DRY DRY 100
x DRY DRY 80
DRY DRY DRY 60 100
WET DRY DRY 40 75
WET WET DRY 20 50
WET WET WET 0 25

So Only 4 level are possible ?

SW3 SW2 SW1 Vol VOLUME
x DRY DRY 100
x DRY DRY 80
DRY DRY DRY 60 100
WET DRY DRY 40 75
WET WET DRY 20 50
WET WET WET 0 25

So Only 4 level are possible ?

Before delving into the code, it can be helpful for me to start with the physical design.

Imagine a 100m tall tank with sensors placed at 25m, 50m, and 75m (let’s call the lowest sensor #1, and the highest #3).

The knowledge you have about the level of fluid in the tank based on the sensor readings is:

All sensors dry: less than 25m
Sensor 1 wet, others dry: above 25m, below 50m
Sensors 1 & 2 wet, sensor 3 dry: above 50m, below 75m
All sensors wet: above 75m

Depending on what you will do with this information will dictate your algorithm. For instance if you just want a description of the tank level, you could translate “all sensors dry” into “less than 25m” or “less than 25%”.

If you need to know when the tank is truly full and fully empty, you would need to add a sensor at the bottom and another at the top.

1 Like

tks for your reply… the goal is to know the level of water in the motorhome…This information will help me to plan the next refilled .Having a % is good.

It all depends on how accurately you need the level percentage and how much you are willing to spend to achieve this result.

I have a gray water tank in the basement with a sump pump in it. I never cared about the level, until the pump stopped working.

I put a ToF sensor in there, because it is cool, but I guess I didn’t look at it enough (and didn’t get an alert set up). I finally replaced the float switch and things are much better. I also put a level sensor about where the float turns on and below where the tank overflows that turns on a buzzer. That works well for me.

Figure out what you really need/want first.

I had a similar challenge with a cistern. I had two sensors which were “empty” and “full” I finally bit the bullet and bought a water level sensor (get 0-190Ω). If your tank is 325mm it cost USD$16.38. ESP8266, power for it, and a 480Ω resistor. Select one that is the right depth for your tank and you’ll have 1024 levels (not really, as the ADC is a little noisy, and the resistor has tolerance, so 200 levels? :wink: )

Let me know if you need more details.

OSD