Arduino UNO R4 - NTC Thermistor Temperature Sensor

In this guide, we will learn how to use a waterproof 10K NTC thermistor probe with the Arduino UNO R4. The steel tip of this probe holds no chip at all, only a tiny resistor that reacts strongly to heat. That makes it cheap, tough and happy under water, so it fits places where a normal sensor board would not survive: a fish tank, a fridge, or a jar of home brew. In detail, we will learn:

Arduino UNO R4 measures water temperature with a waterproof 10K NTC thermistor probe

Overview of NTC Thermistor Temperature Sensor

DIYables 10K NTC thermistor waterproof probe with its 2-pin JST XH2.54 plug
image source: diyables.io

The DIYables probe seals a 10K NTC thermistor inside a stainless-steel tube with a round end, 5mm wide and 25mm long. A black two-wire cable, 0.5m long, runs from the tube to a white JST XH2.54 2-pin plug. There is no small board and no chip here, so the Arduino UNO R4 cannot read the probe on its own. It needs a second resistor of the same value. That is why every probe in the pack of five comes with its own matching 10K resistor.

DIYables 10K NTC Thermistor Probe
Sensor type NTC thermistor
Resistance at 25°C 10kΩ, ±1%
B value (beta) 3950
Temperature range -20°C to 105°C
Probe stainless steel, waterproof, 5mm x 25mm, round tip
Cable 0.5m, 2 wires
Connector JST XH2.54, 2 pins
Dissipation constant 5mW/°C (typical)
In the pack 5 probes and 5 matching 10K resistors

The two wires have no polarity, because a thermistor is simply a resistor. Push a male jumper wire into each hole of the white plug, then:

  • Either probe wire: connect to the 5V pin of the Arduino UNO R4.
  • The other probe wire: connect to A0, and also to one leg of the 10K resistor.
  • The free leg of the 10K resistor: connect to GND.

How It Works

A thermistor is a resistor whose value changes a lot with temperature. NTC stands for Negative Temperature Coefficient: when the tip warms up, its resistance goes down. The Arduino UNO R4 cannot measure ohms, but it can measure a voltage. With the 10K resistor placed below the probe, a warmer probe lifts the voltage on A0, and a colder probe lets it sink. The code reads that voltage, works out the resistance of the probe, and turns the resistance into degrees.

Temperature Probe resistance Voltage on A0 analogRead() at 14 bits
5°C about 25.9kΩ 1.39V 4560
15°C about 15.8kΩ 1.94V 6341
25°C 10.0kΩ 2.50V 8192
40°C about 5.3kΩ 3.27V 10707
85°C about 1.1kΩ 4.51V 14777

The resistance does not follow a straight line, so the code uses the B-parameter equation (often called the beta formula):

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

  • T is the temperature in kelvin. Subtract 273.15 to get °C.
  • T0 = 298.15K (25°C), and R0 = 10000Ω is the probe's resistance at that temperature.
  • B = 3950, the B value of this probe.
  • R is the resistance that the Arduino UNO R4 has just worked out.

If you search online you will also find the Steinhart-Hart equation. It needs three calibration numbers instead of one and wins only over very wide ranges, so this guide keeps the simpler B formula. At ordinary room temperatures the UNO R4 reading is typically about 1°C from a reference thermometer, mainly because of the 10K resistor tolerance and the ADC.

Two other temperature pages for the Arduino UNO R4 may fit your project better:

Wiring Diagram

The probe and the 10K resistor make a voltage divider between 5V and GND, and A0 reads the point in the middle. Use the 5V pin, not 3.3V. By default, analogRead() on the Arduino UNO R4 measures against 5V, so a divider fed from that same 5V gives a clean ratio. If your USB port gives 4.9V instead of 5V, both sides move together, and the temperature does not change.

In the diagram, the resistor joins the A0 wire and the GND wire directly. On your desk, a small breadboard makes this three-way joint easy. No breadboard? Twist or solder the resistor legs onto the jumper wires, then cover the bare metal with tape or heat-shrink tubing.

The wiring diagram between Arduino UNO R4 NTC thermistor

