Sie sind auf Seite 1von 12

11/11/2018 LM35 Temperature Sensor With Seven Segment Display

November 11, 2018

MaxPhi
Arduino Projects & Tutorials

 MAIN MENU

Sélectionner une langue


Fourni par Traduction
AVR PROJECTS

LM35 Temperature Sensor Interfacing with


Seven Segment Display using AVR
September 2, 2017 - by admin - 2 Comments.

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage
over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a
large constant voltage from its output to obtain convenient Centigrade scaling.

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 1/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

In this project, we are measuring the temperature using the LM35 temperature sensor and
display on the two seven segment. The LM35 sensor can measure the temperature from full
−55° to +150°C range. For display the temperature up to +150°C we need three seven segment
display. But in this project, to make project simple and easy to understand we used only two
segments.

The main part of this project is the understanding the analog to digital conversion(ADC) in the
AVR microcontroller and the other is how to display that temperature value to the two seven
segment display.

Table of Contents [hide]

1 What is LM35 Temperature Sensor


2 LM35 Pinout
3 How to Calculate Analog to Digital Value – Formula
3.0.1 Example:
4 LM35 Temperature Sensor and Seven Segment Display AVR Connection
5 LM35 Temperature Sensor and Seven Segment Display AVR Code

What is LM35 Temperature Sensor


The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius(Centigrade) temperature. The LM35 does not require any
external calibration or trimming to provide typical accuracies of ±1⁄4°C at room temperature
and ±3⁄4°C over a full −55 to +150°C temperature range.
Features

Calibrated directly in ° Celsius (Centigrade)


Linear + 10.0 mV/°C scale factor
0.5°C accuracy guaranteeable (at +25°C)
Rated for full −55° to +150°C range
Suitable for remote applications
Low cost due to wafer-level trimming
Operates from 4 to 30 volts
Less than 60 μA current drain
Low self-heating, 0.08°C in still air
Nonlinearity only ±1⁄4°C typical
Low impedance output, 0.1 W for 1 mA load

More about LM35 Datasheet.

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 2/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

LM35 Pinout

How to Calculate Analog to Digital Value –


Formula
Use the following ratio:
e/V max  =  d/2 n– 1 
where

V max maximum voltage that the analog signal can assume


n number of bits available for the digital encoding, Here n = 10
d present digital encoding
e present analog voltage from the sensor

Example:
How to Calculate the Digital Value if we have 30 °C temperature.
Here
scale factor = 10.0 mV/°C or 0.01V/°C
If we have 30 °C temperature than Voltage = 30 * 0.01 = 0.3V
So e = 0.30V
Vmax = 5V
d = e * 2 n– 1 / V max 
d = 0.30 * 1023/5
d = 61.38 or almost double
Note: Every time we calculate the digital value, it is double to the temperature.
So in programming, we divide it by 2 for getting the approximate value of the temperature.

LM35 Temperature Sensor and Seven Segment


Display AVR Connection
https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 3/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

LM35 Temperature Sensor and Seven Segment


Display AVR Code
#include<avr/io.h>
#include <avr/interrupt.h>
#include<util/delay.h>

int count=0;
int d0,d1,seg;
int delay=5;
int ReadADC(uint8_t ch)
{
ADMUX=ch;
//Start Single conversion
https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 4/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

ADCSRA |= (1<<ADSC);
//Wait for conversion to complete
while(!(ADCSRA&(1<<ADIF)));
ADCSRA|=(1<<ADIF);
return(ADC);
}
void initADC()
{
ADMUX=(1<<REFS0);
ADCSRA=(1<<ADEN)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1);
}
void segment_code(int seg)
{
switch(seg)
{
case 1:
PORTD=0b11111001; //1
_delay_ms(delay);
break;
case 2:
PORTD=0b10100100; //2
_delay_ms(delay);
break;
case 3:
PORTD=0b10110000; //3
_delay_ms(delay);
break;
case 4:
PORTD=0b10011001; //4
_delay_ms(delay);
break;
case 5:
PORTD=0b10010010; //5
_delay_ms(delay);
break;
case 6:
PORTD=0b10000010; //6
_delay_ms(delay);
break;
case 7:
PORTD=0b11111000; //7

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 5/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

_delay_ms(delay);
break;
case 8:
PORTD=0b10000000; //8
_delay_ms(delay);
break;
case 9:
PORTD=0b10010000; //9
_delay_ms(delay);
break;
case 0:
PORTD=0b11000000; //0
_delay_ms(delay);
break;
}
}

int main()
{
DDRC=0b0000000;
DDRD=0xFF; // PORT D as output port
DDRB=0xFF; //PB0 and PB1 is segment select pins
initADC();
int analogVal;
while(1)
{
analogVal=ReadADC(0);
analogVal=analogVal/2;
count=analogVal;
//variable do containing the 10th digit of temperature
d0=count%10;
seg=d0;
PORTB=0b11111101;//select segment 0
segment_code(seg);//match and display
//get the 100th digit of temperature
d1=count/10;
d1=d1%10;
seg=d1;
PORTB=0b11111110;//select segment 1
segment_code(seg);//match and display
}

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 6/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

return 0;
}

RELATED POSTS

DTMF Controlled Home Automation using AVR Microcontroller and LCD Display
September 2, 2017

Bluetooth Home Automation using AVR Microcontroller


September 2, 2017

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 7/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

Android Mobile Phone Controlled Bluetooth Robot using AVR Microcontroller


September 2, 2017

PREVIOUS ARTICLE NEXT ARTICLE


Bluetooth Home Automation using AVR DTMF Controlled Home Automation using
Microcontroller AVR Microcontroller and LCD Display

About admin

View all posts by admin →

2 Comments on “LM35 Temperature Sensor Interfacing with


Seven Segment Display using AVR”

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 8/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

interest October 18, 2017 at 10:56 am

whoah thiѕ blog is fantastic i really like reаding


your posts. Keep up the good work! You realize, lots of people are һunting around
for this info, you can һelp them greatly.

REPLY

ananthakrisshnan October 24, 2017 at 2:36 pm

thanks for the ckt bro.. really helped me a lot

REPLY

Leave a Reply
Your email address will not be published. Required elds are marked *

COMMENT

NAME *

EMAIL *

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 9/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

WEBSITE

I'm not a robot


reCAPTCHA
Privacy - Terms

POST COMMENT

Search … SEARCH

Need Help in Your Electronics Project?


Are you facing problem in making your electronics project? We can make a project and guide you
at the very affordable amount. Enquiry about your project.

Name

Email

Mobile

Project Title

Write about your project...

SEND

CATEGORIES

Arduino Books

Arduino Projects

Arduino Tutorials

AVR Projects

Project Ideas

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 10/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

RECENT POSTS

5 Arduino Cookbooks Review: Why You Should Read Before Buying

10+ Arduino Programming Books for Beginners – A Complete Review

Electronics Projects List

Arduino Buzzer Tutorial And How To Use It With Arduino Board

DTMF Controlled Home Automation using AVR Microcontroller and LCD Display

About Us

Contact Us

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 11/12
11/11/2018 LM35 Temperature Sensor With Seven Segment Display

Copyright © 2018 MaxPhi. All rights reserved. | Privacy Policy | Sitemap

Powered by WordPress and HitMag.

https://www.maxphi.com/lm35-temperature-sensor-with-seven-segment-display 12/12

Das könnte Ihnen auch gefallen