ESP32 UNO - NTC Thermistor Temperature Sensor

A fish tank, a home-brew bucket, a freezer in the garage: each of them needs a temperature sensor that does not mind getting wet. The DIYables 10K NTC thermistor probe is made for that. Its tip is a sealed steel tube with a tiny heat-sensitive resistor inside. Add the 10K resistor that comes in the same bag, connect three points on the ESP32 Uno form board, and a short sketch prints the temperature in °C and °F. No library is needed.

Here is the plan:

  1. Look inside the steel probe and see why its two wires have no + or − side
  2. Build a small voltage divider on the 3.3V and A2 (GPIO35) pins
  3. Upload one sketch that turns millivolts into ohms, then ohms into °C and °F
  4. Check the readings with a bowl of warm water
ESP32 Uno reading water temperature with a waterproof 10K NTC thermistor probe

Components You Need

1×ESP32 Uno-form Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×10K NTC Thermistor Waterproof Probe (10K resistor included)
1×Jumper Wires
1×Optionally, Breadboard

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Good to know: the probe kit holds five probes and five matching 10K resistors, so you do not need to buy a resistor. The breadboard only makes it easy to join the resistor to the wires.

The 10K NTC Thermistor Probe

Read this part once, and every number in the Serial Monitor will make sense.

The probe looks like a short steel pencil on a black cable. The thermistor sits inside the 5mm x 25mm stainless-steel tip, sealed against water. The 0.5m cable carries two wires and ends in a white JST XH2.54 plug with two holes. There is no module board. You push two male jumper wires into the holes of the plug, and the probe is ready. Both wires are the same: a thermistor is a resistor, so it has no + or − side.

DIYables 10K NTC thermistor waterproof probe with 2-pin JST XH2.54 plug and 10K resistor
image source: diyables.io
Item Value
Thermistor NTC, 10K at 25°C, ±1%
B value 3950
Temperature range -20°C to 105°C
Probe Stainless steel, waterproof, 5mm x 25mm, round tip
Cable 0.5m, 2 wires, no polarity
Connector JST XH2.54 2-pin plug
In the kit 5 probes and 5 matching 10K resistors

How It Senses Heat

The thermistor in the tip is very sensitive to heat: a few degrees are enough to change its ohms in a way you can see. The sketch finds those ohms and converts them to degrees. NTC stands for Negative Temperature Coefficient, which simply means the ohms go down as the probe warms up.

The ESP32 Uno cannot measure ohms, only volts. That is the job of the 10K resistor from the kit. Together with the thermistor, it forms a voltage divider. The thermistor sits between 3.3V and A2, and the resistor sits between A2 and GND. A warmer probe has fewer ohms, so more of the 3.3V reaches A2.

Probe Temperature Thermistor Resistance Voltage on A2
-10°C 58,246 ohms 0.48V
15°C 15,837 ohms 1.28V
25°C 10,000 ohms 1.65V
40°C 5,301 ohms 2.16V
70°C 1,760 ohms 2.81V

From Ohms to Degrees

The sketch does the math in two steps.

Step 1, millivolts to ohms: R = 10000 × (3300 − mV) / mV

Step 2, ohms to kelvin (the B formula): 1/T = 1/T0 + (1/B) × ln(R/R0)

Here T0 is 298.15 K (that is 25°C), R0 is 10000 ohms and B is 3950. The result T is in kelvin, so °C = T − 273.15. You may also meet the Steinhart-Hart equation. It uses three coefficients and is a little more exact, yet the one-number B formula does the job well for this probe.

ESP32 Uno Pinout

The probe uses the hole printed A2, yet the sketch calls it 35. That is because A2 is wired to GPIO35 of the ESP32 chip. The map below lists the GPIO number behind every Uno label.

ESP32 Uno pinout diagram

How to Connect