This image is created using Fritzing. Click to enlarge image

NTC Probe Part Arduino UNO R4 Pin
Probe wire A (either one) 5V
Probe wire B A0
10K resistor, first leg A0
10K resistor, second leg GND

If the project will run for a long time, or sit inside a box, it is better to fix the wires with screws. A Screw Shield V2 or a Proto Screw Terminal Block Shield solves this. Plug it into the Arduino UNO R4 and screw the wires in. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

The wiring diagram between Arduino UNO R4 NTC thermistor Screw Shield

This image is created using Fritzing. Click to enlarge image

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

Look at the 10K resistor in this picture: it is screwed straight into the shield. One leg sits in a GND terminal, and the other leg shares the A0 terminal with the yellow probe wire, so the GND wire is not needed.

※ NOTE THAT:

  • Only the steel tip is waterproof. Keep the white plug and the resistor joint dry, above the water line.
  • The probe cable can be made longer with extra wire. Just keep the run away from motor and mains cables, which can add noise to the reading.

How To Program For NTC Thermistor

No library is needed. analogRead() and the math function log() are already part of the Arduino core.

  • Name the pin, and write down the values of the probe:
const int NTC_PIN = A0; const float SERIES_RESISTOR = 10000.0; // the 10K resistor const float NOMINAL_RESISTANCE = 10000.0; // probe resistance at 25°C const float NOMINAL_TEMPERATURE = 298.15; // 25°C in kelvin const float B_COEFFICIENT = 3950.0;
  • Ask for 14-bit readings in setup(). analogRead() then returns 0 to 16383:
analogReadResolution(14);
  • Read A0 ten times and take the average:
long total = 0; for (int i = 0; i < 10; i++) { total += analogRead(NTC_PIN); delay(10); } float adcAverage = total / 10.0;
  • Work out the resistance of the probe from the ratio:
float ntcResistance = SERIES_RESISTOR * (16383.0 / adcAverage - 1.0);
  • Apply the B formula. In C++, log() is the natural logarithm (ln):
float kelvin = 1.0 / (1.0 / NOMINAL_TEMPERATURE + log(ntcResistance / NOMINAL_RESISTANCE) / B_COEFFICIENT); float celsius = kelvin - 273.15;
  • Before the math, check that the average is not close to 0 (probe unplugged) or close to 16383 (short circuit). Then the sketch never prints "inf" or "nan".

※ NOTE THAT:

Prefer the usual 0 to 1023 range? Remove analogReadResolution(14); and use 1023.0 in place of 16383.0. The temperature stays the same, only the steps get coarser: around 25°C, one step is about 0.1°C at 10 bits and less than 0.01°C at 14 bits. The real accuracy still depends on the probe and the resistor, not on the number of bits.

Arduino UNO R4 Code - Thermistor Temperature in Celsius and Fahrenheit

