How a Thermistor Sensor Actually Works

A thermistor sensor is a thermally sensitive resistor whose electrical resistance changes predictably with temperature. The most common variant in embedded DIY electronics is the NTC (Negative Temperature Coefficient) thermistor, such as the ubiquitous 10K 3950 glass-bead model manufactured by companies like EPCOS or Amphenol. As the ambient temperature rises, the semiconductor material inside the bead releases more charge carriers, causing its electrical resistance to drop exponentially. According to Ametherm's NTC design guides, this non-linear response provides high sensitivity at lower temperatures but requires mathematical linearization in firmware.

Unlike digital sensors (e.g., the DS18B20) that output serial data over a 1-Wire bus, a raw thermistor sensor outputs resistance, not voltage or current. Because microcontrollers cannot measure resistance directly, you must force a known current through the thermistor using a voltage divider circuit. This converts the changing resistance into a measurable analog voltage, which the microcontroller's ADC (Analog-to-Digital Converter) then samples as a raw integer value.

Wiring the Voltage Divider and Pinout

To interface the thermistor sensor with an ESP32 or Arduino, you need a single fixed-value pull-up or pull-down resistor to create the voltage divider. A 10KΩ 1% tolerance metal film resistor is the standard choice for a 10K NTC thermistor, as it centers the voltage output at exactly 1.65V when the thermistor is at its nominal 25°C rating. This is critical for the ESP32, whose ADC is notoriously non-linear near the 0V and 3.3V rails but highly accurate in the mid-range.

ESP32 Thermistor Voltage Divider Pinout
ESP32 Pin Component Leg Supply Range Wiring Notes
3V3 10KΩ Fixed Resistor (Leg 1) 3.0V - 3.6V Do NOT use the 5V/VIN pin; exceeding 3.3V on the ADC pin will destroy the ESP32 GPIO.
GPIO 34 (ADC1_CH6) Thermistor (Leg 1) + 10KΩ Resistor (Leg 2) 0V - 3.3V GPIO 34 is input-only and lacks internal pull-ups, making it ideal for clean analog reads.
GND Thermistor (Leg 2) 0V Ensure a solid ground connection; ground loops will introduce analog noise.
Callout Tip: If you are using a 5V Arduino Uno, wire the 10K fixed resistor to the 5V rail and the thermistor to GND, reading the center point on A0. The math remains identical, but your $V_{in}$ variable in the code must be changed to 5.0.

The Math: Converting Raw ADC to Celsius

Getting a physical temperature reading requires a three-step conversion pipeline: Raw ADC Integer → Analog Voltage → Thermistor Resistance → Celsius. The final step relies on the Beta parameter equation (a simplified version of the Steinhart-Hart equation), which is highly accurate for standard 3950 NTC beads between -20°C and +105°C. For extreme precision across wider ranges, Omega Engineering recommends the full three-coefficient Steinhart-Hart model, but the Beta equation is sufficient for 95% of hobbyist and industrial monitoring tasks.

Step 1: ADC to Voltage
$V_{out} = \text{ADC}_{raw} \times \frac{V_{in}}{\text{ADC}_{max}}$

Step 2: Voltage to Resistance
Using the voltage divider rule solved for the thermistor (assuming the fixed resistor is tied to VCC and the thermistor is tied to GND):
$R_{therm} = R_{series} \times \frac{V_{out}}{V_{in} - V_{out}}$

Step 3: Resistance to Temperature (Beta Equation)
$\frac{1}{T} = \frac{1}{T_0} + \frac{1}{\beta} \ln\left(\frac{R_{therm}}{R_0}\right)$
Where $T_0$ is 298.15K (25°C), $R_0$ is 10,000Ω, and $\beta$ is 3950.

Below is the complete, copy-pasteable C++ implementation for the ESP32 Arduino core. Note the bounds-checking on the ADC read to prevent divide-by-zero errors when the thermistor is shorted or disconnected.


// Thermistor Sensor ESP32 Implementation
const int THERMISTOR_PIN = 34;
const float V_IN = 3.3;
const int ADC_MAX = 4095;
const float R_SERIES = 10000.0; // 10K pull-up resistor
const float R_NOMINAL = 10000.0; // Thermistor resistance at 25C
const float T_NOMINAL = 25.0;    // 25C in Celsius
const float B_COEFFICIENT = 3950.0; // Beta value for standard 3950 NTC

void setup() {
  Serial.begin(115200);
  analogReadResolution(12); // Ensure 12-bit resolution on ESP32
  pinMode(THERMISTOR_PIN, INPUT);
}

