Summary of esp8266/Arduino NTC (Negative Temperature Coefficient) library
This article describes an Arduino library for ESP8266 that converts ADC readings from NTC thermistors into temperature using the Steinhart-Hart or Beta Model equations. It details resistor calculations for voltage limits, supports both internal and external (ADS1015) ADCs, and includes a digital IIR filter to reduce noise. The solution outputs temperatures in Celsius or Fahrenheit.
Parts used in the NTC Thermistor Temperature Library:
- NTC Negative Temperature Coefficient thermistor
- ESP8266 microcontroller with 10-bit ADC
- Pullup resistor (e.g., 220k ohm)
- ADS1015 12-bit analog-to-digital converter
- Adafruit ADS1X15 library
- Digital IIR filter
- Atom development board
- PlatformIO environment
- esp_lib_ads1x15ntc_01.zip code package
A thermistor is a type of negative coefficient resistor whose resistance is dependent on temperature, more so than in standard resistors. The resistance of a NTC Negative Temperature Coefficient thermistor (https://en.wikipedia.org/wiki/Thermistor) decreases as temperature rises. The Steinhart-Hart Thermistor Equation or the Beta Model Equation can be used to correlate the thermistor resistance to temperature to which the sensor is exposed.
The library implements the Steinhart-Hart Thermistor Equation or the Beta Model Equation to convert adc value read from analog input to temperature.
It output temperatures in Celsius or Fahrenheit.
The ESP8266 comes with a 10bit ADC, 0 to 1V, one can use the ESP8266 ADC for this library.
Suppose you are going to the internal ADC, and that NTC is going to be used between -20 and +100 degree Celsius. The NTC resistance by datasheet at -20 degree is 100k, and at 100 degree 100. To evaluate the pullup resistor you have to consider that the Voltage output at the ADC pin will be
Vout = Vpullup*(Rntc/Rntc+Rpullup)
We have to consider the max Vout, that comes from the max resistance given by the NTC
Voutmax = Vpullup*Rntcmax/(Rntcmax+Rpullup)
We have to chose a Rpullup such that Voutmax < 1V, so:
Rpullup = Vpullup*Rntcmax/Voutmax – Rntcmax
Subsitute with the sample NTC we are considering:
Rpullup = 3.3*100000/1 – 100000 = 230000.
A 220k resistor would do the job.
In the example i propose here I am using a ADS1015 12 bit analog to digital comparator, that is much more accurate than the internal ESP8266 ADC.
I am using the Adafruit ADS1X15 library for this IC, on top of that library I’ve build an helper to just convert the ADC raw value that comes from the ADS1x15 to a resistance or voltage value.

Once we’ve acquired the NTC resistance we can use the Steinhart-Hart Thermistor Equation or the Beta Model Equation to convert the resistance value to temperature.
A digital iir filter is implemented to remove unwanted reading errors.
This library was developed on Atom+PlatformIO, compiled esp8266/Arduino.
Code
Read More: esp8266/Arduino NTC (Negative Temperature Coefficient) library
-
How does the resistance of an NTC thermistor change with temperature?
The resistance decreases as the temperature rises. -
What equations are used to correlate thermistor resistance to temperature?
The Steinhart-Hart Thermistor Equation or the Beta Model Equation is used. -
Can this library output temperatures in units other than Celsius?
Yes, it can output temperatures in either Celsius or Fahrenheit. -
How do you calculate the pullup resistor value for the ADC pin?
You calculate it using the formula Rpullup = Vpullup*Rntcmax/Voutmax - Rntcmax to ensure Voutmax is less than 1V. -
Why might someone use an ADS1015 instead of the internal ESP8266 ADC?
The ADS1015 is a 12-bit converter that is much more accurate than the internal 10-bit ESP8266 ADC. -
What method is implemented to remove unwanted reading errors?
A digital iir filter is implemented to remove unwanted reading errors. -
On what hardware and environment was this library developed?
The library was developed on Atom+PlatformIO and compiled for esp8266/Arduino. -
What range of temperatures is considered for the sample NTC evaluation?
The evaluation considers the NTC being used between negative 20 and plus 100 degrees Celsius.
