Hi all,
Part of my current project is using a thermistor to measure temperature for a home espresso machine.
I purchased a US Sensors USP11491 probe thermistor as it is +/-0.2°C Accuracy with a max temp of 150°C.
My research led me to believe that using the Steinhart-Hart coefficients for the thermistor would yield the best accuracy over larger ranges. I set up the thermistor as shown in the Thermistor4 Library Arduino Playground - Thermistor4
My thermistor has its own 78L05 regulator with a 10uF capacitor and a 0.1uF capacitor on the input side, and a 0.1uF capacitor on the output side to smooth any supply ripples. I also have a 0.1uF across the RFIXED resistor to smooth any jittery readings as shown in the Thermistor4 example.
For RFIXED, I am using a 1K 25 turn pot tuned to 678?, which on the J-curve (my thermistor is a J curve) corresponds to 100°C (actually 100°C = 678.60?), in order to maximise my sensitivity around boiling point.
I obtained the Steinhart-Hart coefficients from the manufacturer (US Sensors) 
A = 1.12766979300187 E-03
B = 2.34444184128213 E-04
C = 8.47692130592308 E-08
D = 1.17512193579615 E-11
I measured the output from the 78L05 with 2 meters to get a consensus, both measured 4.95V.
I inputted all of this information into the code.
When I run the Thermistor4 code, my measured temps are consistently high.
Using a 50/50 mix of ice and water slush, that should be 0°C, I measure 8.9°C (48°F)
At body temp, measured with the probe in my mouth, (that should be about 97°F) for 5 min, I measure 41.1°C (106°F)
At boiling point at an altitude of approx 39m (128 ft) I measure 105°C (221°F)
According to US Sensors a typical accuracy at boiling point for this thermistor is +/- 0.9°C
I cannot figure out where I am going wrong, any advice is very welcome!
I am using Arduino 1.0.4, but also tested on Arduino 0022 with same results.
My code is below
//#include <Wire.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(10, 9, 5, 6, 7, 8);
// Thermister4 Library version 4c. For Arduino 0018 or newer.
// (c)20101017 by MODAT7 under GNU GPLv1
//Example code of various functions using my 2 salvaged thermistors.
#include "Thermistor4.h"
//Faster serial means shorter delays in the program.
#define SERIALBAUD 115200
//Inside thermistor on Arduino ADC pin 0, Outside on pin 1.
#define THERMISTORPinInside 0
//#define THERMISTORPinOutside 1
//========================================
//One temperature monitoring thermistor for Inside and Outside.
Thermistor4 ThermistorInside;//, ThermistorOutside;
//various temp variables for testing.
unsigned int i, ADCAverage;
double mytemp;
//unsigned long mytime1, mytime2; //for speed tests
byte degree[8] = {140,146,146,140,128,128,128,128};
//byte degree[8] = {14,31,27,31,14,0,0};
//========================================
void setup() {
lcd.createChar(0,degree);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Testing....");
/*
//pin floating paranoia, set pullup's (don't mess with 0 and 1 serial).
for(int i=2; i<20; i++) {
pinMode(i, INPUT);
digitalWrite(i, HIGH);
}
*/
Serial.begin(SERIALBAUD); //set up serial port.
//My 2 salvaged thermistors are about 30k at room temperature.
ThermistorInside.Pin = THERMISTORPinInside; //Set the pin number.
ThermistorInside.SetUp(); //Sets up the analog read pin for internal AVR.
//pow() is used elsewhere so might as well be used here.
ThermistorInside.BitResolution=pow(2, 10)-1; //ATmega's have a 10bit ADC (2^10-1).
ThermistorInside.VoltageSupply=4.955; //My USB powers my ATmega325 chip at 4.95v. Meter this for accuracy.
ThermistorInside.ResistanceFixed=678; //Fixed resistor in the divider. Measured in ohms. Meter this for accuracy.
ThermistorInside.Offset=0.0; //adjust temperature in Kelvin up or down a little to account for unforseen variations.
//These numbers were generated from thermistor.sf.net and aren't quite right unless using the full equation.
ThermistorInside.SteinhartA1=1.12766979300187e-003; //First Steinhart-Hart coefficient.
ThermistorInside.SteinhartA2=2.34444184128213e-004; //Second Steinhart-Hart coefficient.
ThermistorInside.SteinhartA3=8.47692130592308e-008; //Third Steinhart-Hart coefficient.
ThermistorInside.SteinhartA4=1.17512193579615e-011; //Fourth Steinhart-Hart coefficient.
} //end setup()
//========================================
void loop() {
Serial.print("Inside Temp (F): ");
lcd.setCursor(0,1);
lcd.print(ThermistorInside.GetFarenheit(), 2);
lcd.setCursor(5,1);
lcd.print((char)0);
lcd.print("F");
Serial.println(ThermistorInside.GetFarenheit(), 2);
//Example of averaging 10 reads. Note that analogRead() isn't very fast.
//Part of this code has to be done manually, then call ReadADC() with the averaged number.
//Note that an unsigned int is only 16 bits. Do not exceed it or it will roll over and return trash.
ADCAverage = 0; //reset the variable for each loop.
for(i=0; i<10; i++) {
ADCAverage += analogRead(THERMISTORPinInside);
//delay(50); //add an extra delay to spread the average out a little more?
}
ThermistorInside.ReadADC(ADCAverage/10); //call ReadADC() with the averaged value.
ThermistorInside.CalculateTemperature(3); //generate the temperature numbers.
} //end loop()
//end of Thermistor4c.pde