void loop() {
  int rawADC = analogRead(THERMISTOR_PIN);
  
  // Prevent divide-by-zero if thermistor is disconnected (reads 4095)
  if (rawADC >= ADC_MAX) {
    Serial.println("Error: Thermistor disconnected or shorted to VCC");
    delay(1000);
    return;
  }
  
  // Prevent math domain error if shorted to GND (reads 0)
  if (rawADC <= 0) {
    Serial.println("Error: Thermistor shorted to GND");
    delay(1000);
    return;
  }

  // Step 1 & 2: Convert ADC to Resistance
  float voltage = rawADC * (V_IN / ADC_MAX);
  float resistance = R_SERIES * (voltage / (V_IN - voltage));

  // Step 3: Beta Equation to calculate Temperature in Kelvin
  float steinhart;
  steinhart = resistance / R_NOMINAL;     // (R/Ro)
  steinhart = log(steinhart);             // ln(R/Ro)
  steinhart /= B_COEFFICIENT;             // 1/B * ln(R/Ro)
  steinhart += 1.0 / (T_NOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart;            // Invert to get Kelvin
  
  float tempC = steinhart - 273.15;       // Convert to Celsius
  float tempF = (tempC * 9.0) / 5.0 + 32.0; // Convert to Fahrenheit

  Serial.print("Resistance: ");
  Serial.print(resistance);
  Serial.print(" ohms | Temp: ");
  Serial.print(tempC);
  Serial.println(" C");

  delay(500);
}

Interference, Self-Heating, and Calibration

Analog sensors are highly susceptible to environmental and electrical interference. When debugging a thermistor sensor circuit, the three most common failure modes are EMI injection, ADC reference drift, and self-heating.

1. Self-Heating Errors: Current flowing through the voltage divider dissipates power as heat inside the tiny glass bead. If you use a 10K series resistor on a 5V Arduino, the thermistor dissipates roughly 0.6mW at 25°C. In still air, this can artificially raise the bead temperature by 1°C to 2°C. Fix: Increase the series resistor to 47KΩ or 100KΩ to limit current, or pulse the power pin via a MOSFET so the sensor only draws current during the brief ADC sampling window.

2. EMI on Long Wire Runs: Analog voltage signals act as antennas. If your thermistor is mounted 3 feet away from the microcontroller near a switching power supply or AC relay, high-frequency noise will cause the ADC reading to jump erratically. Fix: Use twisted-pair shielded cable, place a 0.1µF ceramic capacitor directly across the ADC pin and GND at the microcontroller end, and oversample the ADC (take 16 reads and average them) in your firmware.

3. ADC Reference Drift: The math assumes $V_{in}$ is exactly 3.3V. If your ESP32's onboard voltage regulator sags to 3.2V under WiFi transmit loads, your calculated temperature will drift. Fix: For high-precision applications, use an external precision voltage reference IC (like the LM4040) or measure the actual VCC rail using a secondary ADC channel to dynamically scale your math.

Thermistor Sensor FAQ

How do I waterproof a thermistor sensor for liquid measurements?

Bare glass-bead thermistors are not waterproof and will eventually suffer from moisture ingress, which alters their resistance baseline. To measure liquid temperatures, purchase a thermistor sensor pre-potted in a stainless steel or copper probe housing with marine-grade epoxy. If you must waterproof a bare bead, coat it in two-part marine epoxy or slide it into a piece of 3mm heat-shrink tubing filled with thermally conductive silicone potting compound. Avoid standard hot glue, as it acts as a thermal insulator and drastically slows down the sensor's response time.

Why is my thermistor sensor ADC reading jumping around?

Jittery ADC readings are almost always caused by one of three things: a loose breadboard connection introducing variable contact resistance, electromagnetic interference (EMI) from nearby AC wiring or switching DC-DC converters, or an unstable power supply rail. To isolate the issue, disconnect the thermistor and replace it with a fixed 10K resistor. If the ADC reading stabilizes, your environment is injecting noise into the high-impedance thermistor legs. Add a 100nF decoupling capacitor between the ADC pin and ground, and implement a software moving-average filter to smooth out transient spikes.

Should I use a thermistor sensor or a DS18B20 for my project?

Choose the thermistor sensor when you need ultra-fast thermal response times (glass beads react in <2 seconds), high resolution for narrow temperature bands, or a low-cost BOM for mass production. Choose the DS18B20 digital sensor when you need to run cables over long distances (digital 1-Wire signals resist EMI far better than analog voltage), when you want to daisy-chain multiple sensors on a single GPIO pin, or when you want to avoid complex firmware linearization math. The DS18B20 handles the ADC conversion and linearization internally, outputting a clean digital Celsius value at the cost of a slower 750ms conversion time.