Need help with Resistance Sensor Setup

hi i received a fuel gauge sending unit and i wanna set it up
the ohm valus are
33-240 for empty to full or vise versa…
Brown wire is signal output
Blue is negative…

do i wire it

Blue to gnd of esp32
brown to 3.3v pin
5.6k ohm resistor from A0 to 3.3 pin (brown wire) ?

this is the code i have plus the sending unit i using 21 "

X AUTOHAUX Universal Marine Fuel Sending Unit Float Replacement Fuel Gauge Gas Tank Diesel Water Level Sender Unit Sensor, 21" 530mm, Anti-Corrosion, Stainless Steel, Silver Tone : Amazon.ca: Automotive"&qid=1723142987&

sensor:
  - platform: resistance
    sensor: Fuel_Tank_Sensor
    configuration: DOWNSTREAM
    resistor: 5.6kOhm
    name: Fuel Tank Sensor


# Example source sensor:
  - platform: adc
    id: Fuel_Tank_Sensor
    pin: A0
    filters:
      - clamp:
          min_value: 33
          max_value: 240

Hi comet424,

First is this Home Assistant or ESPHome? I don’t think Home Assistant has a resistance or adc sensor platform, but I could be wrong.

Also it would be proper on the forum here to supply links without the affiliate or tracking part of the link text so people can click on them safely. If you could edit that to remove all text including and after the:

you might find someone else that would actually click on it.

oh my mistake ya its for ESphome … can i move it there? or have to repost it?
and ill fix that link issue

You can change the topic, yes

@Sir_Goodenough i think i moved it correctly…

1 Like

and does anyone know if i need a bigger resistor as i read something about you need half the size of the biggest ohms… so 240 /2 so would i need a 120ohm resistor instead of the 5,6k

NOT GOOD!

Wire it like this:
image

Resistor value can be higher as well if you don’t have 120ohm resistor on hand. 150 or 200 is very ok

With 120ohm resistor your analog pin voltage would be between 1.1V and 2.6V

@Karosm ok the resister from the example was too big or too small.?
ill see what i got in resisters
and is the code for min max value right too for 33 ohms and 240 ohms… or how do you then make it work in percentage… as 1% to 100% as i wanna use a Gauge display

for future projects how you know which resistor to choose from… as the resistance sensor page didnt it say it but another page said it had to be half the size of the maximm of the resistor…

5.6k means 5600ohms, too high value for your sensor. It would give you 0.1V difference between full and empty. With 120ohm resistor you get 1.5V difference.
Half the max is good choice, but don’t go below 100ohms.

@Karosm so i got a 120ohm resistor… and i wired it the way you have it… but it doesnt seem to be working … if i put it full or empty i get the same reading… and its slow it doesnt check resistance instantly… not sure why and this is the code i using

[15:15:19][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:15:19][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 54.7Ω
[15:15:19][D][sensor:094]: 'Fuel Tank Sensor': Sending state 54.68019 Ω with 1 decimals of accuracy
[15:16:19][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:16:19][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 54.7Ω
[15:16:19][D][sensor:094]: 'Fuel Tank Sensor': Sending state 54.68019 Ω with 1 decimals of accuracy
[15:17:19][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:17:19][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 54.7Ω
[15:17:19][D][sensor:094]: 'Fuel Tank Sensor': Sending state 54.68019 Ω with 1 decimals of accuracy
[15:18:19][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:18:19][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 54.7Ω
[15:18:19][D][sensor:094]: 'Fuel Tank Sensor': Sending state 54.68019 Ω with 1 decimals of accuracy
sensor:
  - platform: resistance
    sensor: Fuel_Tank_Sensor
    configuration: DOWNSTREAM
    resistor: 120Ohm
    name: Fuel Tank Sensor


# Example source sensor:
  - platform: adc
    id: Fuel_Tank_Sensor
    pin: GPIO35
#    filters:
#      - clamp:
#          min_value: 33
#          max_value: 240

and im using a ESP32 mini d1

and if i change the downstream to upstream… i get this … it still stays the same if i move from bottom to the top

[15:22:30][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:22:30][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 263.3Ω
[15:22:30][D][sensor:094]: 'Fuel Tank Sensor': Sending state 263.34946 Ω with 1 decimals of accuracy
[15:23:00][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[15:23:00][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:23:00][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[15:23:30][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:23:30][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 263.3Ω
[15:23:30][D][sensor:094]: 'Fuel Tank Sensor': Sending state 263.34946 Ω with 1 decimals of accuracy
[15:24:30][D][sensor:094]: 'Fuel_Tank_Sensor': Sending state 1.03300 V with 2 decimals of accuracy
[15:24:30][D][resistance:039]: 'Fuel Tank Sensor' - Resistance 263.3Ω
[15:24:30][D][sensor:094]: 'Fuel Tank Sensor': Sending state 263.34946 Ω with 1 decimals of accuracy

You have something wrong there. Send a good picture of your wiring.
Also, your board Esp32 mini D1 is… not common at least. What board you have defined in your code??

its the only board i have at the moment that had kicking around why what kind you need?
the define is

esp32:
  board: esp32dev
  framework:
    type: arduino

and here is some pics
purple is 3.3v
black Ground
Gray is GPIO 35




Your board definition and breadboard connections look correct.
Photo of your board is worthless, could be esp8266 as well…
Sure about resistor value?

i need a new phone here some somewhat better pics




Much better images.
Your resistor doesn’t look 120ohm, but 10000ohm …
Tell me the colors or take very good pic. :wink:

Edit: reversed it’s 120ohm, sorry for that.

the camera i have troubles getting color to work right… but i thought its 100ohm? 100R


Do you have multimeter to measure resistance?
I really can’t tell from photo…

ya and i took wrong photo i had package of 100r and 120R but ill go get the multimeter and test it

Better like that! :+1:
By the way, disconnect sensor wires from breadboard and measure that (blue-brown) resistance as well (you never know)…