PIC16F877A LM35 Temperature Monitor

Author : Dinesh Kumar Wickramasinghe

Introduction to the Project

Hello Friends, Earlier I wrote a blog post about building a simple temperature monitor with LM35 sensor and Arduino with LCD. This time a similar project with PIC16F877A Microcontroller.

Before we begin, here are some images of the completed project.

I started programming microcontrollers with PIC family microcontrollers. After some time Arduino came to the world and most people started using Arduino. Yes, arduino is easy to learn and use. But I still love PIC family microcontrollers.

If you like to learn more about PIC family microcontrollers, please refer below links. There are some video tutorials created by me a long time back and also a blog post.

Microcontroller Tutorial Videos

Microcontroller Tutorials Blog Post

OK Let’s come back to the topic. This project was built using the LM35 analog linear temperature sensor from Texas Instruments.

If you want to read more technical information about this sensor, here is the datasheet of the sensor.

LM 35 Temperature Sensor Datasheet

The LM35 Temperature Sensor.

Here is the schematic of the project. I simulated this schematic and the code with Proteus and they work fine.

Source Code

Here is the MicroC code for the project.

// LCD module connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;

sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;

char display[16] = "";

void main() {
unsigned int sensorReading;
float voltValue, tempValue;

trisb = 0;
trisa = 0xff;
adcon1 = 0x80;
lcd_out(2,3,"TEMP METER");

  sensorReading = adc_read(0);
  voltValue = sensorReading * 4.88;
  tempValue = voltValue / 10;

  lcd_out(1,1,"Temp : ");

  lcd_chr(1,14,223); //print "°"

You can do modifications and do more experiments. One small remark is always try to buy the original LM35 sensor. Because there are cheap sensors and they will give you inaccurate readings.

Put your questions, comments below. Have a nice day.

Comments Area
Add your questions and comments here. Comments will be published after the admin approval


Similar Projects

Go Top