Convert nonlinear NTC thermistor curves into fast firmware lookup tables
Negative Temperature Coefficient (NTC) thermistors exhibit a steep exponential resistance drop as temperature rises. On resource-constrained microcontrollers without hardware floating-point units, evaluating log() and cubic Steinhart-Hart terms in an interrupt handler wastes cycles and flash.
By generating a power-of-two spaced C99 int16_t lookup table (storing temperatures in tenths of °C) paired with shift-and-interpolate arithmetic, firmware converts any raw 10-, 12- or 16-bit ADC reading into accurate temperature in under 20 CPU instructions.
Formulas
Beta model: R(T) = R25 × exp[B × (1/T − 1/298.15)]Steinhart-Hart: 1/T = A + B·ln(R) + C·(ln(R))³NTC-low divider: V_adc = V_ref × R_ntc ÷ (R_pullup + R_ntc)
Worked example
A 10 kΩ B3950 NTC with a 10 kΩ pull-up on a 3.3 V 12-bit ADC sits at exactly 1.650 V (ADC code 2,048) at 25 °C, yielding −36.5 mV/°C sensitivity and 0.022 °C/LSB resolution with only 0.27 mW of self-heating.