analog sensor formula

is there any formula to show the gasoline level in liters?, my sensor is 0 - 5v
0v is empty
5v full
tank capacity varies

Joystick4 years ago

Below formula worked for me
If for example your tank takes 400l
Use below formula
(Tank capacity / Sensor input range) * Sensor input value
(400 / 5) * Sensor input value
80 * Sensor input value

Therefor 80 * 5=400 (full tank), 80 * 2.5=200 (half tank) 80 * 0=0 (empty)
Hope it helps