Simple sketch to interface with any thermistor and get accurate readings

This is a simple sketch I wrote to Interface any Thermistor with an Analog pin on an Arduino compatible Microcontroller. When I began trying to use thermistors with my Arduino I was unable to find a simple program ( easy to follow) to suit my needs. I did the only thing I could and created my own. I am posting it here for those in the same boat as I was. If you have any suggestions to improve my code please reply and re-upload.
Ian Bowler

ThermistorD.ino (977 Bytes)

looks good, did some restyling of your code, added a header for meta data,
some spaces and empty lines to mimic logical blocks.

//    FILE: .ino
//  AUTHOR: 
// VERSION: 0.1.00
//    DATE: 2014-
//     URL:
// Released to the public domain


// from
#define A -1.392873556E-3 
#define B  6.280201199E-4 
#define C -12.96450742E-7 

#define REFV 5 
#define SERIESRESISTOR 10000 
#define ADJUST 0 

void setup(void) 
  analogReference(INTERNAL);    //Default INTERNAL if EXTERNAL connect AREF pin

void loop(void) 
  float raw = analogRead(THERMISTORPIN);
  float analogvoltage = raw / 1024 * REFV;
  float resistance = SERIESRESISTOR * (1/((REFV/ analogvoltage)-1));
  float logcubed = log(resistance);
  logcubed = logcubed * logcubed * logcubed;
  float kelvin = 1.0 / (A+B*log(resistance)+C*(logcubed));
  float fahrenheit = (((kelvin - 273.15) * 9.0 / 5.0 + 32.0)+ ADJUST);
  Serial.print("temp *F = ");


instead of the #define you can also use e.g. const float A = -1.392873556E-3;
this gives the compiler just a little more information especially with the integer/long/unsigned etc.

Next step is to create a function like this

// reads a thermistor connected to pin P 
// returns temperature in Celsius.
float readThermistor(pin p)
  ... (replace this with the real code)
  return temp;

to make a reusable piece of code