Arduino Nano - NTC Thermistor Temperature Sensor

This tutorial instructs you how to use Arduino Nano to measure temperature with a 10K NTC thermistor sealed inside a waterproof stainless-steel probe. There is no chip in the probe and no library to install. The thermistor is a resistor whose value follows the temperature, so the Nano needs only one analog pin, the small 10K resistor that comes in the kit, and a little math. In detail, we will learn:

Arduino Nano reads a waterproof 10K NTC thermistor probe and prints the temperature in °C and °F

We suggest:

Hardware Preparation

1×Official Arduino Nano
1×Alternatively, DIYables Nano V3.0 Development Board
1×USB A to Mini-B USB cable
1×10K NTC Thermistor Waterproof Probe (with 10K resistor)
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

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

10K NTC thermistor waterproof probe with stainless steel tip, two-wire cable and JST XH2.54 plug
image source: diyables.io

What you hold in your hand is a small stainless-steel tube, 5mm wide and 25mm long, with a round tip. The 10K NTC thermistor is sealed inside it. A black two-wire cable, half a meter long, comes out of the tube and ends in a white JST XH2.54 plug with two holes. There is no circuit board at all. The DIYables kit has five of these probes, plus one matching 10K resistor for each probe.

The steel tube can go into water, a fish tank or a pot of soil. The plug and the far end of the cable cannot, so keep them dry.

10K NTC Thermistor Probe
Sensing element NTC thermistor, 10kΩ at 25°C, ±1%
B value (beta) 3950
Measuring range -20°C to 105°C
Probe tube waterproof stainless steel, round tip, 5mm x 25mm
Cable 0.5m, two black wires
Connector white JST XH2.54 plug, 2 pins
Polarity none, the two wires can be swapped
Output resistance, read through a voltage divider and an analog pin
Heat dissipation constant typically 5mW/°C

The plug has two openings. Push a male jumper wire into each one, then:

  • Wire 1 (either wire): must be connected to the 5V pin of Arduino Nano
  • Wire 2 (the other wire): must be connected to analog pin A7 of Arduino Nano
  • 10K resistor from the kit: must be connected between A7 and GND (0V). One leg shares the A7 wire, the other leg goes to GND

※ NOTE THAT:

The two wires carry no labels, and they do not need any. A thermistor is just a resistor, so it has no polarity: swap the wires and the readings stay the same. What does matter is the place of the 10K resistor. It must sit between A7 and GND, because the sketch is written for that order.

How the Probe Senses Heat

Inside the steel tip there is a thermistor: a tiny resistor that is very sensitive to heat. NTC stands for Negative Temperature Coefficient: the warmer the tip, the lower the resistance. At 25°C this probe measures 10,000 ohms. In ice water it climbs above 30,000 ohms, and in hot water it falls to a few thousand.

The Nano cannot measure ohms, only voltage. That is why the 10K resistor is there. The thermistor and the resistor sit in series between 5V and GND, and they share the 5V between them like a seesaw. When the probe warms up, its resistance drops, so the voltage at their meeting point, A7, goes up. The sketch reads that voltage, works out the resistance of the thermistor, and then turns the resistance into degrees.

A few points along the curve, with the wiring of this tutorial:

Temperature Thermistor resistance Voltage on A7 analogRead() value
0°C about 33.6kΩ 1.15V about 235
15°C about 15.8kΩ 1.94V about 396
25°C 10kΩ 2.50V about 512
40°C about 5.3kΩ 3.27V about 669
70°C about 1.76kΩ 4.25V about 870

The Beta Formula

The curve is not a straight line, so a simple "divide by 10" does not work here. The usual formula for an NTC thermistor is the B-parameter (beta) equation:

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

  • T is the temperature you want, in kelvin
  • T0 = 298.15 K, which is 25°C, the temperature at which the probe has its rated value
  • R is the resistance just measured, and R0 = 10000Ω is the rated value
  • B = 3950, from the specs table
  • Ln is the natural logarithm. In Arduino code it is called log()

Take away 273.15 from T and you have degrees Celsius. The Steinhart-Hart equation is a more exact version with three coefficients, but for this probe the B formula is good enough. Near room temperature, expect readings within about 1°C. How close you get depends on the 10K resistor and on the Nano's ADC.

Wiring Diagram

Wire 1 of the probe goes to 5V, wire 2 goes to A7, and the 10K resistor links A7 to GND. We use A7 because it is close to GND on the Nano. Only 5V and RST sit between them, so the resistor fits straight across on a breadboard:

  • Plug the Nano across the middle gap of the breadboard, with its USB socket to the left. The row with A0 to A7, 5V and GND is now the lower row.
  • Push the 10K resistor into row H. One leg goes in the A7 column. The other leg goes in the GND column, three columns to the right. The resistor jumps over the 5V and RST columns and does not touch them.
  • Run a yellow jumper wire from row J of the A7 column to one hole of the white probe plug.
  • Run a red jumper wire from row J of the 5V column, right next to A7, to the other hole of the plug.

