I just tried to set up a resistance sensor with ESPHome and I only get background noise with it.
My hope was to read a force sensitive resistor but after some failed attempts I replaced it with a static resistor of 200 Ohm.
I get ~2.8 Ohm output.
Replaced it with a 3.3 KOhm resistor and the value is the same.
If you have one available try putting in a larger reference resistor.
The one you have now is so much smaller than the measuring resistor that the voltage drop across the reference resistor will be almost nothing compared to the measured one
3300 + 200 = 3500 ohms total circuit resistance
(200/3500) * 3.3v = 0.18 volts dropped across the reference resistor
That’s not much.
I can’t really see from the picture what board that is or see the terminals you have the wires connected to so I can’t verify the circuit is connected up right either. But it looks correct otherwise.
It is connected correctly, even if I take a closer photo the connectors block the writing anyways :-/
It’s a Adafruit huzzah32 ESP32 feather board.
I tried to switch to any to A4 and got a different value.
Then I tried what you wrote, first a 4.7 kOhm. Got better.
Then I added a 1 Mohm as the first resistor.
I get a higher value, but it does not relate to what the R2 is.
Sure If I add a 4.7 KOhm resistor it’s very close to accurate, but the idea (I hope) is to actually read the resistor. If I swap the R2 to something else, say 3.3 or 200 it still stays at 4.7 KOhm (more or less).
But I had to add a 4.7 kOhm resistor before my FSR.
Without it I would get 1.1 volt all the time, this made it get lower so that I had some room to measure it.
I’ve never used ESPHome for this kind of thing before so I’m not really sure.
I’m not sure what “upstream” and “downstream” are referring to. Is it whether the measured resistor is connected to ground or 3.3v?
Where are you seeing what the resistance of the resistor is? Where is that output?
As far as I know the analog input measures the voltage at the AO pin and converts that to counts (1024 counts = 3.3v) via the ADC. I’m not sure how ESPHome then calculates the resistance past that.
Upstream means that it calculates the upper resistor in a voltage divider.
Downstream means the lower, closer to ground.
To me the actual value is not important, just that it changes with pressure.
So this is the current setup, 3.3 volt to a 4.7 kOhm resistor -> to FSR (Below coffee machine).
Then the second resistor of the voltage divider is a 3.3 kOhm.
Ok, I think I’m starting to see your potential problem.
the resistor you are trying to measure needs to be one of the two resistors in the voltage divider circuit.
Right now it sounds (and looks like from the picture) that you have a three resistor voltage divider. you could do it that way but you would have to manually do the calculations. ESPHome assumes you are using only a total of two resistors in the circuit so it’s basing the calculation on that.
you should eventually end up with a circuit like below
That is what I had, but since the FSR wasn’t giving enough resistance the output would be higher than the 1.1 volt the chip can read.
So by just “helping” the FSR with another resistor I got the voltage down below 1.1.
Maybe there is another combination that would work better but I get a reading with the minimum load and maximum load so I’m happy
Sorry I missed that post where you said was working like that.
But I’m still confused about the “1.1v max” comment.
Shouldn’t the AO pin be rated for 3.3v?
Granted I don’t know anything about the board you are using but I know on NodeMCU boards the AO pin is rated for 3.3v.
And it shouldn’t make any difference whatsoever if you use the upstream or downstream as long as you have the circuit hooked up correctly. One way the resistance will be measured going up as the actual resistance goes up and the other way the measured resistance will go up as the actual resistance goes down.
Not sure why that is but reading the adc of esphome https://esphome.io/components/sensor/adc.html says it caps out at 1.1 v.
You can set attenuation to make it go higher, but not sure if that just multiply the values. If it does then it’s useless
I just read that link and I’m not really sure what that info is based on.
I’ve literally got a NodeMCU sitting right in front of me right now that I have been working on for the last few hours that uses the exact same voltage divider circuit you are using to measure the resistance of a thermister and it reads 0 to 3.3vdc on the AO pin just fine. It definitely doesn’t cap out at 1.1vdc.
I tried setting that setting to 11db and I got more than 1.1, at least 1.7 didn’t try more than that.
So that meant I could remove the extra resistor and save some cash!
Thank you for your help, now I just need to calibrate what the numbers mean translated to coffee mugs.