Using LED's to indicate the water level % of my water tank

Hi guys,

I’m hoping that someone can assist me here.

I currently have a drop in water tank pressure sensor in our outdoor water tank - this is working great. I’m using the following code for this:

captive_portal:

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

ads1115:
 address: 0x48
 i2c_id: bus_a
 continuous_mode: off
       
sensor:
- name: Jojo Tank Height
  id: tank_height
  platform: ads1115
  multiplexer: 'A0_GND'
  update_interval: 60s
  gain: 4.096
  unit_of_measurement: "metres"
  icon: "mdi:gauge"
#  accuracy_decimals: 3
  
  filters:

  - median:
     window_size: 200
     send_every: 10
     send_first_at: 4    


  - calibrate_linear:

    - 0.480 -> 0
    - 1.0232 -> 1.545
       
- platform: template
  name: Jojo Tank Volume
  unit_of_measurement: "litres"
  lambda: |-
    return 3.14159265 * 0.71 * 0.71 * id(tank_height).state * 1000;

- platform: template
  name: Jojo Tank Percentage
  id: tank_percentage
  unit_of_measurement: "%"
  accuracy_decimals: 0
  lambda: |-
    return (id(tank_height).state) / 1.545 * 100;
  

- platform: wifi_signal
  name: "Jojo Volume WiFi Signal Sensor"
  update_interval: 60s

I’d like to add another ESP8266/ESP32 to live in our kitchen, connected to a LED bar (containing 10 LED’s) with each LED representing 0%, 10% 20%… all the way up to 100% - basically 1 bar per 10% to visually display the water percentage in the tank.

Here is the LED bar that I have on order: LED Bar

Is anyone able to kindly assist me with a basic code to make this happen?

Not quite answering your question, but might get you started.

I think you could do it with on_value_range.

You would have about 10 thresholds and you’d turn on/off the relevant led lights.

Structure might be a bit similar to the example.

Thanks so much for the info.

I’ll try have a look this weekend.

Appreciate your input :slight_smile:

Hi,
I am also setting up a drop in sensor for my oil tank.

Can you help me at all in your calculation, where you put your tank size in?

return 2 * 3.14159265 * 0.71 * 0.71 * id(tank_height).state * 1000;

My tank is a vertical cylinder 1.2m diameter

Is it the 0.71 ?

Cheers,
Will