The whole circuit has three points: 3.3V, A2 and GND. Push one male jumper wire into each hole of the white plug. Then the 10K resistor bridges A2 and GND. The drawing shows the resistor legs joined straight to the wires. On your desk, a small breadboard makes that joint easy, or you can twist each leg around a wire end and solder it.

The wiring diagram between ESP32 Uno NTC thermistor

This image is created using Fritzing. Click to enlarge image

Circuit Point ESP32 Uno Pin
Probe wire (either one) 3.3V
Other probe wire A2 (GPIO35)
10K resistor, first leg A2 (GPIO35)
10K resistor, second leg GND

For a project that lasts, screw terminals hold the wires better than jumper wires. Try a Screw Shield V2 or a Proto Screw Terminal Block Shield: it sits on the ESP32 Uno, and each pin gets its own screw terminal. Each wire goes to the screw terminal of the same pin, as in the image below.

The wiring diagram between ESP32 Uno NTC thermistor Screw Shield

This image is created using Fritzing. Click to enlarge image

Here the 10K resistor goes directly into the screw terminals as well: one leg in GND, the other in A2 together with the probe wire. A screw terminal clamps both at once.

WARNING

Feed the probe from the 3.3V pin, never from 5V. A hot probe has few ohms, so A2 gets close to the supply voltage. From 5V, A2 would pass the 3.3V limit of the ESP32 pins at only about 41°C. The code also counts on 3300 mV at the top of the divider.

Good to know: the probe sits on A2 (GPIO35), not on A0 like many other analog pages for this board. A2 is an ADC1 pin, so it keeps reading when you add WiFi later, and GPIO35 is an input-only pin, which is all a sensor needs. A0 is GPIO2: an ADC2 pin that stops working while WiFi is on, and also a boot strapping pin. The divider would hold GPIO2 at about 1.6V, and that can make an upload fail.

ESP32 Uno Code - Thermistor Temperature in °C and °F

The sketch reads A2 sixteen times, 5 ms apart, and uses the average. It asks for calibrated millivolts with analogReadMilliVolts(), not for a raw count out of 4095. Why? The ESP32 ADC is not a straight line near its two ends, and its top is about 3.1V, not 3.3V. A simple "raw / 4095" ratio would be a few degrees off. Before any math, two checks catch a missing probe and a short, so you see a clear message and never inf or nan.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-ntc-thermistor-temperature-sensor */ /* * ESP32 Uno sketch: 10K NTC thermistor probe (B value 3950) on A2 (GPIO35). * Circuit: 3.3V -> thermistor -> A2 -> 10K resistor -> GND * Each line shows the chain of the math: * pin voltage (mV) -> thermistor resistance (ohms) -> temperature (°C and °F). */ #define NTC_PIN 35 // A2 on the Uno-style header is GPIO35 on the ESP32 chip (ADC1, works with WiFi on) #define SAMPLES 16 // readings averaged for one result #define VCC_MV 3300.0 // the divider is fed from the 3.3V pin #define R_FIXED 10000.0 // the 10K resistor from the kit, between A2 and GND #define R0 10000.0 // thermistor resistance at 25°C #define T0 298.15 // 25°C in kelvin #define B_VALUE 3950.0 // B (beta) value of the thermistor void setup() { Serial.begin(9600); analogSetAttenuation(ADC_11db); // let the pin read from 0V up to about 3.1V } void loop() { long total_raw = 0; long total_mv = 0; // a thermistor reading is a bit noisy, so add up several readings for (int i = 0; i < SAMPLES; i++) { total_raw += analogRead(NTC_PIN); // 0 to 4095, only used for the wiring checks total_mv += analogReadMilliVolts(NTC_PIN); // millivolts, uses the factory calibration delay(5); } float raw_avg = total_raw / (float)SAMPLES; float pin_mv = total_mv / (float)SAMPLES; // wiring checks, so the math below never divides by zero if (raw_avg < 10) { // nothing pulls A2 up, so the 10K resistor holds it at GND Serial.println("No thermistor found: check the probe wires on 3.3V and A2"); } else if (raw_avg > 4085 || pin_mv >= VCC_MV) { // A2 sits at the top of the range Serial.println("A2 is at the top: probe shorted, or the 10K resistor is not on GND"); } else { // voltage divider: thermistor on the 3.3V side, 10K on the GND side float r_ntc = R_FIXED * (VCC_MV - pin_mv) / pin_mv; // B formula: 1/T = 1/T0 + ln(R/R0) / B, with T in kelvin float t_kelvin = 1.0 / (1.0 / T0 + log(r_ntc / R0) / B_VALUE); // log() is the natural log float t_c = t_kelvin - 273.15; float t_f = t_c * 9.0 / 5.0 + 32.0; Serial.print(pin_mv, 0); Serial.print(" mV -> "); Serial.print(r_ntc, 0); Serial.print(" ohms -> "); Serial.print(t_c, 1); Serial.print(" °C / "); Serial.print(t_f, 1); Serial.println(" °F"); } delay(1000); }

