Arduino Nano ESP32 - NTC Thermistor Temperature Sensor

In this guide, we will learn how to make a thermometer from the Arduino Nano ESP32 and a 10K NTC 3950 probe in a steel tube. The tube is small, sealed, and sits at the end of a thin cable. So you can lower it into a sous-vide pot, push it into a jar of fermenting kombucha, lay it on a fridge shelf, or stick it into the soil of a seed tray. In detail, we will learn:

Arduino Nano ESP32 reading temperature from a waterproof NTC thermistor probe on A7

Hardware Preparation

1×Arduino Nano ESP32
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 Probe, Waterproof (10K resistor included)
1×Jumper Wires
1×Breadboard
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano ESP32

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 .

Overview of NTC Thermistor Temperature Sensor

Look closely at the probe and you find three parts. At one end is a round-tipped tube of stainless steel, 5mm across and 25mm long, with the thermistor sealed inside. In the middle is 0.5m of black cable with two wires. At the other end is a white JST XH2.54 plug with two holes. Nothing else: no small board, no chip, no LED. The DIYables set holds five of these probes plus five 10K resistors, one for each.

NTC thermistor probe pinout: sealed steel tip, 0.5m two-wire lead and JST XH 2-pin plug
image source: diyables.io

A male jumper wire slides straight into each of the two holes in the plug. Then:

  • First wire: connect to the 3V3 pin of the Nano ESP32.
  • Second wire: connect to A7. The 10K resistor also starts here and ends on GND.

You do not need to find out which wire is which. The steel tip holds only a resistor, and a resistor works the same in both directions.

Waterproof NTC Probe
Thermistor NTC, 10kΩ ±1% at 25°C
Beta (B) constant 3950
Works from -20°C up to 105°C
Tip stainless steel, sealed, Ø5 x 25mm
Lead 0.5m, 2 wires, either way round
Plug type female JST XH2.54 with 2 holes
Insulation resistance more than 100MΩ

How the probe tells the temperature

A thermistor is a resistor that changes a lot with heat. In an NTC type, heat makes the number of ohms drop, and cold makes it climb. The ADC of the Nano ESP32 only understands volts, though. The 10K resistor fixes that. Thermistor on top (to 3V3) and resistor at the bottom (to GND) share the 3.3V between them, and A7 sits on the joint. As the tip heats up, the thermistor's share gets smaller, so A7 goes up. The sketch measures A7, works out the ohms, and turns the ohms into degrees. A few sample values with this exact circuit:

Probe temperature NTC resistance A7 voltage (3V3 supply)
10°C about 20.2kΩ 1.09V
25°C 10.0kΩ 1.65V
30°C about 8.0kΩ 1.83V
45°C about 4.35kΩ 2.30V
80°C about 1.27kΩ 2.93V

The step from ohms to degrees is a short formula called the beta (or B-parameter) equation:

1/T = 1/T0 + (1/B) × ln(R/R0)

  • R: the thermistor resistance found by the sketch, in ohms.
  • R0: 10000Ω, which the probe has at T0 = 298.15K, in other words 25°C.
  • B: 3950, given by the maker.
  • T: the answer, in Kelvin. Minus 273.15 gives °C.

Scientists sometimes use Steinhart-Hart, a longer formula with three constants. You do not need it here: with this probe the beta equation already lands within about 1°C around room temperature. Beyond that, the result depends on how exact your 10K resistor is and on the ADC inside the Nano ESP32.

Wiring Diagram

You need three pins of the Nano ESP32 for this: 3V3 powers the thermistor, A7 listens to the joint, and GND takes the lower end of the 10K resistor.

Turn the Nano ESP32 so its USB-C port points left and press it down over the trench in the middle of the breadboard. Now the pins you need (3V3, A7 and GND) are all on the side facing you, and each one has four free holes below it. Push the 10K resistor into the fourth hole row (row H): its left leg under A7, its right leg under GND, three holes further. It simply bridges the VBUS and B1 holes in between. Finish with two jumper wires from the bottom row (row J) to the probe's white plug, yellow under A7 and red under 3V3, which is the second pin from the left end next to D13. No hole is shared, and the board needs no separate GND wire.

Why 3V3 and not VBUS? In very hot water, A7 rises close to the top of the divider. The analog pins of the ESP32-S3 chip must never get more than 3.3V, so the top must be 3.3V too. The 3V3 pin also comes from a regulator, so it stays steady even when the USB port gives a little less than 5V. That matters, because the code takes the top of the divider as exactly 3300mV.

Why A7 and not A0? A7 is only three pins away from GND. So the 10K resistor fits straight between them, on the breadboard and on a screw terminal board, with no extra wire.

