Go Down

Topic: Thermistor2 - Strange result? (Read 982 times) previous topic - next topic


Hi All,

Just trying a basic temperature conversion from my thermistor.

I'm trying to follow the notes on "Thermistor2" from the playground:
I'm using the last example.... Elaborate code tidied up a bit.

I have changed things a little... updated the voltage supplied from the arduino, measured with multimeter.
I'm using a 100k thermistor to have updated this too.
I have changed the pad resistor from 10k to 100k to match the thermistor, I've measured this and put the correct actual value in too.

All seems good, but when I run the code, the values returned are -20 celcius... yes a minus value. The room temp I'm working in is 22 celcius. i've checked the circuit and all the reds and blacks are the right way round.

Any ideas? a scholl boy error?

One observation I have made is that 'float thermr' is defined but I can't see it used anywhere else in the code... therefore although I have changed this to 100000.... not sure if the rest of the calc take the 100k thermistor into account.


Hard to say. Post your code & schematic and you'll likely get a solution offered


Thanks wildbill, code is at home, and I'm at work now so will do so but later.

Interestingly, I tried some different resistors, and made a mistake. The code was working but I don't know why.

I put a 100k resistor in to match the thermistor nominally.... but accidentally left the code to have a pad resistor of 10k.

I then measured the actual resistance of pad resistor as 98600 ohms... changed the value of the pad resistor to 9860 (lost one 0) and was correct to my digital thermometer within 0.2 degrees.

I'm happy it's working but I don't fully understand why it is working with seemingly different resistance values.


I was working with a 10K thermistor and 8.2K resistor.  I connected the thermistor to 5v, the resistor to ground, and both of them to the analog 0 pin.  Hope this helps!
Code: [Select]
#define analogPin 0
#define beta 3000 // from your thermistors datasheet
#define resistance 8.2
int ledPin = 13; // LED is connected to digital pin 13
int sensorPin = 0; // light sensor is connected to analog pin 0
int sensorValue; // variable to store the value coming from the sensor
float alarmValue;  // a variable to know when to light LED - alarm value

void setup()
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
  Serial.begin(9600); //initialize the serial port
  digitalWrite(ledPin, LOW); // turn the LED off
  alarmValue = 25; // initialize alarm value in Celsius

void loop()
long a = analogRead(analogPin);
float temp = beta / (log(((1025.0 * resistance / a) - 8.2) / 8.2) + (beta / 298.0)) - 273.0;
sensorValue = analogRead(sensorPin); // read the value from the sensor
// now print out the temperature
float temperatureC = (sensorValue-.5)/10;
Serial.print(temperatureC); Serial.println(" degress C");

// now convert to Fahrenheight
float temperatureF = (temperatureC * 9 / 5) + 32;
Serial.print(temperatureF); Serial.println(" degress F");

  if (temperatureF > alarmValue) { // if the temp > alarm temp value,
            digitalWrite(ledPin, HIGH); // turn the LED on
  else { // otherwise,
            digitalWrite(ledPin, LOW); // turn the LED off

delay(500);                                     //waiting a second


Go Up