Every hole holds only one wire or one leg. No GND wire is needed, because the resistor leg sits in the GND column itself.

The wiring diagram between Arduino Nano and NTC thermistor breadboard

This image is created using Fritzing. Click to enlarge image

Here is the same wiring without a breadboard, with the 10K resistor joined between the A7 wire and a GND wire:

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

This image is created using Fritzing. Click to enlarge image

NTC Thermistor Probe Arduino Nano Pin
Probe wire 1 (either one) 5V
Probe wire 2 A7
10K resistor, first leg A7 (together with probe wire 2)
10K resistor, second leg GND

Loose wires are a common cause of strange bugs. In this case, use a Screw Terminal Expansion Board for Arduino Nano. The Arduino Nano plugs into it, and each pin gets a screw terminal. The diagram below shows the same wiring with the screw terminal board.

The wiring diagram between Arduino Nano and NTC thermistor Screw Terminal

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Nano and other components.

On the terminal board, the 10K resistor needs no wire of its own: one leg goes into a GND terminal, the other shares the A7 terminal with the probe wire. The probe's 5V wire uses the 5V terminal between them, so tighten that wire first, then lay the resistor over it.

※ NOTE THAT:

Why 5V and not 3V3? The analog pins of the Nano compare every reading against 5V. When the probe runs from that same 5V, the code only needs the ratio between the reading and 1023, so a USB port that gives 4.8V or 5.1V makes no difference. Power the probe from the 3V3 pin instead, and every temperature the sketch prints will be wrong.

How To Program For NTC Thermistor

No library is needed. The math lives in the sketch, and log() is built into Arduino.

  • The first step is to specify the Arduino Nano pin that is connected to the thermistor and the 10K resistor:
#define NTC_PIN A7
  • Write down the numbers from the specs table as constants:
const float R_FIXED = 10000.0; // the 10K resistor between A7 and GND const float R0 = 10000.0; // thermistor resistance at 25°C const float B_VALUE = 3950.0; // B value of the probe const float T0 = 298.15; // 25°C in kelvin
  • Read A7 ten times with analogRead() and take the average. The 10-bit converter of the Nano returns a number from 0 to 1023:
long total = 0; for (int i = 0; i < 10; i++) { total += analogRead(NTC_PIN); delay(10); } float raw = total / 10.0;
  • Turn the reading into the resistance of the thermistor. The probe is fed from 5V, so the voltage itself is not needed, only the ratio:
float rNtc = R_FIXED * (1023.0 / raw - 1.0);
  • Put the resistance into the B formula, then convert kelvin to Celsius and Fahrenheit:
float tempK = 1.0 / (1.0 / T0 + log(rNtc / R0) / B_VALUE); float tempC = tempK - 273.15; float tempF = tempC * 9.0 / 5.0 + 32.0;

Arduino Nano Code for NTC Thermistor Temperature Sensor

The full sketch below runs all of these steps about once per second. Before the math, it also checks the averaged reading. A value close to 0 means the probe is not plugged in, because the 10K resistor then pulls A7 down to GND. A value close to 1023 means a short or a missing resistor. In both cases the sketch prints a hint instead of a strange temperature.

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-ntc-thermistor-temperature-sensor */ #define NTC_PIN A7 // Arduino Nano analog pin at the point where the thermistor meets the 10K resistor const float R_FIXED = 10000.0; // the 10K resistor from the kit, placed between A7 and GND (ohms) const float R0 = 10000.0; // thermistor resistance at 25°C (ohms) const float B_VALUE = 3950.0; // B (beta) value of the probe const float T0 = 298.15; // 25°C written in kelvin const float ADC_MAX = 1023.0; // 10-bit ADC of the Nano: 0 to 1023 const int SAMPLES = 10; // number of readings averaged for each result void setup() { Serial.begin(9600); // open the Serial Monitor link at 9600 baud } void loop() { // a single reading jumps a little, so take several and use the average long total = 0; for (int i = 0; i < SAMPLES; i++) { total += analogRead(NTC_PIN); delay(10); } float raw = total / (float)SAMPLES; // a value near 0: the 10K resistor pulls A7 to GND because the probe is not plugged in if (raw < 10) { Serial.println("Probe not found - check the thermistor wires on 5V and A7"); delay(1000); return; } // a value near 1023: the probe is shorted, or the 10K resistor is missing if (raw > 1013) { Serial.println("Reading too high - check the 10K resistor between A7 and GND"); delay(1000); return; } // the divider is fed from 5V, the same voltage the ADC compares against, // so the resistance comes straight from the ratio, without any volts float rNtc = R_FIXED * (ADC_MAX / raw - 1.0); // B-parameter equation: 1/T = 1/T0 + ln(R/R0) / B (T in kelvin, log() = natural log) float tempK = 1.0 / (1.0 / T0 + log(rNtc / R0) / B_VALUE); float tempC = tempK - 273.15; float tempF = tempC * 9.0 / 5.0 + 32.0; Serial.print("A7: "); Serial.print(raw, 1); Serial.print(" | NTC: "); Serial.print(rNtc, 0); Serial.print(" ohm | Temperature: "); Serial.print(tempC, 2); Serial.print("°C ("); Serial.print(tempF, 2); Serial.println("°F)"); delay(1000); // about one line per second }