※ NOTE THAT:

A7 is GPIO14 of the ESP32-S3 chip, and that is an ADC2 pin. ADC2 cannot be read while WiFi is on. This sketch does not use WiFi, so A7 works fine. Do you plan to add WiFi later, for example to send the temperature to your phone? Then move the probe wire and the 10K resistor to one of A0 to A3, and change NTC_PIN in the code to match. A0 to A3 are ADC1 pins, and ADC1 keeps working with WiFi.

The wiring diagram between Arduino Nano ESP32 and NTC thermistor breadboard

This image is created using Fritzing. Click to enlarge image

Without a breadboard, solder the 10K resistor between the A7 wire and the GND wire, like this:

The wiring diagram between Arduino Nano ESP32 and NTC thermistor  (No Breadboard)

This image is created using Fritzing. Click to enlarge image

Thermistor + 10K Resistor Arduino Nano ESP32 Pin
Thermistor lead (either one) 3V3 (not VBUS)
Thermistor lead (the other one) A7
10K resistor, top leg A7
10K resistor, bottom leg GND

A screw terminal keeps each wire tight, even when the board shakes. The Arduino Nano ESP32 fits a Screw Terminal Expansion Board for Arduino Nano, which turns every pin into a screw terminal. See the diagram below for the screw terminal version.

The wiring diagram between Arduino Nano ESP32 and NTC thermistor Screw Terminal

This image is created using Fritzing. Click to enlarge image

On the screw terminal board, the 10K resistor is screwed straight into the GND terminal and the A7 terminal, where it shares the A7 terminal with the probe's wire. So there is no GND wire at all.

※ NOTE THAT:

Water is fine for the steel tip, but not for the rest. Everything else (plug, jumper wires, resistor joint) must stay dry, so keep them above the water line, for example taped to the side of the pot or jar.

How To Program For NTC Thermistor Temperature Sensor

There is nothing to install. analogReadMilliVolts() comes with the Arduino core for the Nano ESP32, and log() is a standard C++ math function.

  • Give the analog pin a name and store the probe numbers:
#define NTC_PIN A7 #define R_FIXED 10000.0 // kit resistor, from A7 to GND #define R_NOMINAL 10000.0 // the NTC has 10K at 25°C #define B_VALUE 3950.0
  • Inside setup(), widen the ADC input range to about 3.1V:
analogSetAttenuation(ADC_11db);
  • Ask for the voltage on A7 in millivolts. This function applies the factory calibration saved in the ESP32-S3 chip. The full sketch repeats it 20 times and uses the average:
float pin_mv = analogReadMilliVolts(NTC_PIN);
  • Get the thermistor's ohms from the divider rule:
float r_ntc = R_FIXED * (3300.0 - pin_mv) / pin_mv;
  • Put the ohms into the beta equation to get °C. Note that log() in C++ means ln, the natural logarithm, not log10:
float temp_c = 1.0 / (1.0 / 298.15 + log(r_ntc / R_NOMINAL) / B_VALUE) - 273.15;

Why millivolts, and not analogRead() divided by 4095? The ESP32-S3 ADC bends away from a straight line near both ends of its range, and with ADC_11db its upper limit ends near 3.1V instead of 3.3V. A plain ratio would get the resistance wrong, mostly when the probe is very cold or very hot. The calibrated millivolt reading avoids both problems.

Arduino Nano ESP32 Code - NTC Thermistor Temperature Sensor