Upload and Test

  1. New to the ESP32 Uno? Follow ESP32 Uno - Getting Started to add the ESP32 core to Arduino IDE.
  2. Wire the probe and the resistor as in the table above.
  3. Connect the board to your computer with the USB Type-C cable.
  4. Choose the board in Arduino IDE: ESP32 Dev Module and the CH340 COM port.
  5. Paste the sketch and press Upload.
  6. Open the Serial Monitor at 9600 baud.
  7. Let the probe lie on the desk for ten seconds. Then put the steel tip into a bowl of warm tap water, and keep the plug and the resistor dry. Each line shows the whole chain, from millivolts to ohms to degrees:
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
1624 mV -> 10320 ohms -> 24.3 °C / 75.7 °F 1626 mV -> 10295 ohms -> 24.3 °C / 75.8 °F 1621 mV -> 10358 ohms -> 24.2 °C / 75.6 °F 1861 mV -> 7732 ohms -> 30.9 °C / 87.6 °F 2019 mV -> 6345 ohms -> 35.6 °C / 96.1 °F 2083 mV -> 5843 ohms -> 37.6 °C / 99.7 °F 2105 mV -> 5677 ohms -> 38.3 °C / 101.0 °F 2108 mV -> 5655 ohms -> 38.4 °C / 101.1 °F
Ln 11, Col 1
ESP32 Dev Module on COM15
2
  1. Pro tip: pull the white plug off the jumper wires for a second. The line changes to "No thermistor found", so you know the safety check works.

The first three lines are the room, at about 24°C. In the water, the value climbs over several lines, because the steel tube has to warm up too. Wait until two lines in a row agree before you trust a new reading.

Video Tutorial

Code Explanation

Code Part What It Does
#define NTC_PIN 35 The A2 hole is GPIO35, so the code uses 35
analogSetAttenuation(ADC_11db) Lets A2 read up to about 3.1V, enough for the whole probe range
analogReadMilliVolts(NTC_PIN) Gives the pin voltage in mV, corrected with the calibration stored in the chip
for (int i = 0; i < SAMPLES; i++) Adds 16 readings, so one noisy sample does not move the result
raw_avg < 10 A2 is at the bottom, so no probe pulls it up
raw_avg > 4085 A2 is at the top, so the probe is shorted or the resistor misses GND
R_FIXED * (VCC_MV - pin_mv) / pin_mv Divider math, gives the thermistor resistance in ohms
log(r_ntc / R0) / B_VALUE The B formula, log() is the natural log in Arduino code
t_kelvin - 273.15 Kelvin to °C, then °C × 9 / 5 + 32 gives °F

ESP32 Uno vs UNO R4 for This Project

The circuit is the same on both boards. Only the supply pin, the analog pin and the math change.

