Temperature from a Thermistor (Arduino)
Turn a 10k NTC thermistor and a resistor into a temperature sensor. Learn voltage dividers and the Beta equation.
Intermediate25 min
What you need
Wiring
Hover a pin or a wire to trace the connection.
Code
thermistor.ino
// Read temperature from a 10k NTC thermistor + 10k divider.
const int pin = A0;
const float BETA = 3950.0; // use your thermistor's datasheet value
void setup() { Serial.begin(9600); }
void loop() {
int raw = analogRead(pin);
// Thermistor to 5V, 10k from A0 to GND:
float r = 10000.0 * (1023.0 - raw) / raw; // thermistor resistance
float tempK = 1.0 / (1.0 / 298.15 + log(r / 10000.0) / BETA);
Serial.print(tempK - 273.15);
Serial.println(" C");
delay(1000);
}
Steps
- Build the divider: thermistor from 5V to A0, and a 10kΩ resistor from A0 to GND.
- Put your thermistor's Beta value (from its datasheet) into the code.
- Upload and open the Serial Monitor to read the temperature.
- Pinch the thermistor — the temperature should climb.