The complete sketch writes one line to the Serial Monitor every second: the averaged A7 voltage, the thermistor's ohms, and the temperature in °C and °F. If A7 stays near 0V or near 3.3V, you get a short wiring hint in place of a temperature.

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-ntc-thermistor-temperature-sensor */ #define NTC_PIN A7 // The Arduino Nano ESP32 pin connected to the thermistor and the 10K resistor // A7 is an ADC2 pin: it cannot be read while WiFi is on. With WiFi, use A0 to A3 (ADC1) instead. #define SUPPLY_MV 3300.0 // the divider gets its power from the 3V3 pin #define R_FIXED 10000.0 // kit resistor, from A7 to GND #define R_NOMINAL 10000.0 // the NTC has 10K at 25°C #define T_NOMINAL 298.15 // 25°C written in Kelvin #define B_VALUE 3950.0 // B (beta) value of the thermistor #define SAMPLE_COUNT 20 // how many readings are averaged for one result // the voltage on A7 moves a little from one reading to the next, so take the average float readPinMilliVolts() { long sum_mv = 0; for (int i = 0; i < SAMPLE_COUNT; i++) { sum_mv += analogReadMilliVolts(NTC_PIN); // calibrated value, in millivolts delay(5); } return sum_mv / (float)SAMPLE_COUNT; } void setup() { Serial.begin(9600); analogSetAttenuation(ADC_11db); // let A7 measure up to about 3.1V } void loop() { float pin_mv = readPinMilliVolts(); // safety checks: no division by zero and no log() of zero or a negative number if (pin_mv < 50) { // the 10K resistor pulls A7 down to GND when the probe is missing Serial.println("A7 is near 0V: the thermistor is not connected. Check the plug and the 3V3 wire."); delay(1000); return; } if (pin_mv > 3150) { Serial.println("A7 is near 3.3V: the probe wires may touch each other, or the 10K resistor has lost its GND connection."); delay(1000); return; } // voltage divider: thermistor on the 3V3 side, 10K resistor on the GND side float r_ntc = R_FIXED * (SUPPLY_MV - pin_mv) / pin_mv; // B-parameter equation: 1/T = 1/T0 + ln(R/R0) / B, with T in Kelvin // log() in Arduino is the natural logarithm (ln) float temp_k = 1.0 / (1.0 / T_NOMINAL + log(r_ntc / R_NOMINAL) / B_VALUE); float temp_c = temp_k - 273.15; // Kelvin -> Celsius float temp_f = temp_c * 9.0 / 5.0 + 32.0; // Celsius -> Fahrenheit Serial.print("A7: "); Serial.print(pin_mv, 0); Serial.print(" mV | NTC: "); Serial.print(r_ntc, 0); Serial.print(" Ω | "); Serial.print(temp_c, 1); Serial.print("°C ~ "); Serial.print(temp_f, 1); Serial.println("°F"); delay(1000); // about one line per second }

Detailed Instructions

Follow these instructions step by step:

  • If this is the first time you use Arduino Nano ESP32, see how to setup environment for Arduino Nano ESP32 on Arduino IDE.
  • Make the four connections from the wiring table. Before you go on, look again: one thermistor lead must sit on 3V3, not on VBUS.
  • Plug a USB Type-C cable into the Nano ESP32 and into your PC.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Nano ESP32 board (e.g., Arduino Nano ESP32) and COM port.
  • Paste the code above into a new sketch, then press Upload.
  • Open the Serial Monitor and choose 9600 baud.
  • Let a few lines scroll by with the probe on the desk. Next, lower the probe into a cup of tea that has been standing for some minutes.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Nano ESP32
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano ESP32' on 'COM15')
New Line
9600 baud
A7: 1561 mV | NTC: 11142 Ω | 22.6°C ~ 72.7°F A7: 1564 mV | NTC: 11099 Ω | 22.7°C ~ 72.8°F A7: 1556 mV | NTC: 11203 Ω | 22.5°C ~ 72.4°F A7: 2006 mV | NTC: 6451 Ω | 35.2°C ~ 95.4°F A7: 2376 mV | NTC: 3889 Ω | 47.9°C ~ 118.2°F A7: 2569 mV | NTC: 2847 Ω | 56.2°C ~ 133.2°F A7: 2654 mV | NTC: 2434 Ω | 60.6°C ~ 141.1°F A7: 2685 mV | NTC: 2290 Ω | 62.3°C ~ 144.2°F A7: 2697 mV | NTC: 2237 Ω | 63.0°C ~ 145.4°F A7: 2699 mV | NTC: 2227 Ω | 63.1°C ~ 145.6°F
Ln 11, Col 1
Arduino Nano ESP32 on COM15
2

Lines one to three were taken with the probe lying on the desk, at about 22.6°C. As soon as the tip touches the tea, look at the two middle columns: the millivolts go up while the ohms go down, from about 11kΩ to 2.2kΩ. That opposite movement is the "negative" in NTC. The temperature climbs over five or six lines, not in one step, because the heat has to pass through the steel before it reaches the thermistor. Trust the number once it stops changing.

Two messages can replace the temperature. "A7 is near 0V" means the plug has come off or the 3V3 wire is loose. "A7 is near 3.3V" means the 10K resistor has lost its GND connection, or the two probe wires touch.

※ NOTE THAT:

Do you have a kitchen thermometer? Put it and the probe side by side in the same glass of water and compare the two numbers. If the Nano ESP32 always shows a bit more or a bit less, add or subtract that difference to temp_c in the code.

Keep this probe at 105°C or below. Ovens, grills and kilns need a thermocouple, which is covered in Arduino Nano ESP32 - MAX6675 Thermocouple Module. If you would rather skip the resistor and the math, the DS18B20 probe gives a finished digital reading: see Arduino Nano ESP32 - Temperature Sensor.

Video Tutorial

※ 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!