# Arduino not reading correctly NTC thermistor

Good morning, i have some troubles with arduino and a NTC sensor (JT type), its value is 100K at 25°.
Here is the datasheet: http://www.spiratronics.com/data/B048.pdf (Mine is 104JT-050)
I read lots of threads regarding arduino and thermistors, and i found that better readings can be done with this method: http://garagelab.com/profiles/blogs/tutorial-using-ntc-thermistors-with-arduino
the same here: Using a Thermistor | Thermistor | Adafruit Learning System

Now the problem: I did the circuit, but i have a 100K thermistor so i put a 100K resistor, i have a 4390 beta value and i put that in the sketch:

``````// Pin that the thermistor is connected to
#define PINOTERMISTOR A0
// Nominal temperature value for the thermistor
#define TERMISTORNOMINAL 100000
// Nominl temperature depicted on the datasheet
#define TEMPERATURENOMINAL 25
// Number of samples
#define NUMAMOSTRAS 10
// Beta value for our thermistor
#define BCOEFFICIENT 4390
// Value of the series resistor
#define SERIESRESISTOR 100000

int amostra[NUMAMOSTRAS];
int i;
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}

void loop(void) {
float media;

for (i=0; i< NUMAMOSTRAS; i++) {
delay(10);
}

media = 0;
for (i=0; i< NUMAMOSTRAS; i++) {
media += amostra[i];
}
media /= NUMAMOSTRAS;
// Convert the thermal stress value to resistance
media = 1023 / media - 1;
media = SERIESRESISTOR / media;

//Calculate temperature using the Beta Factor equation
float temperatura;
temperatura = media / TERMISTORNOMINAL;     // (R/Ro)
temperatura = log(temperatura); // ln(R/Ro)
temperatura /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
temperatura += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temperatura = 1.0 / temperatura;                 // Invert the value
temperatura -= 273.15;                         // Convert it to Celsius

Serial.print("The sensor temperature is: ");
Serial.print(temperatura);
Serial.println(" *C");

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

And it’s ok.
But when the sensor should read 69° it read 50/51°.
The sensor is placed under a computer cpu’s heat spreader, it has some thermal paste on it, what i’m doing wrong?

Is the sketch or the circuit wrong?

Please read How to Use this Forum

Modify your post to use the code tags </>. If you look at the original posting, you can see that it changes to italics half way through and index numbers are lost.

Can you attach a hand drawn circuit sketch and photo of your arrangement. Referring us back to the web documents doesn’t show what you have actually done.

Have you actually measured your 100K reference resistor?

Thanks for the answer, have modified the post.
Here is a pic of the circuit:

I can’t show it now as it is inside a computer case, if i can i will take some photos.
100k reference resistor? I haven’t measured the resistor, should i do that?

A voltage divider with 10k resistances would probably be better. When the analog input is reading a value, a sampling capacitance must be charged. That may inflence your readings.

pietkuip:
A voltage divider with 10k resistances would probably be better.

When the analog input is reading a value, a sampling capacitance must be charged. That may inflence your readings.

The fixed resistor value should be the same as the thermistor for maximum A/D resolution.

If the value is >10k, it is wise to add a 100n cap from analogue-in to ground.
Then the A/D sees a "solid" voltage during sampling.

Digital temp sensors like the DS18B20 are easier to use than thermistors.
Leo..

The circuit image shows a 10 kohm resistor. Previously you said there was a 100 kohm resistor to match the 25C resistance of the thermistor, and the code is written for a 100 kohm.

``````#define SERIESRESISTOR 100000
``````

Which resistor do you actually have in the circuit?

100k reference resistor? I haven't measured the resistor, should i do that?

Do you know the tolerance of the resistor? Any difference from the 100 k will add error. If its a 1% resistor its no big deal, but if its a 5% or 10% it may be a significant part of your error. If you know the actual value, you can use that number in the #define statement.

But when the sensor should read 69° it read 50/51°.

How have you determined that the temperature reading should be 69°.

Wawa:
The fixed resistor value should be the same as the thermistor for maximum A/D resolution.

If the value is >10k, it is wise to add a 100n cap from analogue-in to ground.
Then the A/D sees a “solid” voltage during sampling.

Digital temp sensors like the DS18B20 are easier to use than thermistors.
Leo…

cattledog:
The circuit image shows a 10 kohm resistor. Previously you said there was a 100 kohm resistor to match the 25C resistance of the thermistor, and the code is written for a 100 kohm.

``````#define SERIESRESISTOR 100000
``````

Which resistor do you actually have in the circuit?

Do you know the tolerance of the resistor? Any difference from the 100 k will add error. If its a 1% resistor its no big deal, but if its a 5% or 10% it may be a significant part of your error. If you know the actual value, you can use that number in the #define statement.
How have you determined that the temperature reading should be 69°.

Good morning, i have a 100k resistor, but the image shows a 10k, my fault. Will try to measure the resistance of the thermistor, also i determined the temperature by the cpu of the computer, where the thermistor is next to.

Wawa:
The fixed resistor value should be the same as the thermistor for maximum A/D resolution.

If the value is >10k, it is wise to add a 100n cap from analogue-in to ground.
Then the A/D sees a “solid” voltage during sampling.

Digital temp sensors like the DS18B20 are easier to use than thermistors.
Leo…

I know that other thermistors are more user friendly, but i need that one because is a flat one, and i can put it in small places.

Thanks to all, will update soon

I don't see any fundamental problem in the code you are running. I used my 10K NTC thermistor to run with the posted Beta Factor code and got reasonable results comparable to what I see running generic Steinhart-Hart code but I had to tweak the published Beta factor for my thermistor to get good agreement.

The accuracy of the code is dependent upon three factors which are all published values which may not exactly match you situation. The thermistor 100 Kohms at 25C, the Beta factor of 4390, and the reference resistor value of 100 Kohms are all published rather than measured values.

There is lots of material on the web about calibrating thermistors and determining Beta by making resistance measurements at two temperatures. Here's one example Predicting Thermistor Resistance

First off, you definitely want a measured value for the reference resistor or use a 1% or less tolerance.

You can use the thermometer and the raw ADC readings from voltage divider to determine the resistance of the thermistor for your particular Arduino.

If you have a specific thermometer reading you want to replicate with the thermistor, you may find it easiest to change the Beta factor directly, to produce the right temperature values at that high temperature of interest. In your case, if you believe the PC is at 70C modify beta to produce that value from the code. You're likely to be close to 25C. Everything will depend on how accurate you want your measurements to be and over what range.

cattledog:
I don't see any fundamental problem in the code you are running. I used my 10K NTC thermistor to run with the posted Beta Factor code and got reasonable results comparable to what I see running generic Steinhart-Hart code but I had to tweak the published Beta factor for my thermistor to get good agreement.

The accuracy of the code is dependent upon three factors which are all published values which may not exactly match you situation. The thermistor 100 Kohms at 25C, the Beta factor of 4390, and the reference resistor value of 100 Kohms are all published rather than measured values.

There is lots of material on the web about calibrating thermistors and determining Beta by making resistance measurements at two temperatures. Here's one example Predicting Thermistor Resistance

First off, you definitely want a measured value for the reference resistor or use a 1% or less tolerance.

You can use the thermometer and the raw ADC readings from voltage divider to determine the resistance of the thermistor for your particular Arduino.

If you have a specific thermometer reading you want to replicate with the thermistor, you may find it easiest to change the Beta factor directly, to produce the right temperature values at that high temperature of interest. In your case, if you believe the PC is at 70C modify beta to produce that value from the code. You're likely to be close to 25C. Everything will depend on how accurate you want your measurements to be and over what range.

Good morning, yes, i had tried to modify beta value with 2500 and the temperature was next to the one i was looking for, but i thought it was not correct to do that, so i thought it was right to understand why this little damn and freaky sensor (i have 2 of that, one is 100K 50mm and 4390beta, the other is 10K 10mm and 3435beta, however they don't read the temperature correctly) is giving problem.
I had built a PC inside a plexyglass cube with spare pieces i have bought, and i need to cooldown the CPU with a controlled PWM fan connected to arduino with a sensor. All that is for my school-leaving examination, as i'm doing an electronic course, that's why i need a small sensor (to put that next to the CPU chip under the Heatspreader, so i had to delid my CPU) and i need to have accurate temperatures (more or less, if real temperature is 71 i can accept a 70 value from arduino).