Arduino as a Thermometer

Arduino as a Thermometer

The Arduino Thermometer project is very similar to the Arduino Voltmeter project, in that it measures an analog voltage, calculates an output value, and displays that value. The difference is that the voltage comes from a TI LM35 temperature sensor.

Arduino thermometer project with LCD and LM35 temperature sensor.

This project is a modification to the older project, which used a parallel LCD interface. The parallel interface used 8 of the Uno's 11 useful digital lines. The I2C LCD that replaces it uses two analog inputs - A4 and A5.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Set the LCD to address 0x27, 16 chars, and 2 lines.
LiquidCrystal_I2C lcd(0x27,16,2);

void setup()
{
  lcd.init();
  lcd.backlight();
}

void loop()
{
  char str[16];
  double degC, degF;

  // Read the LM35 sensor on A3.
  int adu = analogRead(A3);

  // Calculate the temperature.
  degC = adu * 0.488;
  degF = (adu * 0.8784) + 32;

  // Turn it into a string.
  memset(str, 0, sizeof(str));
  dtostrf(degC,1,2,str);
  strcat(str, " C ");
  dtostrf(degF,1,2,str+(strlen(str)));
  strcat(str, " F");

  // Display the header and the string.
  lcd.setCursor(0,0);
  lcd.print("Temperature");
  lcd.setCursor(0,1);
  lcd.print(str);

  delay(1000);
}
	
An Arduino thermometer using the LM35 and an LCD display to show the temperature in degrees Fahrenheight and Centigrade.

The LM35 uses A3 but you could connect it to any available analog input.

This project shows that most things Arduino center around the Arduino software, and the hardware sort of takes care of itself. For this project, I plugged in an I2C LCD, a three wire temperature sensor, and wrote a few lines of code. The software libraries for Arduino take care of the rest of it.

Arduino Board Logo

 

Arduino-Board is the go-to source for information on many available Arduino and Arduino-like boards, tutorials and projects.

Help and Support

Arduino-Board

Stay updated

Sign up if you would like to receive our once monthly newsletter.