All articles

    The NTC Thermistor: Measuring Temperature with Just a Resistor

    How an NTC thermistor measures temperature: resistance falls as it heats, the 10k value at 25 °C and the B coefficient, wiring it as a voltage divider with the voltages at different temperatures, the Beta equation in code with a worked example, accuracy and self-heating, the ESP32 and its ADC, calibration, reading faults, the inrush-limiting NTC, and a comparison with the DS18B20.

    Updated 6 min read

    A thermistor is a resistor whose value changes with temperature. It's very cheap and found everywhere: chargers, batteries, 3D printers and air conditioners. The most common type is the NTC: when the temperature rises, the resistance falls.

    The hotter it gets, the lower the resistance, and the relationship isn't a straight line
    The hotter it gets, the lower the resistance, and the relationship isn't a straight line

    The two key specifications

    • R25: the resistance at 25 °C. The most common is 10k.
    • B (Beta): describes the shape of the curve. A common value is 3950 (there are also 3435 and 3380). Get it from the seller or the datasheet.

    Don't know its value? Measure it with a multimeter in a room at about 25 °C: if it reads about 10k, it's 10k, and if 100k, it's 100k. And don't hold it in your fingers while measuring, because your hand's warmth changes the reading within seconds, which is exactly what makes it a sensor.

    Wiring: a voltage divider

    A fixed resistor on top and the thermistor below, the midpoint to A0, and the hotter it gets the lower the voltage
    A fixed resistor on top and the thermistor below, the midpoint to A0, and the hotter it gets the lower the voltage

    A fixed resistor of the same value as the thermistor gives you the best sensitivity around 25 °C. See the voltage divider and the divider calculator.

    The figures in the diagram show why the thermistor is sensitive: from zero to 50 °C, the voltage moves from 3.85 to 1.32 V, which is about 50 mV per degree, and the ADC on the Uno has a step of about 5 mV, so it sees the change easily. And if you want to focus on a high temperature (such as 100 °C), choose a fixed resistor close to the thermistor's value at that temperature.

    The code (the Beta equation)

    const float R_FIXED = 10000.0;
    const float R0 = 10000.0, T0 = 298.15;  // 25 °C in kelvin
    const float B = 3950.0;
    
    void loop() {
      int raw = analogRead(A0);
      float r = R_FIXED * raw / (1023.0 - raw);   // the thermistor's resistance
      float tK = 1.0 / (1.0 / T0 + log(r / R0) / B);
      float tC = tK - 273.15;
      Serial.println(tC, 1);
      delay(1000);
    }

    This equation assumes the thermistor is at the bottom (towards ground), as in the diagram. If you reverse the order, reverse the calculation of r.

    A worked example

    A reading of raw = 300:

    1. The resistance: 10000 × 300 ÷ 723 ≈ 4150 Ω.
    2. log(4150 ÷ 10000) ≈ −0.88, divided by 3950 ≈ −0.000223.
    3. 1 ÷ 298.15 ≈ 0.003354, and the sum ≈ 0.003131.
    4. 1 ÷ 0.003131 ≈ 319.4 K → about 46 °C.

    And if you want to see these numbers without the arithmetic, use the thermistor calculator.

    Averaging the readings

    A single reading jitters by a degree or two from noise. Take an average:

    long sum = 0;
    for (int i = 0; i < 16; i++) sum += analogRead(A0);
    float raw = sum / 16.0;

    Accuracy

    • The Beta equation is approximate: accurate around 25 °C, and drifting a little at the extremes. For higher accuracy there's the Steinhart-Hart equation with three constants.
    • The tolerance of the thermistor itself (1% or 5%) and of the fixed resistor both matter. A 1% resistor is better.
    • The ADC reference: in this circuit it's the ratio that's measured, so a change in the 5 V has little effect as long as the divider and the ADC are on the same voltage. See the ADC.
    • Self-heating: the current through the thermistor warms it. Larger resistances (for example a 100k thermistor with 100k) reduce this.
    • Take an average of several readings.

    Self-heating in numbers

    With 10k and 10k on 5 V, the current is a quarter of a milliamp, and the power in the thermistor is about 0.6 mW. A small thermistor in air warms by roughly one degree per 1–2 mW, so the error is less than half a degree. In a battery project, you can power the divider from a GPIO pin and switch it on only at the moment of reading, saving power and heating at once.

    Calibration

    Put the thermistor in a glass of ice and water (very nearly exactly zero degrees), then in water with a trusted thermometer at about 50. If both readings are off by the same amount, correct by adding a number. If the error grows with temperature, the B value is probably wrong: try 3435 or 3380 instead of 3950.

    With an ESP32

    The ESP32's ADC is 12-bit (0–4095), so change 1023 to 4095. But it isn't linear at the extremes (near zero and near 3.3 V). It's better to use analogReadMilliVolts() and calculate the resistance from the voltage, and to power the divider from 3.3 V.

    Reading faults

    ReadingUsual cause
    −273 or a very strange valueThe thermistor is disconnected or shorted
    The temperature falls when you heat itThe thermistor and fixed resistor are swapped
    A constant error of a few degreesThe R25 value or the fixed resistor is wrong
    The error grows away from 25The B value is wrong
    The reading jumps aroundNoise; take an average and add a 100 nF capacitor on A0

    A completely different NTC: inrush protection

    If you open a power supply you'll sometimes find a large black disc marked something like 5D-9. That's an NTC too, but with a different job: when cold its resistance is a few ohms, so it limits the high current at switch-on while charging the large capacitors. After a few seconds it warms from the current and its resistance falls, so it wastes almost nothing. It's not a measuring sensor.

    And there's the opposite, the PTC: its resistance rises with temperature. One example is the self-resetting fuse (polyfuse); see the fuse article.

    NTC or DS18B20?

    NTCDS18B20
    PriceMuch cheaperMore expensive
    SignalAnalogDigital
    Accuracy without calibrationModerateAbout ±0.5
    High temperatureSome types go to 250 °C and beyondUp to 125
    SpeedFast (depending on its size)Conversion can take 750 ms

    Uses

    • Protecting batteries while charging.
    • 3D printers (a 100k thermistor in the hotend).
    • Switching on a fan when the temperature rises. With a comparator it can even be done without a microcontroller.

    FAQ

    Can I extend the thermistor's wire? Yes, a metre or two is fine, because the wire's resistance is tiny next to 10k. For longer, add a 100 nF capacitor at A0 against noise.

    The printer thermistor is 100k; what do I change? Set R0 and R_FIXED to 100000, and find B for its type (many are 3950).

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.