Reading temperature on AVR Atmega using a thermistor with NTCtemp library 02

Summary of Reading temperature on AVR Atmega using a thermistor with NTCtemp library 02


NTCtemp is an AVR library for reading thermistor temperature on Atmega micros. It supports Steinhart-Hart, Beta model, and a Lookup Table method to convert ADC readings to temperature, plus a digital IIR filter to smooth readings. Helpers include a Beta estimation tool (based on reprap instructions) and a spreadsheet that generates lookup tables using the Beta equation; the lookup method finds nearest lower ADC index, then interpolates between adjacent table temperatures for precise results.

Parts used in the NTCtemp project:

  • Thermistor (NTC)
  • Atmega microcontroller (AVR)
  • Analog input for ADC on Atmega
  • Resistor for thermistor voltage divider
  • NTCtemp AVR library (software)
  • Beta estimation helper spreadsheet
  • Make lookup table helper spreadsheet

A thermistor is a type of resistor whose resistance varies significantly with temperature, more so than in standard resistors.Reading temperature on AVR Atmega using a thermistor with NTCtemp library 02
NTCtemp is a simple AVR library to read temperature from a thermistor connected to an atmega micro.
The library implements three models convert adc value read from analog input to temperature:

  • Steinhart-Hart Thermistor Equation
  • Beta Model Equation
  • Lookup Table estimation

A digital iir filter is implemented to remove unwanted reading errors.
For Steinhart-Hart and Beta model equation, look at the previous article.
This version of the library implements a Lookup Table estimation method, which can be usefull if you do not want to include log function, and mantain you hex smaller.
To helper are provided:

  • the beta estimation helper
  • the make lookup table helper

The beta estimation helper, helps you to estimate beta value of unknown thermistor.
It is almost the same provided in the reprap wiki page here: http://reprap.org/wiki/MeasuringThermistorBeta. A readme file with instruction is provided with the spreadsheet of the helper
The make lookup table helper is a spreadsheet which generate the lookup table according to preselected values. Estimation is done using the Beta Model Equation: temperature (Celsius) = beta / ( beta / tref + ln ( R / rref ) ) – 273.15
Each element in the table is a temperature for a given ADC value.
Given the ADC value of the connected thermistor, we can measure the temperature using the lookup table.
Because we know the ADC value for the first element of the table, and the interval between values, we can select the nearest lower index for any given ADC.
Then we can select the upper and lower temperature values for the selected index.
On those values we do interpolation to obtain a correct temperature value.
We must calculate the inverval step, indicates the position between upper and lower index, of the current adc value.
Then we can do interpolation of values.
intervalstep = currentadcvalue-minindex
t = lowertemp + ((uppertemp-lowertemp)/lookupadcstep) * (intervalstep);
For more detail: Reading temperature on AVR Atmega using a thermistor with NTCtemp library 02 

Quick Solutions to Questions related to NTCtemp:

  • What temperature conversion models does NTCtemp implement?
    Steinhart-Hart equation, Beta Model equation, and a Lookup Table estimation method.
  • Can NTCtemp reduce noisy ADC readings?
    Yes, it includes a digital IIR filter to remove unwanted reading errors.
  • How does the lookup table method determine temperature?
    It stores temperature for ADC values, selects nearest lower index for the ADC reading, then interpolates between lower and upper table temperatures.
  • Do I need logarithmic functions for the lookup table method?
    No, the lookup table method is useful when you do not want to include log functions and want a smaller hex.
  • What helpers are provided with NTCtemp?
    A beta estimation helper and a make lookup table helper spreadsheet.
  • How is the lookup table generated?
    The spreadsheet generates the table using the Beta Model equation and preselected values; each table element is temperature for a given ADC value.
  • How is intervalstep calculated for interpolation?
    intervalstep = currentadcvalue - minindex, then used to interpolate between lower and upper temps over the lookup adc step.
  • What formula does the Beta helper use to estimate temperature?
    temperature (Celsius) = beta / ( beta / tref + ln ( R / rref ) ) - 273.15 as used by the spreadsheet.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top