Convert voltage output to percent

Hi,

I have a water level sensor successfully sending me a signal as a voltage. Its between 2.32v (empty) and 3.46v (full).

My question is: How to i convert that to a percentage?

Use the calibrate linear filter:

https://esphome.io/components/sensor/index.html#calibrate-linear

filters:
  - calibrate_linear:
      # Map 0.0 (from sensor) to 0.0 (true value)
      - 2.32 -> 0.0
      - 3.46 -> 100
1 Like

thank you kind sir.

interesting. it’s sending back negative outputs.

[15:34:51][D][sensor:127]: 'Homestead Reserve Watertank Level': Sending state -111.31579 V with 0 decimals of accuracy
[15:35:01][D][sensor:127]: 'Homestead Reserve Watertank Level': Sending state -111.31579 V with 0 decimals of accuracy

removing all filters has shown another issue. looks like my sensor is faulty.

the issue was i did not have the attenuation set as it needs to be to ‘auto’ on the ESP32 device.

 - platform: adc
    pin: A4
    name: "reserve tank water level"
    update_interval: 15s
    attenuation: auto
    filters:
    - median:
        window_size: 15
        send_every: 15
        send_first_at: 15