NTC Thermistor Steinhart-Hart Curve & C99 LUT Generator

Model NTC Beta or Steinhart-Hart curves, check pull-up divider voltage and sensitivity, and generate copyable C99 int16 lookup tables and Python code.

Jump to results

Inputs

Thermistor parameters
Divider & firmware LUT
Match R25 near your primary target temperature.

Results

Estimates
Resistance at 25 °C10 kΩ
Divider output voltage
1.65 V
Expected 12-bit ADC code
2,048 / 4,095
Voltage sensitivity
-36.66 mV/°C
Resolution at spot temp
0.022 °C/LSB
Self-heating power
0.272 mW
Firmware LUT entries
33 × int16_t (66 bytes)
NTC resistance & ADC divider voltage curve (−40 °C to 125 °C)
-40°C 0°C 25°C 60°C 100°C 125°C10^6Ω10^2ΩIndigo: log R(T) · Amber: V_adc(T)
Temperature vs. resistance & ADC curve
Temp (°C)NTC ResistanceV_adc (V)12-bit ADC
-40 °C401.86 kΩ3.223,996
-25 °C144.32 kΩ3.0863,830
-10 °C58.25 kΩ2.8163,495
0 °C33.62 kΩ2.5433,156
15 °C15.84 kΩ2.0232,510
25 °C10 kΩ1.652,048
40 °C5.3 kΩ1.1431,419
55 °C2.98 kΩ0.757940
70 °C1.76 kΩ0.494613
85 °C1.09 kΩ0.323401
100 °C697.52 Ω0.215267
125 °C358.83 Ω0.114142
Generated C99 firmware LUT & Python converter
#include <stdint.h>

/* OhmBitLab NTC LUT: R25=10000 ohm, B=3950 K, R_pullup=10000 ohm, ntc-low, 12-bit ADC */
#define NTC_LUT_SIZE 33U
#define NTC_ADC_SHIFT 7U
#define NTC_ADC_STEP (1U << NTC_ADC_SHIFT)

/* Temperature in tenths of deg C (e.g. 250 = 25.0 C) indexed by (adc >> NTC_ADC_SHIFT) */
static const int16_t ntc_temp_c_x10[NTC_LUT_SIZE] = {
   1500,  1293,  1016,   866,   763,   685,   621,   567,
    520,   477,   439,   403,   369,   338,   308,   278,
    250,   222,   194,   167,   139,   111,    82,    53,
     22,   -12,   -47,   -87,  -132,  -186,  -257,  -365,
   -500
};

int16_t ntc_adc_to_c_x10(uint16_t adc) {
  uint16_t idx = adc >> NTC_ADC_SHIFT;
  if (idx >= NTC_LUT_SIZE - 1U) return ntc_temp_c_x10[NTC_LUT_SIZE - 1U];
  int32_t t0 = ntc_temp_c_x10[idx];
  int32_t t1 = ntc_temp_c_x10[idx + 1U];
  uint16_t frac = adc & (NTC_ADC_STEP - 1U);
  return (int16_t)(t0 + (((t1 - t0) * (int32_t)frac) >> NTC_ADC_SHIFT));
}
import math

R_PULLUP = 10000
ADC_MAX = 4095
TOPOLOGY = "ntc-low"
R25 = 10000
BETA = 3950

def adc_to_temp_c(adc: int) -> float:
    if adc <= 0 or adc >= ADC_MAX:
        raise ValueError("ADC reading saturated at rail")
    ratio = adc / ADC_MAX
    r_ntc = R_PULLUP * ratio / (1.0 - ratio) if TOPOLOGY == "ntc-low" else R_PULLUP * (1.0 - ratio) / ratio
    inv_t = (1.0 / 298.15) + math.log(r_ntc / R25) / BETA
    return (1.0 / inv_t) - 273.15

# Example spot check at 25 C -> ADC ~ 2048
print(f"{adc_to_temp_c(2048):.2f} C")

Choose a bias resistor near the NTC resistance at your most critical temperature to maximize mV/°C sensitivity and minimize quantization error.

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.

Frequently asked questions

Should I use the Beta equation or Steinhart-Hart coefficients?

The Beta equation is typically accurate within ±0.5–1 °C across a narrow band (0–85 °C). Use three-term Steinhart-Hart A/B/C coefficients when spanning −40 °C to 150 °C or 3D-printer hotend ranges.

How do I pick the best pull-up resistor value for an NTC?

Set the pull-up resistor equal to the NTC resistance at the midpoint of your critical measurement range. That places V_adc near Vref/2 where dV/dT sensitivity peaks.

Why does the generated C99 LUT use 33, 65 or 129 points?

Having (2^n + 1) table points makes the ADC step size an exact power of two, allowing the MCU to compute table index and interpolation fraction using fast bit-shifts instead of integer division.