LM35 Arduino code with LCD

Here it is shown how to read environment temperature using LM35 temperature sensor with Arduino and display on LCD. There are couple of variation of LM35 such as LM35DZ, LM35DT, LM35CZ and any of these will work. Arduino code is provided that reads and displays the temperature on 16x2LCD.
 
The LM35 is a popular analog temperature sensor that is widely used with microcontrollers like Arduino for temperature sensing applications. It is a precision analog sensor that provides a linear voltage output proportional to the temperature in Celsius, making it easy to interface with microcontrollers and other electronic devices.

The LM35 temperature sensor is based on the principle of the output voltage being directly proportional to the temperature. It has a temperature range of -55°C to +150°C with an accuracy of ±0.5°C at room temperature. The LM35 sensor is a 3-pin device, with one pin for ground (GND), one for supply voltage (VCC), and one for the output voltage (VO) which corresponds to the temperature being sensed.

The LM35 sensor has a low output impedance and does not require any external components for temperature measurement. It can be easily interfaced with an analog input pin of a microcontroller or other analog devices. The output voltage of the LM35 sensor is linear and directly proportional to the temperature in Celsius, with a sensitivity of 10 mV/°C. For example, if the output voltage of the LM35 sensor is 250 mV, it corresponds to a temperature of 25°C.

The LM35 sensor is widely used in various applications such as temperature monitoring and control systems, weather stations, HVAC (Heating, Ventilation, and Air Conditioning) systems, industrial automation, and many other temperature sensing applications. It is simple to use, accurate, and reliable, making it a popular choice for temperature sensing in a wide range of projects.

When using the LM35 sensor in a project, it's important to take care of proper calibration, accurate power supply voltage, and noise reduction techniques to ensure accurate temperature measurements. Reading the analog output of the LM35 sensor and converting it to temperature values can be easily done using the built-in ADC (Analog-to-Digital Converter) of microcontrollers like Arduino, along with simple mathematical calculations.

The circuit diagram below shows LM35 connection with Arduino and LCD.
 
LM35 connection with Arduino and LCD
 
The following shows LM35 pinout.
LM35 TO TransistorPackage
Fig: LM35 TO-Transistor Package

The first pin is Vcc which is connected +5V, the second pin is Vo which is the sensor data pin and the third pin is GND which is the ground pin. The Vcc pin is connected to +5V power source and the GND pin is connected to ground common with Arduino. The sensor data output pin Vo is connected to A0 analog input pin of Arduino.

The LM35 Arduino program code with LCD is below.


//Program for LM35 Temperature sensor with Arduino
//Source:https://ee-diary.com

#include <LiquidCrystal.h>
#include <stdlib.h>


LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // setup the LCD interface pins
char TempC[16], TempF[16];	//buffer to holder string

void setup(){
	lcd.begin(16,2); // initialize the LCD
	lcd.print("Temperature:"); //initial message
	//lcd.setCursor(0,1);
	delay(100);	//100ms startup delay
}

void loop() {
	float Tc = analogRead(A0);
	Tc = (Tc/10)*4.9;
	float Tf = Tc*1.8+32;
	//lcd.print(String(T));
    lcd.setCursor(0,1);
	dtostrf(Tc, 3, 2, TempC);
    strcat(TempC, "C");
	lcd.print(TempC);
	lcd.print("/");
    dtostrf(Tf, 3, 2, TempF);
    strcat(TempF, "F");
	lcd.print(TempF);
	
}


The following video shows simulation of how the LM35 temperature sensor with Arduino and LCD works.


In conclusion, the LM35 is a widely used analog temperature sensor that provides accurate and linear temperature measurements. It is easy to interface with microcontrollers and other electronic devices, making it a popular choice for temperature sensing in various applications.

In this LM35 Temperature Sensor with Arduino and LCD tutorial we have used Arduino Uno which uses ATmega328p microcontroller. The code for LM35 with ATmega328p microcontroller and LCD is provided in LM35 Temperature Sensor with ATmega32 and LCD

References:

[1] Transfer temperature data Wirelessly using 434MHz RF Module

[2] Arduino AD8495 Thermocouple Amplifier

Post a Comment

Previous Post Next Post