Built-in project · Arduino Uno R3

Thermistor thermometer on an Arduino Uno

A 10k thermistor and a 10k resistor make a divider on A0, and the beta equation turns the reading into degrees on a 16x2 LCD. The whole build, an Arduino Uno and 3 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Intermediate Runs in your browser. Free, and no account needed.

The parts retail for about $35. On Mokxi they're free.

Step by step, with the wiring and the common mistakes: Arduino 10k Thermistor: Wiring and Code

Thermistor thermometer · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Thermistor thermometer: a 10k thermistor on A0, the temperature on an LCD.
//
//   10k resistor   5V -> A0
//   thermistor     A0 -> GND
//   LCD            RS 12, E 11, D4 to D7 on 5, 4, 3, 2, as in the LCD lesson
//
// A thermistor is a resistor that changes with temperature: this kind (NTC)
// has 10k at 25 C and less when it is warmer. With the fixed 10k above it,
// the two make a voltage divider, and A0 reads where the middle sits.
//
// From the reading back to degrees takes two steps:
//   1. resistance:  R = 10000 * reading / (1023 - reading)
//   2. temperature: the beta equation, 1/T = 1/T0 + ln(R / R0) / B, with T0
//      = 298.15 K (25 C), R0 = 10000 and B = 3950 from the datasheet.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const float BETA = 3950.0;
const float R_FIXED = 10000.0;
const float R_25C = 10000.0;

void setup() {
  lcd.begin(16, 2);
  Serial.begin(9600);
  Serial.println("Mokxi Uno: thermistor thermometer");
}

void loop() {
  int reading = analogRead(A0);
  if (reading <= 0 || reading >= 1023) {
    lcd.setCursor(0, 0);
    lcd.print("Check wiring    ");
    delay(500);
    return;
  }
  float ohms = R_FIXED * reading / (1023.0 - reading);
  float kelvin = 1.0 / (1.0 / 298.15 + log(ohms / R_25C) / BETA);
  float celsius = kelvin - 273.15;
  float fahrenheit = celsius * 9.0 / 5.0 + 32.0;

  lcd.setCursor(0, 0);
  lcd.print("Temp ");
  lcd.print(celsius, 1);
  lcd.print(" C   ");
  lcd.setCursor(0, 1);
  lcd.print("     ");
  lcd.print(fahrenheit, 1);
  lcd.print(" F   ");

  Serial.print("temperature ");
  Serial.print(celsius, 1);
  Serial.println(" C");
  delay(500);
}

Parts list

5 parts, plus the jumper wires. They retail for about $35; on Mokxi they're free.

How it is wired

9 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Arduino Uno R3 pin 12; Character LCD, 16x2 pin RS
  • Arduino Uno R3 pin 11; Character LCD, 16x2 pin E
  • Arduino Uno R3 pin 5; Character LCD, 16x2 pin D4
  • Arduino Uno R3 pin 4; Character LCD, 16x2 pin D5
  • Arduino Uno R3 pin 3; Character LCD, 16x2 pin D6
  • Arduino Uno R3 pin 2; Character LCD, 16x2 pin D7
  • Arduino Uno R3 pin 5V; Resistor, 10k Ω pin 2; Character LCD, 16x2 pin VDD; Character LCD, 16x2 pin A
  • Ground: Arduino Uno R3 pin GND; Thermistor, 10k NTC pin 1; Character LCD, 16x2 pin VSS; Character LCD, 16x2 pin V0; Character LCD, 16x2 pin RW; Character LCD, 16x2 pin K
  • Arduino Uno R3 pin A0; Thermistor, 10k NTC pin 2; Resistor, 10k Ω pin 1

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.