Item Arduino UNO R4 ESP32 Uno
Probe supply 5V 3.3V only
Signal pin A0 A2 (GPIO35)
What the code reads Raw count, 0 to 1023 Calibrated millivolts
Resistance math R_FIXED × (1023 / raw − 1) R_FIXED × (3300 − mV) / mV
Extra setup line none analogSetAttenuation(ADC_11db)

The B formula after the resistance step is the same on both boards.

NTC Thermistor, DS18B20 or MAX6675?

All three come as probes, but they fit different jobs.

Item 10K NTC Thermistor DS18B20 Probe MAX6675 Thermocouple
Signal Analog, 1 ADC pin Digital, 1-Wire Digital, 3 pins
Range -20°C to 105°C -55°C to 125°C 0°C to 1024°C
Extra part 10K resistor, in the kit 4.7K pull-up, or an adapter board that has it MAX6675 board
Library none OneWire and DallasTemperature Adafruit MAX6675
Best for Cheap probes, many points, no library A ready °C value with no math Ovens, grills and kilns

Want a digital probe with no resistor math? See ESP32 Uno - DS18B20 Temperature Sensor. Going hotter than 105°C? See ESP32 Uno - MAX6675 Thermocouple.

Try These Next

  • Freezer alarm: sound a piezo buzzer when the freezer probe stays above -12°C for ten minutes.
  • Aquarium heater: switch the heater with a relay, on below 24.5°C and off above 25.5°C, so it does not click on and off all the time.
  • Desk display: show °C and °F on an LCD I2C.
  • Phone view: send the value to a web thermometer or a Bluetooth thermometer. A2 is an ADC1 pin, so the probe can stay where it is when WiFi is on.

Troubleshooting

Problem Possible Cause Solution
"No thermistor found" on every line The plug is off the jumper wires, or the 3.3V wire is loose Push the male pins fully into the white plug and check 3.3V and A2
"A2 is at the top" on every line The probe wires touch, or the resistor does not reach GND Check the joint and move the free resistor leg to GND
Temperature goes down when the probe gets warm Thermistor and resistor swapped The probe goes between 3.3V and A2, the resistor between A2 and GND
Reading is a few degrees off at room temperature Wrong resistor, or the code was changed to raw / 4095 Use the 10K resistor from the kit and keep analogReadMilliVolts()
Reading stops changing after you add WiFi The probe was moved to A0 or A1, which are ADC2 pins Keep it on A2 (GPIO35), or use A3 to A5
Value jumps by about 1°C Electrical noise or a loose joint Set SAMPLES to 32 and make sure every wire sits firmly
No COM port in Arduino IDE CH340 driver missing or a charge-only cable Install the CH340 driver and use a USB cable that carries data
Serial Monitor shows odd symbols Baud rate mismatch Select 9600 baud

FAQ

Which probe wire goes to 3.3V?

Either one. A thermistor is a plain resistor with no + or − side. One wire goes to 3.3V, the other goes to A2.

How exact are the readings?

Near room temperature they are typically within about 1°C. The result depends on the 10K resistor and on the ESP32 ADC. A glass full of ice with a little water is an easy check, because it sits at 0°C. If the probe shows 0.7°C there, subtract 0.7 in the code.

Can the probe measure boiling water on the ESP32 Uno?

The probe is rated up to 105°C, but the ESP32 ADC is the limit here. It is most exact below about 2.45V on the pin, which is about 50°C with this divider. At 100°C, A2 is near 3.08V, right under the top of the ADC, so readings that high are rough. For cooking and ovens, use the MAX6675 thermocouple.

Can I add a second probe or use another pin?

Yes. Each probe needs its own 10K resistor and its own analog pin. A3 to A5 (GPIO34, 36, 39) are ADC1 pins like A2, so they also work when WiFi is on. Avoid A0 (GPIO2): it is an ADC2 pin and a boot strapping pin, and the divider can stop uploads. Put the probe wire and its resistor leg on the new pin, and use the GPIO number in the code.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!