You are on page 1of 4

Temperature Sensor and LCD

Temperature measurement and display using Arduino on a 16×2 LCD module which constantly monitors
temperature around the measurement field/range of LM35 and displays the same on LCD module.

LM35 is an analog, linear temperature sensor whose output voltage varies linearly with change in
temperature.

LM35 is three terminal linear temperature sensors from National semiconductors. It can measure
temperature from -55 º C to +150 º C. The voltage output of the LM35 increases 10mV per degree Celsius
rise in temperature. LM35 can be operated from a 5V supply and the stand by current is less than 60uA.

The pin out of LM35 is shown in the figure below:

We are using Arduino Uno as our microcontroller board and LM35 an analog temperature sensor can be
connected to Arduino as shown in circuit diagram.

As the output of LM35 is an analog signal, microcontrollers don’t accept analog signals as their input
directly.

We need to convert this analog output signal to digital before we can feed it to a microcontroller’s input. For
this purpose, we can use an ADC (Analog to Digital Converter).

If we are using a basic microcontroller like 8051, we need to use an external ADC to convert analog output
from LM35 to digital. We then feed the output of ADC (converted digital value) to input of 8051.

But modern day boards like Arduino and most modern day micro controllers come with inbuilt ADC. The
Arduino UNO has an in built 10 bit ADC (6 channel). We can make use of this in built ADC of Arduino to
convert the analog output of LM35 to digital output. Since Arduino UNO has a 6 channel inbuilt ADC, there
are 6 analog input pins numbered from A0 to A5. Connect analog out of LM35 to any of these analog input
pins of Arduino.

INPUT). // Assigning analog pin A1 to variable 'sensor' float tempc. delay(1000).print(tempc).which falls under LM35D series. // Configuring pin A1 as input Serial. LM35 is available in 3 series variations – LM35A. const int sensor=A1. The +5v for LM35 can be taken from the +5v out pin of Arduino UNO. . //variable to store temperature in Fahrenheit float vout. LM35D series is designed to measure from 0 degree Celsius to 100 degree Celsius LM35A series is designed to measure a wider range of -55º Celsius to 155 º Celsius. we have connected Vout of LM35 to A1 of Arduino. //Delay of 1 second for ease of viewing } Temperature Display on 16×2 LCD Module – using Arduino and LM35 Now add a 16×2 LCD display with LM35 and Arduino – interface and display the temperature values on this LCD display. tempc=vout. LM35C series is designed to measure from -40 º Celsius to 110 º Celsius. Serial.Connect LM35 to Arduino UNO as shown in circuit diagram.println(). Serial.print("\t").begin(9600). //temporary variable to hold sensor reading void setup() { pinMode(sensor. We are using the LM35Dz sensor. //variable to store temperature in degree Celsius float tempf.print(tempf). Also the ground pin of LM35 can be connected to GND pin of Arduino UNO. LM35C and LM35D series.print("\t"). Connect Vout (the analog out of LM35) to any of the analog input pin of Arduino uno. In this circuit diagram. Serial.println(). // Converting to Fahrenheit Serial. // Storing value in Degree Celsius tempf=(vout*1. So our min-max range of temperature measurement is 0 º Celsius to 100 º Celsius.print("in Fahrenheit="). } void loop() { vout=analogRead(sensor).print("in DegreeC="). Serial. Serial.8)+32. The main difference between these 3 versions of LM35 IC are in their range of temperature measurements. Serial. vout=(vout*500)/1023. Serial.

// Assigning analog pin A1 to variable 'sensor' float tempc. vout=(vout*500)/1023.h> LiquidCrystal lcd(12. 5. //variable to store temperature in Fahrenheit float vout. const int sensor=A1. //temporary variable to hold sensor reading void setup() { pinMode(sensor. // Configuring pin A1 as input Serial. 11.setCursor(0. lcd. #include<LiquidCrystal.Circuit Diagram – LM35 and Arduino – Temperature Display on 16×2 LCD The Arduino program for the circuit is given below. 3.begin(9600).print("in DegreeC= "). tempc=vout.0). 2). // Converting to Fahrenheit lcd. // Storing value in Degree Celsius tempf=(vout*1. lcd. } void loop() { vout=analogRead(sensor).begin(16. .INPUT).8)+32.2). delay(500). //variable to store temperature in degree Celsius float tempf. 4.

lcd. lcd.1). .lcd. delay(1000). it’s good to choose a 4 Digit 7 Segment Display unit.print("in Fahrenheit="). lcd.print(tempc). //Delay of 1 second for ease of viewing in serial monitor } For displaying temperature up to 3 digit values (100 ºCelsius or higher up to 999) with corresponding unit (Celsius of Fahrenheit).print(tempf).setCursor(0.