Interface LM35 to measure temperature with AVR microcontroller. The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. LM35 can measure temperatures from -55deg to +150deg.
In this circuit the Atmega16 is used and the inbuilt ADC is used to convert the analog voltage from the LM35 to digital value.
Circuit Diagram
Bascom code
””””””””””””’
””””””””””””’
‘ www.avrprojects.info ‘
””””””””””””’
$regfile = “m16def.dat”
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.0 , Rs = Portd.1
Config Adc = Single , Prescaler = Auto
Deflcdchar 0 , 12 , 18 , 18 , 12 , 32 , 32 , 32 , 32
Deflcdchar 1 , 32 , 4 , 12 , 28 , 28 , 32 , 32 , 32
Deflcdchar 2 , 32 , 4 , 14 , 31 , 31 , 32 , 32 , 32
Deflcdchar 3 , 32 , 4 , 14 , 31 , 31 , 7 , 6 , 4
Deflcdchar 4 , 32 , 4 , 14 , 31 , 31 , 31 , 14 , 4
Deflcdchar 5 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Dim A As Word
Dim B As Byte
B = 1
Start Adc
Cursor Off
Cls
Locate 2 , 1
Lcd “avrprojects.info”
Do
A = Getadc(0)
A = A / 2
Locate 1 , 2
Lcd “Temp =” ; A ; Chr(0) ; “c “
Locate 1 , 16
Lcd Chr(b)
Waitms 500
Incr B
If B > 6 Then B = 1
Loop
End