# Not able to sense temp using an NTC thermistor

I had bought a couple of 10K NTC thermistors a while ago and finally found some use for them. I was trying out Adafruit's guide on using them but I'm getting some whacky outputs. At room temp (about 23 deg C) I see a nominal resistance of 9.9K on the multimeter. However, with the code on the guide, I see temps being calculated as 60 deg C. I tried using different NTC's such as the one for the E3D nozzle and switched out the series resistor to 100k but still no joy! What am I missing?

electrophile:
What am I missing?

No idea what you are missing, I do know what I am missing: your code and your circuit diagram (so no Fritzing eye candy).

Ergo the link to the guide. I've now added the fritzing image here. Also listed is the code.

``````// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000

uint16_t samples[NUMSAMPLES];

void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}

void loop(void) {
uint8_t i;
float average;

// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
delay(10);
}

// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;

Serial.println(average);

// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);

float steinhart;
steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
steinhart = log(steinhart);                  // ln(R/Ro)
steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart;                 // Invert
steinhart -= 273.15;                         // convert to C

Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");

delay(1000);
}
``````

Is that the exact schematic & code YOU use?

And isn't it impressive how horribly unreadable Fritzings are even for this kind of simple diagrams?

DId you connect the 10k pull-up to 5V or 3.3V? (assuming you're using a 5V Arduino and have both voltages available).

The code and the idiot diagram have to match.

There are two ways of wiring the thermistor voltage divider. One of them is wrong.

wvmarle:
Is that the exact schematic & code YOU use?

And isn't it impressive how horribly unreadable Fritzings are even for this kind of simple diagrams?

DId you connect the 10k pull-up to 5V or 3.3V? (assuming you're using a 5V Arduino and have both voltages available).

Yeah I took that from the Adafruit's page and they did not have a higher resolution image. I just realized that the schematic I attached here is different from the final one and the way I've wired it (which is shown a little later in the page on the guide). The final schematic has AREF and the 10K pullup at 3.3V.

jremington:
The code and the idiot diagram have to match.

There are two ways of wiring the thermistor voltage divider. One of them is wrong.

Yeah I just realized that the schematic I attached here is different from the final one and the way I've wired it (which is shown a little later in the page on the guide). The final schematic has AREF and the 10K pullup at 3.3V. I'm guessing the other way is to swap the positions of the pullup and the thermistor?

I'm guessing the other way is to swap the positions of the pullup and the thermistor?

Correct.

You can damage the Arduino by connecting a voltage source to AREF, unless you follow the rules carefully. See https://www.arduino.cc/en/Reference/AnalogReference

You're using the beta-coefficient formula (did you change that parameter to match your NTC's?), so you wire the NTC between GND and the analog pin, and the 10k between 5V and the analog pin if you have a 5V Arduino, or between the analog pin and 3.3V if you have a 3.3V Arduino.

You mentioned wiring to +3.3V which is wrong on a 5V Arduino. That's why I asked for YOUR schematic, so how YOU wired it, not something you pulled off from a web site and which may or may not be the same.

If you wire the divider to +3.3V and your Vcc is 5V, then no wonder you have too high temperature. The analog pin gets a lower voltage, making the NTC appear to have a lower resistance, thus higher temperature.

electrophile:
Yeah I took that from the Adafruit's page and they did not have a higher resolution image. I just realized that the schematic I attached here is different from the final one and the way I've wired it (which is shown a little later in the page on the guide). The final schematic has AREF and the 10K pullup at 3.3V.

Hand-draw an accurate diagram of how you've actually wired it, no point posting something that's different,
it muddies the water.