Thursday, December 23, 2010

Digital thermometer with LM35 and PIC18F452

This can be a complete project on its own - a simple DIY digital thermometer with LCD display and only a handful of parts - the PIC18F452, LM35 and a small number of resistors and capacitors running off a regulated 5v supply.
Temperature range - 0 to 150'C
Display type - LCD (can be 16x1, 16x2 or anything larger)
Controller: PIC18F452
Programming Language: BASIC
Compiler: mikroBASIC PRO for PIC v3.20

program thermometer452

'Programmer: Syed Tahmid Mahbub
'Compiler: mikroBASIC PRO for PIC v3.20
'Target PIC: 18F452 - 40pin DIP
'Configuration: Check the project in the download link for the configuration bits

dim LCD_RS as sbit at RB4_bit
    LCD_EN as sbit at RB5_bit
    LCD_D4 as sbit at RB0_bit
    LCD_D5 as sbit at RB1_bit
    LCD_D6 as sbit at RB2_bit
    LCD_D7 as sbit at RB3_bit

    LCD_RS_Direction as sbit at TRISB4_bit
    LCD_EN_Direction as sbit at TRISB5_bit
    LCD_D4_Direction as sbit at TRISB0_bit
    LCD_D5_Direction as sbit at TRISB1_bit
    LCD_D6_Direction as sbit at TRISB2_bit
    LCD_D7_Direction as sbit at TRISB3_bit

dim ADCResult as longword
dim value as word[3]
dim vstring as string[3]

sub procedure GlobInit
    TRISB = 0
    PORTB = 0
    TRISA = 1
    ADCON1 = $4E
    LCD_Out(1, 1, "Temp:")
    LCD_Out(1, 15, "'C")
end sub

     while true
           ADCResult = (ADC_Read(0) * 500) >> 10
           value[0] = ADCResult div 100
           value[1] = (ADCResult div 10) mod 10
           value[2] = ADCResult mod 10
           vstring[0] = value[0] + 48
           vstring[1] = value[1] + 48
           vstring[2] = value[2] + 48
           LCD_Out(1, 10, vstring)

Hex file + Schematic + Code freely available for download:

The code can be freely used and there is no copyright restrictions or anything as such. Only credit the author where necessary.


  1. This comment has been removed by the author.

  2. It is a device which helps to measure the temperature gradient or temperature of human beings by calculating some body temperature.

    Ventilator Machine

  3. Wow its great and nice blog you have posted. Digital Thermometer


  4. hi dear its very nice and very helpful post for those who are new and thinking to start a blog site.Your posts are very helpful and creative clik here and see how to dc 24 volt to ac 220 volt instalation of inverter

  5. Fantastic Post! Lot of information is helpful in some or the other way. Keep thermometer

  6. It's really helpful thanks for sharing. Buy digital thermometer from Accusure

  7. Gud Morning.... Your Blog is Awesome, ​An infrared thermometer is a thermometer which infers temperature from a portion of the thermal radiation sometimes called black-body radiation emitted by the object being measured. Thanks for sharing.....!!!
    Best Infrared Thermometer

  8. can u plese share the schematic diagram