Detailed Instructions

  • If this is the first time you use Arduino Nano, see how to set up the environment for Arduino Nano in Arduino IDE.
  • Wire the components as shown in the diagram.
  • Connect the Arduino Nano board to your computer using a USB cable.
  • Open Arduino IDE on your computer.
  • Pick Arduino Nano as the board, then the COM port it shows up on.
  • Copy the sketch above and paste it into Arduino IDE.
  • Press Upload and wait until the IDE says the upload is done.
  • Open the Serial Monitor and set the speed to 9600 baud.
  • Let the probe lie on the desk for a few lines. Then fill a mug with warm tap water and drop the steel tip into it. Keep the plug and the resistor out of the water.
  • The temperature starts at room level and climbs for several seconds, until the steel tip matches the water:
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Nano
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano' on 'COM15')
New Line
9600 baud
A7: 493.2 | NTC: 10742 ohm | Temperature: 23.40°C (74.12°F) A7: 494.3 | NTC: 10696 ohm | Temperature: 23.49°C (74.29°F) A7: 493.3 | NTC: 10738 ohm | Temperature: 23.41°C (74.13°F) A7: 540.6 | NTC: 8923 ohm | Temperature: 27.59°C (81.65°F) A7: 597.1 | NTC: 7133 ohm | Temperature: 32.80°C (91.05°F) A7: 638.8 | NTC: 6014 ohm | Temperature: 36.90°C (98.42°F) A7: 664.7 | NTC: 5390 ohm | Temperature: 39.59°C (103.26°F) A7: 679.6 | NTC: 5053 ohm | Temperature: 41.20°C (106.15°F) A7: 685.8 | NTC: 4917 ohm | Temperature: 41.88°C (107.39°F) A7: 688.6 | NTC: 4856 ohm | Temperature: 42.19°C (107.95°F)
Ln 11, Col 1
Arduino Nano on COM15
2

The reading does not jump to the water temperature at once. The steel tube needs a few seconds to warm through, so wait until two or three lines in a row agree before you trust the number. For a quick test of your build, stir the probe in a glass of ice water: after about half a minute it should show close to 0°C.

If the Serial Monitor prints "Probe not found", one of the jumper wires has slipped out of the white plug. If it prints "Reading too high", look at the 10K resistor between A7 and GND.

Additional Knowledge

NTC Thermistor vs DS18B20 vs LM35

10K NTC Thermistor Probe DS18B20 Waterproof Probe LM35
Kind of signal analog, a changing resistance digital, 1-Wire bus analog, 10mV per °C
Extra part needed 10K resistor (in the kit) 4.7K pull-up resistor none
Library none, only log() math OneWire and DallasTemperature none
Range -20°C to 105°C -55°C to 125°C 2°C to 150°C (basic wiring)
Waterproof yes, steel probe yes, steel probe no, bare TO-92 part
Time for one reading a few milliseconds up to 750ms at 12-bit a few milliseconds
Many sensors on one pin no, one analog pin each yes, each one has its own address no, one analog pin each

It is evident that the NTC thermistor is the simplest way to put a waterproof probe on a Nano: two wires, one resistor and no library. The DS18B20 is the better pick when you want a factory-calibrated digital value or many probes on one wire. The LM35 suits a sensor mounted on the board itself, where nothing has to go into water.

Using More Than One Probe

The kit holds five probes and five resistors, and the Nano has eight analog inputs, A0 to A7. The first probe already uses A7. Each extra probe gets its own resistor and its own free pin: wire 1 to 5V, wire 2 to A0 (or A1, A2 and so on, up to A6), and a 10K resistor from that pin to GND. In the sketch, repeat the reading and the math for each pin. A4 and A5 are also the I2C pins of the Nano, so leave them free if you plan to add an LCD or OLED later.

Project Ideas

  • A freezer alarm that sounds a buzzer when the inside climbs above -12°C
  • An aquarium monitor that shows the water temperature on an LCD
  • A fermentation helper for home brewing that switches a heating pad with a relay to keep the brew between 18°C and 22°C
  • A two-probe logger that compares the water going into and coming out of a solar water heater

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!