# Temperature Measurement with NTCs

NTCs are often used as temperature sensors. To use them, we need to know how to calculate a temperature value out of the measured resistance.

## Temperature Measurement with NTC Thermistors

In the last tutorial we looked at different thermistor types and their applications. In this tutorial we will take a look at how we can acquire a temperature value using a NTC thermistor. The first step is to measure the resistance of the thermistor. This can be done using a simple voltage divider circuit as the one shown below. The voltage can then be measured with the ADC of a microcontroller and converted into the resistance value as it is shown in the tutorial on resistance measurement with voltage dividers. For test purposes you can also use a DMM to measure the resistance.

Once we measured the resistance of the NTC, we can continue with calculating the temperature value. While we could use a conversion table like it is typically given in the datasheet of the NTC thermistor, it would be a lot better to have a conversion formula, which we could use to calculate the temperature in software. The most popular model to describe the resistance temperature (R/T) curve of NTCs is the Steinhart-Hart equation. For lower precision NTCs oftentimes a related but less precise model that only uses a two-point calibration is used: the beta parameter equation. Let's have a look at how we can use them to calculate the temperature out of our measured resistance value.

## Temperature Calculation

Before we look at the formulas it is important to understand, that they all use the temperature in Kelvin (K). 0 K is the temperature at absolute zero, which corresponds to -273.15 °C. To use the formulas we need to convert between degree Celsius and kelvin:
$$\{T\}_K = \{t\}_{^\circ C} + 273.15$$ with $$\{T\}_K$$ in Kelvin and $$\{t\}_{^\circ C}$$ in degree Celsius
$$\{t\}_{^\circ C} = \{T\}_K - 273.15$$ with $$\{T\}_K$$ in Kelvin and $$\{t\}_{^\circ C}$$ in degree Celsius

With that said, let's look into the actual temperature calculation.

### Steinhart-Hart Equation

The Steinhart-Hart Equation was originally developed for temperature measurement in oceanography and was first published in 1968. The model provides a good approximation for the real NTC thermistor behavior in their typically working temperature range. Here it is:
$$T = {1 \over {a + b \ln R + c \ln ^ 3 R}}$$

The three coefficients $$a$$, $$b$$ and $$c$$ are usually given in the datasheet. They can be calculated from three known resistance temperature pairs which are measured during calibration. I will not cover this here. If the coefficients are not given, you can typically at least find the beta value $$B$$, which can be used with the beta equation.

If you have found the three coefficient for your NTC thermistor, you can use the equation to calculate the temperature for the measured resistance $$R$$. The only thing left to do is to convert the temperature value from kelvin to degree Celsius.

The graph shows an example for the R/T curve of a NTC thermistor. Insert the coefficients of your NTC thermistor to see the R/T curve calculated according to the Steinhart-Hart equation.

Minimum Temperature (°C)
Maximum Temperature (°C)
Parameter A
Parameter B
Parameter C

### Beta Parameter Equation

An alternative equation for calculating the temperature is the beta parameter equation. It uses a two-point calibration instead of the three points used in the Steinhart-Hart equation. This makes the calibration and the use of equation easier, but also a bit less precise. The equation requires two parameters: the resistance $$R_0$$ at a temperature $$T_0$$ and the beta parameter. For the resistance $$R_0$$ we can simply use the nominal resistance at 25 °C ($$T_0 = 298.15 K$$). The second parameter is the beta value which can be found in the datasheet. It is common practice to give a hint to the calibration points based on which the beta value was calculated. The beta value is e.g. given as $$B_{25/85}$$. This mean that the resistance value at 25 °C and at 85 °C was used to calculate the beta value.

With both parameters known we can use the following formula to convert the measured resistance value into a temperature:
$$T = {1 \over {{1 \over B } \cdot \ln {R \over R_0} + {1 \over T_0}}}$$

We can also calculate the resistance for a given temperature:
$$R = R_0 \cdot e ^ {B \cdot ({1 \over T} - {1 \over T_0})}$$

The graph below shows an R/T curve as it can be calculated using the beta equation.

Minimum Temperature (°C)
Maximum Temperature (°C)
Resistance at 25 °C
Beta

The beta equation is actually a simplified version of the Steinhart-Hart equation that drops the last correction term. One can calculate the equivalent coefficients for the Steinhart-Hart equation as following:
$$a = {1 \over T_0} - {\ln R_0 \over B}$$
$$b = {1 \over B}$$
$$c = 0$$

This is what I have done for the example values used in the graph for the Steinhart-Hart equation. Note, that a simple conversion won't improve the precision. When using these coefficients with the Steinhart-Hart equation the result is exactly the same as when using the simpler beta parameter equation.

## Working with unknown NTC thermistors

A common problem with many Arduino kits or sensor packs, is that there are no datasheets. If you have a NTC thermistors without a proper datasheet you are forced to calibrate it yourself. This is why I wan to explain how a simple two-point calibration to calculate the beta value of our NTC can look like.

The first step is to determine the nominal value at 25 °C. If it is not printed on the thermistor itself, just measure the resistance at room temperature. This gives you a resistance value close enough to the nominal value at 25 °C to guess the actual nominal value. A very common value is 10 kΩ at 25 °C. We can use the nominal value as our first calibration point.

To perform the two-point calibration we need a second resistance value for a known temperature. For better accuracy there should be a noticeable temperature difference between both calibration points. It is not a good decision to use 30 °C for the second calibration point as we already used 25 °C for our first calibration point. What is an appropriate temperature for the second calibration point? Well, it is time to head over to the kitchen to boil a pot of water. This gives us temperature of around 100 °C. This will be our second calibration point. Simply use a DMM to measure the resistance at a 100 °C. Make sure, that NTC does not touch the pot.

Using both calibrations points we can finally calculate our beta value:
$$B_{25/100} = {\ln {R \over R_0} \over {{1 \over T} - {1 \over T_0}}}$$

$$T_0$$ and $$R_0$$ are the values of our first calibration point. $$R$$ is the measured resistance at 100 °C ($$T = 373.15 K$$).

## Linearity

Let's finish off, by looking at the linearity. As we know neither the R/T curve of the NTC nor the U/R curve of the voltage divider is linear. Luckily, the non-linearity of the voltage divider and the NTC thermistor, cancel each other out for a certain degree. We get an S-shaped voltage temperature curve:

Input Voltage
Resistor R2
Minimum Temperature (°C)
Maximum Temperature (°C)
Resistance at 25 °C
Beta

We can improve the linearity at the cost of sensitivity by adjusting the value of $$R_2$$. The following formula gives us the optimal value for $$R_2$$:
$$R_2 = R_T \cdot {{B - 2T} \over {B + 2T}}$$

If we want a good linearity in the range from 0 °C to 50°C we calculate the value for 25 °C (T = 298.15 K):
$$R_2 = 10 kΩ \cdot {{4300 K - 2 \cdot 298.5 K} \over {4300 K + 2 \cdot 298.5 K}} \approx 7.6 kΩ$$

In case of a different center point, we need to use the beta equation to calculate the expected resistance $$R_T$$ first. At 25 °C $$R_T$$ is simply the nominal resistance of the NTC.