Projects / NTC thermistor thermometer

NTC thermistor thermometer

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. UNO11.9 mASSD1306

    Install the libraries

    Adafruit SSD1306 and Adafruit GFX Library.

  2. UNO

    Measure the fixed resistor

    Note its real value and put it in R_FIXED.

  3. UNO23.9°C

    Wire the divider

    5V to 10k to A0, A0 to the thermistor to GND.

  4. UNO11.9 mASSD1306

    Wire the OLED

    SDA and SCL on A4 and A5.

  5. UNO

    Upload the sketch

    Room temperature shows, about 20 to 30 degrees.

  6. UNO24.0°C

    Pinch the thermistor

    The temperature climbs slowly.

  7. UNO

    Compare with a reference thermometer

    Note the difference.

  8. UNO

    Set offsetC to the difference

    Upload again.

In short

How do you build an NTC thermistor thermometer?

A thermistor in a divider gives a temperature reading that you calibrate against a known thermometer. You need Arduino Uno R3, NTC thermistor 10 kΩ (B3950), Resistor 10 kΩ, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
5V to 10 kilohm resistor to A0Uno A0Fixed half of the divider
A0 to the NTC thermistor to GNDUno A0Reading falls as temperature rises
OLED SDA and SCLUno A4 and A5I2C, address 0x3C
OLED VCC and GNDUno 5V and GNDCheck your module voltage

Code

A negative-temperature-coefficient (NTC) thermistor is a resistor whose resistance falls as it warms. In the divider the thermistor sits between A0 and ground, so the reading is raw = 1023 times R divided by (R_fixed plus R), which gives R = R_fixed times raw divided by (1023 minus raw). The beta equation then turns resistance into temperature: 1 over T equals 1 over T0 plus the natural log of R over R0 divided by B, with T in kelvin. For a typical 10 kilohm B3950 part, R0 is 10 kilohm at 25 degrees Celsius and B is 3950. The beta model is accurate to about a degree near room temperature but drifts far from 25 degrees, so for better accuracy near body or kettle temperatures use the Steinhart-Hart equation with three constants. To calibrate, hold the thermistor next to a reference thermometer in a glass of room-temperature water and enter the difference in offsetC. Averaging 32 readings reduces noise. The thermistor also warms itself slightly because of the current through it, which is small here.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const float R_FIXED = 10000.0;     // series resistor in ohms, measure yours
const float R_NOMINAL = 10000.0;   // thermistor resistance at 25 C
const float T_NOMINAL = 25.0;      // reference temperature in C
const float BETA = 3950.0;         // B value from the thermistor data
float offsetC = 0.0;               // calibration offset, set after comparing with a thermometer

float readTempC() {
  long sum = 0;
  for (uint8_t i = 0; i < 32; i++) { sum += analogRead(A0); delay(2); }
  float raw = sum / 32.0;
  if (raw < 1 || raw > 1022) return NAN;                   // open or shorted sensor
  float r = R_FIXED * raw / (1023.0 - raw);                // thermistor is between A0 and GND
  float tK = 1.0 / (1.0 / (T_NOMINAL + 273.15) + log(r / R_NOMINAL) / BETA);
  return tK - 273.15 + offsetC;
}

void setup() {
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.setTextColor(SSD1306_WHITE);
  Serial.begin(9600);
}

void loop() {
  float c = readTempC();
  oled.clearDisplay();
  oled.setTextSize(1);
  oled.setCursor(0, 0);
  oled.print("NTC thermometer");
  oled.setTextSize(3);
  oled.setCursor(0, 20);
  if (isnan(c)) oled.print("---");
  else { oled.print(c, 1); }
  oled.setTextSize(1);
  oled.setCursor(0, 54);
  if (!isnan(c)) { oled.print(c * 9.0 / 5.0 + 32.0, 1); oled.print(" F"); }
  oled.display();
  Serial.println(c, 2);
  delay(500);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

24.97
24.95
24.96
24.97
24.96
24.95

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Room temperature18 to 30 C
Pinched between fingersRises toward 32 C
Cold glass of waterFalls below room temperature
Unplug the thermistorShows dashes
Compare after calibrationWithin about 1 C near room temperature

If it does not work

Reads very high or very low

The thermistor and resistor are swapped, check the order.

Reading drifts

The probe is warming itself or is near a heat source.

Large error away from 25 C

The beta model is limited, use Steinhart-Hart.

Display blank

Try address 0x3D, and check the display voltage.

Noisy values

Keep the thermistor leads short and away from motors.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the NTC thermistor thermometer?

Arduino Uno R3, NTC thermistor 10 kΩ (B3950), Resistor 10 kΩ, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the NTC thermistor thermometer take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the NTC thermistor thermometer works?

Room temperature: 18 to 30 C. Pinched between fingers: Rises toward 32 C. Cold glass of water: Falls below room temperature.

Reads very high or very low: what should I check?

The thermistor and resistor are swapped, check the order.

Reading drifts: what should I check?

The probe is warming itself or is near a heat source.

Large error away from 25 C: what should I check?

The beta model is limited, use Steinhart-Hart.

Display blank: what should I check?

Try address 0x3D, and check the display voltage.