How To Measure Temperature With An NTC Thermistor
How To Measure Temperature With An NTC Thermistor
Do you ever wonder how some devices such as thermostats, car engines, overs, and 3D printer heat beds
measure temperature? This project shows you how!
In many projects, knowing the temperature is a useful piece of data. Knowing temperature helps us to
regulate room temperature, prevent engine overheating, ensure that a 3D printer bed is hot enough for
materials like ABS to stick to its surface, and keep food from burning.
In this project, we focus on one type of sensor that can measure temperature: a thermistor.
A thermistor exhibits resistance with higher sensitivity to temperature compared to other types of resistors.
Using an Arduino, we can measure and process the thermistor’s readings and then convert them into more
common temperature units.
1 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
BOM
• Arduino
◦ MEGA or Uno, or your favorite �avor of Arduino
• Some jumper wires
• Solder and soldering iron (these are just in case your thermistor doesn't �t easily into the Arduino
headers
• Arduino IDE
Typically, with applications using a resistor, you want to avoid having the resistance change as the
temperature changes. While this isn’t exactly possible in real life, you can make it so that only a small change
in resistance corresponds with a large change of temperature. If you couldn’t do that, resistors could really
wreak havoc in circuits. For example, an LED that brightens and dims as the ambient temperature changes.
So what do you do if you actually want an LED’s brightness to be a function of temperature? Well, you’ll need a
thermistor. Thermistors have a large change in resistance with just a small change of temperature. To
illustrate this concept, see Figure 1 below, which shows the typical curve of a thermistor:
2 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
A thermistor can be easily tailored to different ranges, depending on the one you purchase. As you can see
above, as the temperature rises, the resistance lowers. This is a main property of Negative Temperature
Coe�cient resistors (NTC).
Thermistors are also available as Positive Temperature Coe�cient (PTC). PTCs work in a way that as the
temperature rises, the resistance increases. However, note that PTC thermistors have a sort of tipping point
and can greatly affect the resistance at some temperatures, making the PTC thermistor a bit more
challenging with which to interface. Because of this, most low-cost temperature measurements utilize NTC
thermistors.
That said, assume that we'll be referring to NTC type thermistors for the remainder of the article.
Now that we covered the general behavior of thermistors, the next question on your mind may be how we
could possibly measure temperature with an Arduino. The curve in the graph above is nonlinear, so a simple
linear equation does not seem possible. (In reality, we can work out an equation. More on this later in the
article.)
So what to do?
Before we continue, try to think about how you would do this with an Arduino or even just a circuit without a
microprocessor component.
There are a few ways you can approach this problem. Four options are discussed below. This is far from an
exhaustive list of every technique out there, but it covers some popular approaches.
Approach One
Some manufacturers provide an entire chart mapping out a speci�c integer range of the typical values for
temperature and resistance. One such thermistor can be seen on this datasheet, written by the company
Vishay.
But again, the question arises of how you could do this in the Arduino. All of these values would need to be
hard coded into a huge lookup table or very long "switch…case" or "if…then" control structures.
And if the manufacturer doesn’t provide a lookup table, each point needs to be measured by you in order to
generate the data. Sounds like a programming headache, right? However, this method does have its place. For
instance, if your project at hand check only a few points or stay within a small range, this may be the way to
go. An example would be if you only want to measure when the values fall within select temperature ranges
with an LED that lights up to indicate each time it happened.
In this project, however, we want to measure a near-continuous range and send it to the serial monitor,
3 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
Approach Two
Another approach is to “linearize” the response from the thermistor by adding external circuitry by connecting
a resistor in parallel with the thermistor. Some ICs already to this for you.
Choosing the correct value and determining how to pick and linearize a region is an article in its own right.
Approach two is a great �t if your microprocessor lack �oating point precision (such as PICAXE) because it
simpli�es a range of temperature to a linear response, and also makes designing a circuit without a
microprocessor much easier.
For this project, we have a microprocessor and will make use of the entire range, so again this approach won’t
work for us.
Approach Three
If you’re a glutton for punishment, you could take the table data from the datasheet or, even more time-
consuming, generate your own data you develop with independent measurements to recreate the plot in a
program like Excel. From there, you could us the curve �tting feature to generate a curve formula. This
provides you with a handy formula in your program, but it takes time and preprocessing of data.
We’d rather not be stuck analyzing all of this data, although approach three is a legitimate approach. Also,
every thermistor is a bit different (not a huge issue if the the tolerance level is pretty low).
Approach Four
There exists a general curve �tting formula, known as the Steinhart-Hart equation, for devices like
thermistors. There are different versions where the squared and cubed terms are both used. Here’s one
version of the equation:
This general curve �tting equation can accommodate all NTC type resistors, due to the approximation of the
relationship of resistance and temperature is su�cient for most applications.
Note that the equation requires three constants: A, B, and C. These constants are different for each thermistor
and have to be either given or calculated. With three unknowns, you need three measurements of resistance
at a certain temperature. From there, these measurements create three equations to solve for these
constants.
Luckily, there is a simpler equation that is less accurate but has only one constant. The constant is denoted by
β, and so the equation is known as the β equation.
where RO refers to the resistance at your reference temperature TO (e.g., the resistance at room temperature).
β is usually provided in a datasheet. If it is not, you only need one measurement (one equation) to calculate
for it.
And so we have found it. This is the equation, and the approach, that we will use for our thermistor interface,
because it is pretty straightforward to code, while also being simplest one we have yet to �nd that doesn’t
need to linearize the thermistor’s response.
4 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
Since we’ve found the correct approach, we need to now �gure out how to actually measure the resistance
with our Arduino before we can plug it into the β equation. This can be done using a voltage divider:
Above is our interface circuit for our thermistor. Each time the thermistor senses a change in temperature, it
will be re�ected in the output voltage.
However, we do not want Vout as the answer - we want Rthermistor. We’ll solve for that with:
We’re about to perfect, but we need to measure our voltage output as well as the supply voltage. This is where
the Arduino’s built-in ADC comes in handy.
We can represent the voltage as a digital number within a certain scale. So, our equation winds up as:
This works out mathematically due to the fact that no matter how we represent the voltage (in volts or in
digital units), these units cancel out top and bottom in the fraction, leaving a dimensionless number. After
that, multiply by a resistance to yield your answer in ohms.
Dmax for us will be 1023 because it is the highest number generated by our 10-bit ADC. Dmeasured will be set
as our measured ADC value, ranging from be as low as zero to as high as 1023.
Wiring It Up
We will use a 10K ohm thermistor, as well as a 10k ohm resistor for Rbalance in our voltage divider. No β was
given, so that needs to be calculated.
5 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
6 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
Arduino Code
The code below is laid out with helpful comments to help guide you through the logic.
The code measures the divider's voltage, calculates the temperature, and displays this in the serial terminal.
There are also some "if…then" statements sprinkled in for fun, to show how you can act upon a range of
temperatures and a single data point.
Copy Code
/*
================================================================================
File........... Thermistor_Demo_Code
Purpose........ Thermistor demonstration code
Author......... Joseph Corleto
E-mail......... [email protected]
Started........ 7/25/2016
Finished....... 7/25/2016
Updated........ --/--/----
================================================================================
Notes
================================================================================
================================================================================
Updates
================================================================================
*/
//===============================================================================
// Header Files
//===============================================================================
//===============================================================================
// Constants
//===============================================================================
//Thermistor related:
7 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
/* Here we have a few constants that make editing the code easier. I will go
through them one by one.
A reading from the ADC might give one value at one sample and then a little
different the next time around. To eliminate noisy readings, we can sample
the ADC pin a few times and then average the samples to get something more
Download the code for this project here.
Next Steps
This project shows a pretty simple way of learning to measure temperature with a cheap thermistor. Want to
improve upon the setup? Here are a couple of ideas:
• Put a small capacitor parallel to the output voltage. Doing so would stabilize the voltage and could even
eliminate the need to average so many samples (as in the code).
• Use precision resistors (better than 1%) to give you a more consistent and predictable measurement.
Note that if you need absolute critical temperature measurement, the self-heating of the thermistor can
in�uence measurements. This particular project does not compensate for self-heating.
If you’ve completed this project, you should have a better idea on how you can measure temperature in your
future projects!
8 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
arduino-ntc-thermistor
Share this project
See project notes
Edit this project
AREF D11
R1
D10
T
D9
Arduino UNO
D8
A0 D7
A1 D6
R2
A2 D5
ARDUINO UNO R3 ATMEGA328P BOARD JUMPER WIRE M TO M VARIOUS 60/40 370 3% .015DIA
Arduino Adafruit Industries LLC Harimatec Inc.
More Info View More Details ₹ 427.04 View More Details ₹ 3,079.84
9 of 10 28/01/2025, 4:12 PM
How to Measure Temperature with an NTC Thermistor https://www.digikey.in/en/maker/projects/how-to-measure-temperature-...
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community
and technical resource.
Visit TechForum
10 of 10 28/01/2025, 4:12 PM