Thermistor and Serial Print Monitor

I am trying to get readings from a thermistor and referenced this link:
http://www.arduino.cc/playground/ComponentLib/Thermistor2
and am using the simple code.

My circuit also looks like the one in this link:

When I run the code and examine the values in the Serial Monitor the numbers are not accurate. I get a value of about 1 degree Farenheit when I should be getting something closer to 68F. Below is my code:

#include <math.h>

int tempSensor = A0; // Analog input pin that the thermistor is connected to
int inputSensorValue = 0; // Input sensor value read from the Thermistor

double ThermistorC(int RawADC) {
double TempC;
TempC = log(((10240000/RawADC) - 10000));
TempC = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempC * TempC ))* TempC );
TempC = TempC - 273.15; // Convert Kelvin to Celcius
return TempC;
}

double ThermistorF(int RawADC) {
double TempF;
TempF = log(((10240000/RawADC) - 10000));
TempF = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempF * TempF ))* TempF );
TempF = TempF - 273.15; // Convert Kelvin to Celcius
TempF = (TempF * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return TempF;
}

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

void loop() {
// Get sensor reading:
inputSensorValue = analogRead(A0);
// Print to Serial Monitor Sensor Values (optional):
Serial.print("Sensor Temp Farenheit = " );
Serial.println(int(ThermistorF(analogRead(inputSensorValue)))); // Display Fahrenheit
}

I have scanned the net for other samples of this and when I copy the code and paste into the arduino IDE I get googly gop in the serial monitor. Any idea why I can not get the right values from the code above?

Thanks in Advance!

There are several constants in that equation that characterize the thermistor. If your thermistor I different from the one the sketch was written for you will get incorrect results.

If your thermistor did not come with a list of constants you can calculate the constants by measuring the resistance at three temperatures.

Hi,

Thanks for the quick response. How do I measure the resistance at three temperatures? Sorry if that is a basic question... It is a 10K thermistor.
Thank you once more.

mikamikapika:
How do I measure the resistance at three temperatures?

You get a multimeter and use it to measure resistance. Then you use a known-good thermometer to measure temperature. Put everything in your freezer. Measure temperature and resistance. Do the same at room temperature and in a warm oven. Look for an online thermistor calculator that will turn those three pairs of temperature and resistance into the constants needed for the formula.

Thanks for the response. I had a major flop in my circuit and was using a 1k resistor instead of a 10k resistor and therefore was getting incorrect values.