Arduino and LM35 Temperature Measurement

Introduction: Arduino and LM35 Temperature Measurement

Abstract

The LM35 is a precision integrated-circuit temperature sensor, which is connected to Arduino and measures the temperature in Celsius format. The program converts the reading into either Fahrenheit, or Kelvin or Rankine, accordance with the user selection and display it on LCD screen.

Parts and components

Arduino Uno board

16x2 LCD

1 K ohm potentiometer

LM35

Push Button

10K resistor = 2 Nos

Step 1: Schematic

The 16x2 is very common type LCD, with two rows, and each row displays 16 characters of either 5x7 or 5x8 dot matrix characters.

The LCD is available in a 16 pin package. It consists of back light and contrast adjustment function and each dot matrix has 5×8 dot resolution.

//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,6,5,4,3,2);

// this constant won't change:
const int buttonPin = 8; // the pin that the pushbutton is attached to

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

// compare the buttonState to its previous state
if (buttonState != lastButtonState)
{
// if the state has changed, increment the counter
if (buttonState == HIGH)
{
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
// (note: line 0 is the first row, since counting begins with 0):
lcd.setCursor(0, 0);
lcd.print(" "); //Print blanks to clear the row
lcd.setCursor(0, 0);
switch(buttonPushCounter)
{
case 1:
lcd.print("Celsius");
break;
case 2:
lcd.print("Farenheit");
break;
case 3:
lcd.print("Kelvin");
break;
case 4:
lcd.print("Rankine");
break;
default:
buttonPushCounter = 1;
lcd.print("Celsius");
break;
}
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;