Temperature, humidity and air

NTC thermistor 10k with ESP32

Copied thermistor code often gives a temperature that moves the wrong way, and the reason is the wiring. The usual tutorial formula assumes the NTC sits on the ground side of the divider, while the tutorial's own diagram may put it on the 3.3 V side. This page uses one layout: 10 kΩ from 3V3 to the ADC pin, and the NTC from that pin to ground. Then Rt = R × V / (Vs − V).

Temperature comes from the Beta equation, using 10 kΩ at 25 °C and a Beta value such as 3950 from the part's data. Check your part's values, because 3950 is common but not universal. The NTC gets less resistive when hot, so in this layout the pin voltage falls as temperature rises. Use analogReadMilliVolts, not a raw count against 4096. The arduino-esp32 call applies calibration, and the raw value is less accurate on some chips.

A thermistor is cheap, small and fits in a probe, but accuracy depends on the ESP32 ADC, the fixed resistor and the actual 3.3 V rail. Do not expect tenths of a degree without calibration. Take a few readings and average them. Current through the divider heats the NTC very slightly, which matters only for precise work. For long wires, or where you want a digital value, a DS18B20 is easier. Use an ADC1 pin, because ADC2 conflicts with WiFi. LCD Ultra Pro can read an analog pin and scale it to a range, which gives a rough readout over a small span. The curve is not linear, so accurate degrees need the code below.

NTC thermistor 10k wiring diagram for ESP32
Wiring diagram drawn by LCD Ultra Pro.

Specifications

Typical part10 kΩ at 25 °C, Beta 3950
Divider10 kΩ to 3V3, NTC to GND
BehaviourResistance falls as temperature rises
Read withanalogReadMilliVolts on an ADC1 pin

Power and logic levels

3.3 V: safe to connect directly

SupplyDivider from 3V3
Signal levelStays below 3.3 V
On an ESP32Feed the divider from 3V3, not 5 V.

ESP32 pins, including those on a display board's connectors, work at 3.3 V and are not 5 V tolerant. Modules differ, so if in doubt, measure the signal before you connect it.

Wiring

NTC thermistor 10kConnect toNote
Fixed 10 kΩ3V3 to GPIO 4
NTCGPIO 4 to GNDThis order matches the code

Arduino code

const int ADC_PIN = 4;
const float VS = 3300, R_FIXED = 10000, R0 = 10000, BETA = 3950;

float readCelsius() {
  long sum = 0;
  for (int i = 0; i < 32; i++) sum += analogReadMilliVolts(ADC_PIN);
  float mv = sum / 32.0;
  float rt = R_FIXED * mv / (VS - mv);     // NTC on the ground side
  return 1.0 / (log(rt / R0) / BETA + 1.0 / 298.15) - 273.15;
}

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.printf("%.1f C\n", readCelsius());
  delay(1000);
}

No extra library needed. Compiled for ESP32-S3 with arduino-esp32 3.x. Not yet tested by us on a physical sensor. Change the pins to match your board.

On a display

In LCD Ultra Pro a rule can read an analog pin and scale it to a range. The code above gives accurate degrees.

Design a display for NTC thermistor 10k

Boards with a ready connector

Only boards whose connectors we have surveyed. Others may still work on free GPIOs.

Elecrow CrowPanel ESP32 HMI 2.4"GPIO_D port: GPIO 32 (ADC)
Elecrow CrowPanel ESP32 HMI 2.8"GPIO_D port: GPIO 32 (ADC)
Elecrow CrowPanel ESP32 HMI 3.5"GPIO_D port: GPIO 32 (ADC)
LilyGO T-Display (classic) 1.14"Right pin header: GPIO 36 (ADC)36 / 37 / 38 / 39 are input-only
M5Stack AtomS3 0.85"Grove port: GPIO 2 (ADC)
M5Stack M5StickC Plus2 1.14"Grove port: GPIO 32 (ADC)
Sunton ESP32-2432S028R 2.8"GPIO header (P3): GPIO 35 (ADC)GPIO 21 is the display backlight — not usable. GPIO 35 is input-only. No 3V3 pin on P3 (only GND).
Waveshare ESP32-S3-LCD-7BGPIO connector (J8): GPIO 6 (ADC)

Good to know

  • The formula depends on which side the NTC is on.
  • Check your part's Beta value.
  • Use an ADC1 pin with WiFi.
  • Calibrate if you need accuracy.

What it is good for

  • Cheap probes
  • Heater and 3D printer style sensing
  • Tight spaces

FAQ

Why does my thermistor reading move the wrong way?

The formula and wiring do not match. Check which side of the divider the NTC is on.

What Beta value should I use?

Use the value from your part's data. 3950 is only common.

NTC or DS18B20?

NTC is cheaper and smaller. The DS18B20 is digital and easier over long wires.

Sources

Related parts

Use this information at your own risk. It is for general guidance only: the example code compiles, but it has not been tested on every part, and modules differ between sellers. Check the manufacturer's data before you build. Product names belong to their owners, and LCD Ultra Pro is not affiliated with them. See our Terms.