Temperature Reading Using LM35 Temperature Sensor

Connecting LM35 Temperature Sesnor With Arduino

Image below shows pinout of LM35 when viewed from back side vout is the pin which gives output in response for changing voltages.


 LM35 has linear vout changes in response to changing temperature, LM35 has got sensitivity of 10mV / Celsius

following are the connections of lm35 with Arduino for the code given below.

1) VCC = Arduino 5V

2) Vout = Arduino Pin A3

3) GND = Arduino Ground

For display I am using I2C LCD for my I have used following connections as shown in diagram given below this diagram shows connection of I2C module with LCD and with Arduino.



To see how temperature sensor lm35 works with Arduino you could see this video given below.


Code For Arduino

#include <LiquidCrystal_I2C.h>
const int sensor=A3;                                // Assigning analog pin A3 to variable 'sensor'
float tempc;                                              //variable to store temperature in degree Celsius
float tempf;                                               //variable to store temperature in Fahreinheit
float vout;                                                 //temporary variable to hold sensor reading
LiquidCrystal_I2C lcd(0x27, 16, 2);        // Defining LCD 
void setup() 
{
pinMode(sensor,INPUT); // Configuring sensor pin as input
lcd.init();                           // For LCD
lcd.backlight();                  // For Lcd Back Light  
}
void loop() 
{
vout=analogRead(sensor); //Reading the value from sensor
vout = (vout*500)/1023;    // As arduinio had got 10 Bits so 2^10 = 1024 and starting from zero it is 1023
                                            // 5V is equivalent to 1023 and 10 mV of output from LM35 is equal to 1 C
                                            // therefore for LM35 maximum of Vout could be in 5/10mV divisions = 500
                                            // now this 500 is equivalent to 1023 so applying ratios 
                                            //                                                      500 C : 1023 Digital Equivalent
                                            //                                      Measured Temp : Vout Analogue to Digital
                                            // After cross multiplication         Measured Temp = (500 * vout) / 1023           
tempc=vout;                        // Storing value in Degree Celsius
tempf=(vout*1.8)+32;         // Converting to Fahrenheit
                                             // FROM HERE ONWARDS CODE IS FOR DISPLAY ON LCD                   
lcd.setCursor(0,0);               
lcd.print("Temp F = ");
lcd.print(tempf);
lcd.setCursor(0,1);
lcd.print("Temp C = ");
lcd.print(tempc);
delay(200);                           // Delay is given to avoid rapid faluctuations on display on LCD.                 
}

Comments

Popular posts from this blog

DS3231 Real Time Clock Interfacing With Arduino

FM Transmitter Project

4 Way Traffic Signal Using Flip Flops