Built-in project · Arduino Uno R3

Thermistor on A0, degrees on an LCD (pins 4, 6, 10 to 13), on an Arduino Uno

A 10k pull-up from 5 V to A0 and a thermistor from A0 to ground; the beta equation shows Celsius and Fahrenheit on a 16x2 LCD wired to pins 4, 6 and 10 to 13. 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.

Thermistor on A0, degrees on an LCD (pins 4, 6, 10 to 13) · 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
// A thermometer: a thermistor on A0, Celsius and Fahrenheit on the LCD.
//
//   5V -> 10k resistor -> A0 -> thermistor -> GND
//   LCD RS -> pin 4    LCD E -> pin 6
//   LCD D4 -> pin 10   D5 -> pin 11   D6 -> pin 12   D7 -> pin 13
//   LCD RW, VSS, K -> GND     VDD, A -> 5V
//   LCD V0 (contrast) -> GND here; on the bench, the middle leg of a pot
//
// The thermistor is at the bottom of the divider: as it warms its resistance
// falls, and so does the reading on A0. From the reading the sketch works out
// the thermistor's resistance,
//
//   R = 10000 * reading / (1023 - reading)
//
// and the beta equation (10k at 25 C, beta 3950) turns it into kelvin.
//
// Drag the thermistor's temperature and watch the display.

#include <LiquidCrystal.h>
#include <math.h>

const int SENSOR = A0;
const float BETA = 3950.0;
const float R25 = 10000.0;

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

void setup() {
  lcd.begin(16, 2);
  Serial.begin(9600);
  Serial.println("Mokxi Uno: thermistor on A0, LCD on pins 4, 6 and 10 to 13");
}

void loop() {
  int reading = analogRead(SENSOR);
  if (reading < 1) reading = 1;
  if (reading > 1022) reading = 1022;
  float resistance = R25 * reading / (1023.0 - reading);
  float kelvin = 1.0 / (1.0 / 298.15 + log(resistance / R25) / BETA);
  float celsius = kelvin - 273.15;
  float fahrenheit = celsius * 1.8 + 32.0;
  lcd.setCursor(0, 0);
  lcd.print("Temp:        C ");
  lcd.setCursor(6, 0);
  lcd.print(celsius, 1);
  lcd.setCursor(0, 1);
  lcd.print("Fahr:        F ");
  lcd.setCursor(6, 1);
  lcd.print(fahrenheit, 1);
  Serial.print(celsius, 1);
  Serial.println(" C");
  delay(500);
}

Parts list

5 parts, plus the jumper wires. Every one is in the editor's parts bin.

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 13; Character LCD, 16x2 pin D7
  • Arduino Uno R3 pin 12; Character LCD, 16x2 pin D6
  • Arduino Uno R3 pin 11; Character LCD, 16x2 pin D5
  • Arduino Uno R3 pin 10; Character LCD, 16x2 pin D4
  • Arduino Uno R3 pin 6; Character LCD, 16x2 pin E
  • Arduino Uno R3 pin 4; Character LCD, 16x2 pin RS
  • 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.