DIY Temperature Measurement Setup with LM35 Sensor, ATmega32 Microcontroller, and LCD

In this instructional guide, you’ll be introduced to utilizing the LM35 temperature sensor alongside the ATmega32 microcontroller. You’ll gain insights into the process of interfacing the temperature sensor with the ATmega32 and displaying the temperature readings on an LCD screen. This tutorial covers displaying temperature values in both Celsius and Fahrenheit. Moreover, you’ll delve into the coding aspects, learning how to program the temperature sensor with the ATmega32 while also accessing the LCD. The tutorial includes provided code at its conclusion, along with a video demonstration.

Before delving further into this tutorial, you might find interest in exploring our other tutorials:

– Displaying Temperature and Humidity Using DHT11 & Arduino with Code on an LCD
– Integrating the LM35 Temperature Sensor with Arduino and LCD

To offer you a preview of what to expect in this tutorial, below is an image depicting the interfacing setup of the LM35, ATmega32 microcontroller, and LCD on a breadboard.

Circuit Diagram of Interfacing LM35, ATmega32 and LCD

The schematic illustrating the connection of the LM35 to the ATmega32 microcontroller and a 16×2 LCD is presented below.

The LM35 temperature sensor seamlessly interfaces with a microcontroller, requiring no additional external circuitry. It can directly link to any ADC pin of the microcontroller. Its three pins include a positive terminal (accepting 4V to 30V supply), connected here to a +5V supply. The second pin serves as the signal pin, linked to either ADC0 or pin 40 of the ATmega32 microcontroller. The third pin functions as the ground, connected to the common ground.

For the 16×2 LCD connection, it’s linked to PORTD, utilizing only 4 pins for data transfer. The R/W pin is grounded, utilizing a total of 6 pins for RS, E, and the 4 data lines connected from PD2 to PD7 pins of the microcontroller.

Working Mechanism

The temperature analog value is read by the ATmega32 through ADC0 (pin 40) and internally scaled to the appropriate range using software. Afterward, this converted temperature value is transmitted to the LCD for display.

Video Demonstration

Watch the following video to see how it works.

Programming ATmega32, LM35 temperature sensor and LCD

Below, you’ll find the C programming code for integrating LM35 and LCD with ATmega32.

#ifndef F_CPU
#define FCPU 4000000UL

#include <avr/io.h>
#include <util/delay.h>

int main()

char Ctemp[10], Ftemp[10];

float c, f;

c = (adcread(0)*4.88);
c = (c/10.00);
f = (c*9)/5 + 32;

dtostrf(c, 6, 2, Ctemp);
dtostrf(f, 5, 2, Ftemp);

return 0;

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top