The sketch below puts all these steps together. About once a second, it prints the averaged 14-bit reading, the resistance of the probe, and the temperature in both units. It also tells you when the probe looks unplugged or shorted.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-ntc-thermistor-temperature-sensor */ const int NTC_PIN = A0; // Arduino UNO R4 pin at the junction of the thermistor and the 10K resistor const float SERIES_RESISTOR = 10000.0; // the 10K resistor between A0 and GND, in ohms const float NOMINAL_RESISTANCE = 10000.0; // thermistor resistance at 25°C, in ohms const float NOMINAL_TEMPERATURE = 298.15; // 25°C written in kelvin const float B_COEFFICIENT = 3950.0; // B value of the DIYables 10K NTC probe const float ADC_MAX = 16383.0; // highest analogRead() value at 14-bit resolution const int SAMPLE_COUNT = 10; // number of readings averaged for each result void setup() { Serial.begin(9600); analogReadResolution(14); // the Arduino UNO R4 ADC can return 0 to 16383 instead of 0 to 1023 } void loop() { // add up several readings, because a single thermistor reading jumps a little long total = 0; for (int i = 0; i < SAMPLE_COUNT; i++) { total += analogRead(NTC_PIN); delay(10); } float adcAverage = (float)total / SAMPLE_COUNT; if (adcAverage < ADC_MAX * 0.01) { // the 10K resistor pulls A0 down to 0V when the probe is missing Serial.println("A0 is near 0V -> is the thermistor plugged in?"); } else if (adcAverage > ADC_MAX * 0.99) { // A0 sits at 5V when the probe is shorted or the 10K resistor is missing Serial.println("A0 is near 5V -> check for a short or a missing 10K resistor"); } else { // the divider is fed from 5V, the same voltage the ADC measures against, // so only the ratio ADC_MAX / adcAverage is needed float ntcResistance = SERIES_RESISTOR * (ADC_MAX / adcAverage - 1.0); // B-parameter equation: 1/T = 1/T0 + ln(R/R0) / B (T in kelvin) float kelvin = 1.0 / (1.0 / NOMINAL_TEMPERATURE + log(ntcResistance / NOMINAL_RESISTANCE) / B_COEFFICIENT); float celsius = kelvin - 273.15; float fahrenheit = celsius * 9.0 / 5.0 + 32.0; Serial.print("A0 = "); Serial.print(adcAverage, 0); Serial.print(" -> NTC "); Serial.print(ntcResistance, 0); Serial.print(" ohms -> "); Serial.print(celsius, 1); Serial.print(" °C ("); Serial.print(fahrenheit, 1); Serial.println(" °F)"); } delay(1000); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Wire the probe and the 10K resistor to the Arduino UNO R4 as the wiring diagram shows.
  • Connect the Arduino UNO R4 to your computer with a USB Type-C cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino UNO R4 board (e.g., Arduino UNO R4 WiFi or Arduino UNO R4 Minima) and COM port.
  • Copy the code above into the Arduino IDE and click the Upload button.
  • Open the Serial Monitor at 9600 baud. Let the probe lie on the desk for a few lines.
  • Take a glass of cold water from the fridge and put the steel tip into it.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Uno R4 WiFi
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno R4 WiFi' on 'COM15')
New Line
9600 baud
A0 = 7988 -> NTC 10510 ohms -> 23.9 °C (75.0 °F) A0 = 7975 -> NTC 10543 ohms -> 23.8 °C (74.9 °F) A0 = 7993 -> NTC 10497 ohms -> 23.9 °C (75.0 °F) A0 = 7203 -> NTC 12745 ohms -> 19.6 °C (67.4 °F) A0 = 6187 -> NTC 16480 ohms -> 14.2 °C (57.5 °F) A0 = 5594 -> NTC 19287 ohms -> 10.9 °C (51.6 °F) A0 = 5262 -> NTC 21135 ohms -> 9.1 °C (48.3 °F) A0 = 5131 -> NTC 21929 ohms -> 8.3 °C (47.0 °F) A0 = 5079 -> NTC 22256 ohms -> 8.0 °C (46.4 °F)
Ln 11, Col 1
Arduino Uno R4 WiFi on COM15
2

The first three lines show the room air. In the cold water, the value falls fast at first, then more and more slowly. The steel tube has to cool down too, so give the probe several seconds before you trust a new number.

Want to test your probe? Fill a glass with crushed ice and a little water, stir, and wait a minute. The Serial Monitor should show close to 0°C.

If the Serial Monitor says "A0 is near 0V", a wire has slipped out of the white plug, or A0 is not connected. "A0 is near 5V" usually means that the 10K resistor is missing, or that the A0 wire touches 5V somewhere.

Project Ideas

Some ways to use the probe with the Arduino UNO R4:

  • Fridge alarm: beep a buzzer when the fridge stays above 8°C for ten minutes.
  • Aquarium watch: show the water temperature on the 12x8 LED matrix of the Arduino UNO R4 WiFi.
  • Home brew log: send the fermentation temperature over WiFi to a web page once a minute.
  • Seed tray heater: switch a heating pad with a relay to hold a set temperature.
  • Two zones: add a second probe and resistor on A1, then compare the inside and the outside of a cool box.

Video Tutorial

Function References

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