Summary of Interfacing Temperature Sensor with Microchip PIC16F876A
This tutorial explains interfacing an LM35 analog temperature sensor to a PIC16F876A microcontroller using its 10-bit ADC and displaying temperature on a 2x16 HD44780-based LCD. The ADC reading is converted to millivolts, then to degrees Celsius using LM35’s 10 mV/°C transfer function. The project uses MikroC for programming and includes optional control of external devices based on temperature.
Parts used in the Interfacing Temperature Sensor with Microchip PIC16F876A:
- PIC16F876A microcontroller (28 PDIP)
- LM35 analog temperature sensor
- 2x16 LCD module (HD44780 controller)
- Power supply (5V reference)
- Connecting wires and PCB or breadboard
- MikroC compiler for PIC programming
The tutorial aims at providing the necessary information for interfacing an analog type temperature sensor with a Microchip PIC Microcontroller. PIC (Peripheral Interface Controllers) was introduced in 1985. The PIC16F876A has 8K of Flash Program Memory, 368 bytes of Data Memory (RAM) and many other attractive features. Some features are ADC, USART, and 14 Interrupts all in 28 PDIP Package.

It is possible to switch On/Off an external application based on temperature value.
The LCD is based on HD44780 controller. The programming has been done using the MikroC compiler from Mikroelektronika (www.mikroe.com). The demo version has a 2KB Hex Output limit, fortunately it is more than enough for our requirement.
Program
int t1,temp;
char *text[6];
void main()
{adcon1=14;
lcd_init(&portb);
lcd_out(1,1,”Temperature”);
lcd_out(2,8,”‘C”);
while(1)
{t1=adc_read(0);
//temp=0.245*t1; // For TMP37 Sensor 20mv/’c
temp=0.245*t1*2; // For Lm35 Sensor 10mv/’c
inttostr(temp,text);
lcd_cmd(lcd_cursor_off);
lcd_out(2,1,text);
delay_ms(100);}}

For more detail: Interfacing Temperature Sensor with Microchip PIC16F876A
- What microcontroller is used in the project?
The PIC16F876A microcontroller is used. - Which temperature sensor is interfaced?
The LM35 analog temperature sensor is used. - How is the LM35 output measured?
The LM35 analog output is digitized using the PIC16F876A on-chip 10-bit ADC. - How is temperature calculated from the ADC reading?
The ADC value is converted to millivolts (using Vref and 10-bit resolution) and then divided by 10 mV per degree Celsius for LM35. - What display is used to show the temperature?
A 2x16 LCD based on the HD44780 controller is used to display temperature. - Which compiler is used for programming the PIC?
The MikroC compiler from Mikroelektronika is used. - Can the project control external devices based on temperature?
Yes, it is possible to switch on/off an external application based on the temperature value. - What Vref value is considered in the tutorial calculations?
The tutorial mentions an internal Vref of 4096 mV but uses 5000 mV for ease of calculation.