TDK Electronics · TDK Europe

NTC Thermistor Class Library for Python 3 or C++

How to read out and trim NTC thermistors digitally using Python 3 or C++

Combining low power consumption, high sensitivity, and signal stability makes NTC thermistors the most popular choice for temperature sensing in automotive battery management, motor and climate control as well as factory automation, and field instrumentation.

The following application notes explain the basic circuit design considerations for converting the resistance change of the NTC thermistor into a digital temperature reading.

Alternative resistance-to-temperature calculations are compared: Exponential curves, lookup tables, and the Steinhart-Hart equation. For all these cases, software class code is available for download below that can be adapted for other applications and other NTC thermistor curves in individual projects on platforms like Raspberry Pi, Arduino, or microcontrollers running CircuitPython or C++.

The Python and C++ class definitions for NTC thermistors enable developers to calculate temperatures from resistance readings and vice versa. Four different classes are available in three independent libraries:

  1. NTC.py or NTC.cpp: A Simple B-Value based calculation and a two-point definition of R/T curves
  2. NTC_SH.py or NTC_SH.cpp: The Steinhart-Hart model with three data points
  3. NTC_LT.py or NTC_LT.cpp: A lookup table class using multiple data points

All class definitions include a class function for a single-point software trimming of a given NTC thermistor. One code example shows how the CSV output from TDK’s NTC R/T Calculation 5.0 - Web-based Application can be used to define the classes for a specific NTC thermistor. A second code example demonstrates the class usage in a typical circuit with NTC thermistor and analog-to-digital converter. All class definitions include a class function for a single-point software trimming of a given NTC thermistor.


Downloads

 Appnote Image

Detailed information on the basics of digital readout and trimming of NTC thermistors

PDF - 598.6 KB Download
 Appnote Image

Detailed information on the circuit optimization for digital readout of NTC thermistors

PDF - 472.7 KB Download
 Class Lib image

Download the Python 3 classes tool here

ZIP - 13.8 KB Download
 Class Lib image

Download the C++ classes tool here

ZIP - 17.5 KB Download