Thermistors are simple to integrate in embedded designs but their temperature
response can be challenging to interpret. A lookup table is a convenient way
to convert a thermistor’s ADC reading to temperature.

A thermistor’s resistance varies with temperature. As an example, assume T1
in the circuit above to be part number NTCLE413E2103H400 from
Vishay/Dale Inc. This thermistor has the resistive characteristics shown
in the table below. At cold temperatures, the resistance is very large
but decreases non-linearly as temperature increases.

The complete datasheet for the part referenced is available here. The
voltage at the ADC input is calculated using a voltage divider:

When the T1 resistance is large, the voltage at the ADC input is close to
zero. As the thermistor gets warmer, the voltage gets closer to V1. The
transition, however, is non-linear. This means for embedded firmware to
interpret the ADC reading as a temperature, it needs to either calculate
a complicated transfer function or approximate the temperature using a lookup
table and linear extrapolation.

Lookup Tables

A lookup table consists of two (or more) columns of data, in this case, a column
for the voltage representing the output of the sensing circuit and a column for
the temperature.

Creating the Lookup Table

A spreadsheet program is an excellent tool to create (and update) the lookup
table and can be designed to easily copy and paste as a data table in a C
file. The image below shows a screen shot of an example. The highlighted
portion can be directly copied and pasted into the code.

(The source file for the above image can be downloaded from
this link.)

The table contains distinct points on the voltage temperature curve. Linear
extrapolation is used to estimate the temperature between the points.

Extrapolating the Data

To extrapolate the data between points, the firmware first needs to select two
data points. It must scan the values in the x-column and find the two values
directly above and below the input. The firmware then uses the point slope
formula to extrapolate the temperature value.

The values x0, x1, y0, and y1 are taken from the lookup table. The x value is
the input from the ADC, and the y value is the temperature. The code below
implements a lookup table using floating point variables.

Conclusion

Thermistors are great to use in embedded designs because they come in a variety
of shapes and sizes and are easy to interface with a microcontroller ADC input. The
main design challenge is interpreting the non-linear temperature response. Taking
the temperature response and creating a lookup table using a spreadsheet is a
relatively easy way of getting the table in C code. The firmware then just
needs to use linear extrapolation to approximate the temperature between
points in the lookup table.

Thermistors are simple to integrate in embedded designs but their temperature
response can be challenging to interpret. A lookup table is a convenient way
to convert a thermistor’s ADC reading to temperature.