10k NTC Thermistor - Not Reading Resistance Properly?

Hi All,

So I have a 10KOhm thermistor, that I have in series with a 10KOhm 1% resistor. I have the datasheet which effectively states the the B_Constant is 3997 @ 1%. I have verified that the resistance on the thermistor is 10Kohm with my multimeter and also double checked the resistor I’m using to verify that its 10K Ohms.

I should be getting 25C at 10K ohms with this setup is my understanding but I am nowhere near that, at 22.7C I’m basically at 1965Ohms. (not to be confused with KOhms) So I’m very far off. This is how my YAML is configured currently:

sensor:
  - platform: ntc
    sensor: resistance_sensor
    calibration:
      b_constant: 3997
      reference_temperature: 25°C
      reference_resistance: 10kOhm
    name: NTC Temperature B Constant

  - platform: resistance
    id: resistance_sensor
    sensor: source_sensor
    configuration: DOWNSTREAM
    resistor: 10kOhm
    name: Resistance Sensor

  - platform: adc
    id: source_sensor
    pin: A0
    update_interval: 5s

I’m basically wired up like this, except i’m using 3.3V and A0 on an Amica NodeMCU ESP8266

Here’s the breadboard view (red/white wires are heading to the thermistor).

Any help is really appreciated.

The voltage divider created by the resistor and the thermistor should be powered from 3.3v. Not 5V.

Edit: never mind. Just saw this:

Thanks Tom, I am powering from 3.3v, i double checked just incase somehow it was off from the nodemcu.

I wonder if it is because the resistance sensor is expecting the ADC reading to be 0-1V?

The Wemos produces a 0-3.3V signal as it has an onboard voltage divider.

Try a filter on the ADC that multiplies by 3.3.

Okay so I seem to have this working now, what I did was I hooked it up to an ESP32, and I set the ‘attenuation’ on the ESP2 to 11db which gives a voltage max of 3.6V, then I manually set the resistance sensor voltage reference to 3.6V also and that appears to be working now. I dont quite understand why… if I try any other values like 6db (2.2 max V) and then set the resistance voltage reference to 2.2V that produces the wrong resistance values…

Maybe someone has an idea? I suspect I have a fundamental misunderstanding here.

Updated yaml that seems to be working an ESP32 on the “VP” pin which is GPI36 (input only)


-sensor
  - platform: ntc
    sensor: resistance_sensor
    calibration:
      b_constant: 3997
      reference_temperature: 25°C
      reference_resistance: 10kOhm
    name: NTC Temperature B Constant

  - platform: resistance
    id: resistance_sensor
    sensor: source_sensor
    configuration: DOWNSTREAM
    resistor: 10kOhm
    reference_voltage: 3.6V
    # reference_voltage: 3.9V
    name: Resistance Sensor

  - platform: adc
    id: source_sensor
    pin: 36
    attenuation: 11db
    update_interval: 5s

There’s something still not quite right. 11dB should give a max input of 3.9V not 3.6.

Yeah thats what I thought originally but I ran across another website that said it was 3.6V so i tried that and I’m getting very accurate readings now, its really weird. With 3.9V as the reference voltage I was getting really off readings again.

Other website that says 3.6V: https://randomnerdtutorials.com/esp32-adc-analog-read-arduino-ide/

That’s for a direct input to the ADC. i.e. 0-1V with an 11dB attenuation network = 3.548V.

But if you also have an external voltage divider that takes 3.3V in and presents it to the ADC as 1V (as a lot of development boards do) then your max input is at 11dB attenuation is 11.7V.

Put 1V on the ADC input. What does the ESP home debug log say the measurement is?

If it’s only 0.303V you have an extra voltage divider external to the chip.

Sorry a bit of a noob here, whats the best way to stick 1V on the ADC Input?

EDIT: Actually I could probably just reduce down the 3.3v to 1v with some resistors, i’ll give that a shot tonight.

I think i’m at a loss trying to understand what the resistance reference voltage is doing here, i understand the concept, convert the resistance to voltage, convert voltage to ohms, then ohms to temp, but I’m a little lost about the reference voltage on the resister platform and why altering that seems to be making such a drastic and working change.

Ok I know this is a stale thread but I’ve spent all night myself trying to learn how to setup a ntc thermistor with espHome. This thread led me to a few other sites like espHome and random nerd that got me there. Sharing my solution in case it helps someone else.

The problem with the code above is the “reference voltage” is the voltage across the voltage divider. It is NOT the max voltage of the ADC reading. By default this is 3.3 that would be powered by the esp32 board. So 3.6 got you closer to 3.3 than 3.9 but was still wrong. You can just remove that parameter all together and let it default to 3.3.

2 Likes

Did you ever get this working? I’ve got the exact same issue, and the comment after your last did not help.
Edit: The 11db attenuation does seem to give accurate readings. I just can’t figure it out why. The documentation is a bit omissive in this topic.