...
- Resistance at 25°C: 10K ±1%
- B25/50: 3950 ±1%
- Thermal time constant ? 15 seconds
- Thermistor temperature range -55°C to 125°C
- Wire temperature range -55°C to 105°C
- 28 AWG PVC Wire
- Diameter: 3.5mm/0.13in
- Length: 18in/45cm
Note that even though the thermistor can go up to 125°C the cable itself maxes out at 105°C so this thermistor is not good for measuring very very hot liquids
Wiring
We can use a simple voltage divider circuit to measure the voltage across the thermistor.
...
Vout = Rt / (Rt + Rs) * Vin
Calculating Rt
Say the fixed resistor is 10K and the variable resistor is called R - the voltage output (Vo) is:
...
ADC value = Vi * 1023 / Varef
So now we combine the two (Vout = Vi) and get:
ADC value =
...
Rt / (
...
Rt + 10K) * Vcc * 1023 / Varef
What is nice is that if you notice, if Vcc (logic voltage) is the same as the ARef, analog reference voltage, the values cancel out!
ADC value = Rt / (Rt + 10K) * 1023
Finally, what we really want to do is get that Rt (the unknown resistance). So we do a little math to move the Rt to one side:
Rt = 10K / (1023/ADC - 1)
Code Block |
---|
// thermistor-1.ino Simple test program for a thermistor for Adafruit Learning System
// https://learn.adafruit.com/thermistor/using-a-thermistor by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and consider buying parts from Adafruit
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
// What pin to connect the sensor to
#define THERMISTORPIN A0
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
float reading;
reading = analogRead(THERMISTORPIN);
Serial.print("Analog reading ");
Serial.println(reading);
// convert the value to resistance
reading = (1023 / reading) - 1; // (1023/ADC - 1)
reading = SERIESRESISTOR / reading; // 10K / (1023/ADC - 1)
Serial.print("Thermistor resistance ");
Serial.println(reading);
delay(1000);
} |
Computing Temperature
We'll use the Steinhart-Hart equation , which lets us do a good approximation of converting values.
Its not as exact as the thermistor table (it is an approximation) but its pretty good around the temperatures that this thermistor is used.
Simplified Equation
Code
Code Block |
---|
// Thermistor Example #3 from the Adafruit Learning System guide on Thermistors
// https://learn.adafruit.com/thermistor/overview by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and consider buying parts from Adafruit
// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}
void loop(void) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
delay(1000);
} |
References
Reference | URL |
---|---|
Thermistor | https://learn.adafruit.com/thermistor/overview |
Using a Thermistor | https://learn.adafruit.com/thermistor/using-a-thermistor |
Temperature Table | https://cdn-shop.adafruit.com/datasheets/103_3950_lookuptable.pdf |
...