# Why are my thermistor readings backward?

I'm trying to build a thermistor that will flash an LED when the temperature is above 30 C. My set-up appeared to be reporting the room temperature correctly to the Serial Monitor, but then I noticed that exposing the thermistor to a hot object causes the reported temperature to drop, whereas exposing it to a cold object causes the reported temperature to rise.

I'd built a simpler thermistor circuit earlier with a similar approach and everything seemed to function correctly. I'm not sure what I broke here:

``````const int WarningLED = 7;
const int Thermistor = 0;

/* Thermistor information:
* P/N: BC2301-ND
* MFG P/n: NTCLE100E3103JB0
* DESC: THERMISTOR NTC 10KOHM 3977K BEAD, IDX: 1 */

int Vo; // voltage between thermistor and R1
float R1 = 10000; //10 KOHM resistor used for voltage divider
float TR; // resistance of negative temperature coefficient (NTC) thermistor
float beta;  //beta will later equal ln( TR / Rref )
float Tk, Tc, Tf;

/* Steinhart-Hart equation coefficients via data table at
* http://www.vishay.com/docs/29049/ntcle100.pdf
* Bead used: 3977K (refer to #9 values on Nominal R table) */
float A = 3.354016e-03,B = 2.569850e-04;
float C = 2.620131e-06,D = 6.383091e-08;

void setup() {
pinMode(WarningLED, OUTPUT); //sets the warning LED pin as a digital output
Serial.begin(9600);          //  setup a serial port to enable comms with the computer.
}

void loop() {

Serial.print("Vo: ");
Serial.print(Vo);
Serial.println(" mV");

//Voltage divider equation: R2 = R1 * [Vo / (Vi - Vo)]
//where R2 = TR, Vi = 1023.0 :
TR = R1 * ((float)Vo / (1023.0 - (float)Vo));
Serial.print("Thermistor resistance: ");
Serial.print(TR);
Serial.println(" ohms");

beta = log(TR/10000); // As per extended Steinhart-Hart equation,
//  where Rref = 10,000 (refer to page 10 of the PDF linked above)
Tk = (1.0 / (A + B*beta + C*beta*beta + D*beta*beta*beta));
Tc = Tk - 273.15;
Tf = (Tc * 9.0)/ 5.0 + 32.0;

Serial.print("Temperature: ");
Serial.print(Tk);
Serial.print(" K; ");
Serial.print(Tf);
Serial.print(" F; ");
Serial.print(Tc);
Serial.println(" C");
Serial.println();

if (Tc > 30.0) digitalWrite(WarningLED, HIGH);
else if (Tc < 30.0) digitalWrite(WarningLED, LOW);
delay(1000);
}
``````

On the Serial Monitor, this reports:

``````Vo: 550 mV
Thermistor resistance: 11627.91 ohms
Temperature: 294.74 K; 70.86 F; 21.59 C
``````

Exposing this to a warmer temperature incorrectly reports:

``````Vo: 597 mV
Thermistor resistance: 14014.08 ohms
Temperature: 290.61 K; 63.43 F; 17.46 C
``````

I notice that, among other issues, this is reporting increased resistance in the thermistor despite that I'm using an NTC, but I'm not sure why this is occurring.

Notable parts used in this circuit:

• Thermistor: NTCLE100E3103JB0
• R1: 10 KOHM
• R2: 1 KOHM
• C1 & C2: 33 nf  