Fuel level sensor - ESPhome - voltage divider

Hi all,

So i have a variable resistor fuel sensor that ranges from 0-190ohm. I want to be able to read the output inside home assistant and convert it to a percentage/volume. I have a voltage divider setup however im getting really low voltage 0.00v to 0.04v. im using a 4.7kohm resistor as i dont have any others kicking about. do i need a smaller resistor or is there another way?

You probably need something else.
The values seems to be correct using https://ohmslawcalculator.com/voltage-divider-calculator

470 ohm seems to give you a good range

and at 10 ohm you get 0.069 volt.

Thanks i have oreder some 470ohm resistors can you advise the best way to transform that voltage into a percentage/volume?

You should have bought a box of all sizes.
You will need them.

You just need to read the voltage using ADC. https://esphome.io/components/sensor/adc.html

Just realised i can use

filters:
  - multiply: 24

to give me a voltage range between 0-1v is there any reason why i cant do it this way/should use a different resistor?

You could. But it will be equivalent to doing digital zoom on an image.
Your data won’t be better and you will probably not get any good data.

The ADC can only sense in a certain resolution and most likely all your values will be in the very lowest range so you will get very few steps.
What you want is your native voltage to span as much as possible of the readable range.

So using 470 Ohm you go from 0.069 volt (I notice I wrote Ohm in the previous post) to 0.95 volt. That should give you good readings.

i have trialled it with the multiply and it is accurate enough for my use. not sure how to convert to percentage so i ve used calibrate linear to change the numbers seems to work bit janky but hey

You can add unit_of_measurement: "%"
You could also multiply by the total volume of tank to get actual gallons. However without using the correct resistor the value will likely bounce up and down. You should really consider changing it.

1 Like

If the value you get is in voltage then (1-value)/1*100.
That should give you the percentage.

But it depends on how you think of the value.
Is 0.7 volt 70% or 30%?