Using an Arduino with thermistor is one of the cheapest
ways you can measure temperature. All you need is a 10k thermistor (and a
10k resistor), and a microcontroller capable of reading an analogue
voltage i.e. Any Arduino.
While they don't give the best accuracy (dependent on your
circuit layout and curve fitting algorithm) you can get close to ±1°C or better,
they are easy to setup for a good-enough reading and they do have good
sensitivity and repeatability. They are widely used for devices such as
3dprinter hot end and bed temperature control and many other applications that require fairly good temperature control.
Other chips that
provide a defined accuracy are LM35 and DS18B20 (there are lots more).
Common thermistors are NTC types (Negative Temperature
Coefficient) meaning that their resistance decreases as temperature
increases (you can get PTC ones but they are less common - typically used as inrush current limiters).
The idea is that you want to measure the resistance of the
thermistor but microcontrollers can only measure voltage (using the ADC).
So, to turn the resistance into a voltage, that changes as the thermistor
resistance changes, you use a voltage divider using a 10k resistor in
series with the thermistor.
You read the center voltage of the voltage divider using your ADC.
Arduino
(Uno, Nano, etc.).
10kOhm NTC Thermistor.
Breadboard.
Jumper wires.
Resistor
(10k Ohm recommended for most thermistors.
Capacitor (100nF).
Using a solderless breadboard to place the components:
Connect one leg of the thermistor to the A0 pin on your Arduino. Connect the other leg of the Thermistor to ground.
Connect one side of a 10k resistor to A0. Connect the other side of the 10k to 5V.
Connect one leg of a 100nF capacitor to A0. Connect the other side of the capacitor to ground.
This
creates a voltage divider so the Arduino can read the thermistor's
changing resistance as a voltage value.
Click in the code below to copy it to the clipboard.
// Copyright John Main: TronicsBench.com
// Free for use in non-commercial projects.
#define THERMISTORPIN A0
// Thermistor parameters
#define BETA 3950
#define R25 10000
void setup() {
// Initialize serial port
Serial.begin(115200);
}
void loop() {
// Read thermistor voltage
int reading = analogRead(THERMISTORPIN);
// Convert voltage to resistance
float resistance = thermistorResistance(reading);
// Calculate temperature from resistance
float temperature = thermistorTemperature(resistance);
// Output temperature over serial
Serial.print("THERMISTOR Temperature: ");
Serial.println(temperature);
delay(1000);
}
// Converts arduino analog reading to resistance
float thermistorResistance(int reading) {
float ratio = (float)reading/1024.0;
float resistance = 10000 * ratio/ (1-ratio);
return resistance;
}
// Convert resistance to temperature using Steinhart-Hart equation
float thermistorTemperature(float R) {
float T25 = 25+273.15; // Convert to Kelvin
float T = 1 / ((1 / T25) + ((log(R / R25)) / BETA));
float Tc = T - 273.15; // Converting kelvin to celsius
return Tc;
}
This uses the thermistor's Steinhart–Hart equation to calculate temperature from its resistance.
One way of deciding if a thermistor is the correct part for your
project is to compare the output to a known device. The
following sketch shows you how to get the value of a DS18B20 as well as a
thermistor, and display that on an SSD1306 I2C display.
The Steinhart-Hart equation models the relationship between
temperature and resistance for thermistors. It expresses temperature T
in kelvins as a function of the thermistor's resistance R in ohms. The
equation takes the form of 1/T = A + B*ln(R) + C*(ln(R))^3, where A, B,
and C are thermistor constants that are specific to each type of
thermistor and are obtained through calibration. The Steinhart-Hart
equation provides a precise mathematical formula to convert a
thermistor's resistance reading into an accurate temperature
measurement.
In most practical implementations the parameter C is often ignored. There are a few key reasons for this:
- Simplification - Ignoring C results in a simpler linearised equation
that is easier to implement versus the full cubic equation providing
reasonable accuracy for most applications.
- Accuracy tradeoff - Including C provides marginally better accuracy,
but the improvement is small relative to the added complexity of
implementing the cubic terms.
- Parameter fitting - It can be more difficult to accurately determine the value of C.
- Temperature range - The contribution of C becomes more significant at
very high or low temperatures far outside the typical operating range of
0-100°C for most thermistors. Within this range the linear
approximation is adequate.
While technically ignoring C results in a small loss of accuracy, the
simplification is well worth it for most use cases that don't require
laboratory-grade precision. In practice, A and B alone provide
temperature measurements with an acceptable error margin.
For the equation used in the code A is 1/T25 and B is 1/BETA.
On the documentation with the thermistors I bought we have:
NTC thermistor Temperature Sensor
5%/1% MF52A 3950K
3pcs 1% 10k
The MF52A is the thermistor type and the value 3950K is the Beta
coefficient (or temperature sensitivity). Beta values range from
2000 to 5000K and you must use the one that is specified for your
thermistor to get accurate results (put the number into the code).
The Beta value indicates the steepness of the response
+
[source NTC thermistors, general technical information (tdk.com)]
When you use the equation for calculating the resistance value you will be asked for the resistance at a set temperature on the datasheet this is the quoted resistance e.g for the above one it is 10k (the temperature is usually specified as 25°C).
Some key properties of the beta value:
There is a trade off between cost and accuracy with thermistors being the cheapest.
Written by John Main who has a degree in Electronic Engineering.
Note: Parts of this page were written using claude-instant as a research assistant.
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.