Temperature sensor using PIC16F877A microcontroller

Components:

There are many temperature sensors available in market. But LM35 temperature sensor is used in this project. It is cheapest in price and one can easily find it in market. There are many other advantages of LM35 like:




  • It is more efficient than thermistor
  • It is made up of integrated circuit hence no chance of damaging to internal circuitry.
  • It draws current only in micro Amperes.

Only 5 volt power supply is required for LM35 and there is no need of extra circuitry to operate it. PIC16F877A microcontroller is used to read temperature value. 16X2 LCD is used to display temperature value on LCD. Code of this project written in Mikro C compiler.

Implementation:

LM35 temperature sensor converts temperature into its proportional analog voltage value. LM35 is three terminal device.Pin number one and three are for 5-volt voltage supply. Pin two is analog voltage output with respect to temperature value.Relation between measured temperature and analog output voltage is:

                                                              1oC = 10m volt                  

Hence for every 1 degree increase in temperature there will be a increment of 10m volt in output voltage of LM35 sensor. PIC16F877A microcontroller is used to measure analog voltage value.  PIC16F877A  microcontroller built in ADC (analog to digital converter) is used to measure analog voltage.  PIC16F877A PORTA have seven built in ADC channels. So one can interface up to seven sensors with this microcontroller very easily.I will post a project on green house system.In green house system project I have used four ADC channels to measure temperature , light, humidity and moisture. Coming back to our digital thermometer, ADC has been used to read analog voltage. After reading ADC value, using voltage and temperature relationship voltage is converted back into temperature. A conversion factor is used to convert voltage back into temperature. All these conversion has been done through programming. LCD is connected to PORTB of  PIC16F877A microcontroller. I will discuss it in programming part. LCD is used to display temperature value.

Circuit diagram:

Proteus is used for simulation. Following is a circuit diagram of Digital temperature sensor:




temperature sensor

temperature sensor circuit diagram

As shown in above figure both temperature sensor and LCD is displaying same values of temperature. To ensure protection of LM35 and microcontroller you can connect 80k ohm resistor parallel to output of temperature sensor.

NOTE: Before making this project , I recommend you should learn about LCD interfacing with microcontroller especially hardware part. because I have seen many students struggling with LCD display.

CODE:

In programming part conversion factor is used to convert voltage back into temperature.The conversion factor is:

1 volt = 100 degree

temp   = ( Output voltage * 100 oC/V )

Code is written in MIKRO C compiler.

//************************* LCD module connections****************************************
//********************** written by Bilalmalikuet@gmail.com**********************************
sbit LCD_D7 at RB2_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_RS at RB7_bit;

sbit LCD_D7_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_RS_Direction at TRISB7_bit;
//************************temperature variables****************
int temp;
char temper[7];
//**************************************************************

void READ_temp(void)
{
temp = ADC_Read(0);
temp = temp * 5/1023;                                                                                                                                                                         temp = temp * 100;

}
void data_converstion(void)
{

inttostr(temp,temper);
}
void display1(void)
{
lcd_out(1,1,"TEMPERATURE=");
lcd_out(1,13, Ltrim(temper));
Lcd_Chr_Cp(0xdf);
Lcd_Chr_Cp('C');
Lcd_Chr_Cp(' ');

}

void main()
{
ADC_Init();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
lcd_cmd(_LCD_CURSOR_OFF);
lcd_out(1,4,"DIGITAL TEMPERATURE");
lcd_out(2,6,"SENSOR");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

while(1)
{

READ_temp();
data_converstion();
display1();
}
}

If you want complete simulation and hex file of this project.Comment on this post.Also comment your issue I will love to reply to your comments.To download circuit diagram and hex file of digital temperature sensor comment on following link

Temperature sensor using pic microcontroller

Keep visiting my blog for more projects.

78 Comments

  1. Nndonde August 11, 2014
    • BILAL Malik August 11, 2014
      • shaheen April 11, 2016
      • prosper February 5, 2017
    • BILAL Malik October 9, 2014
  2. microP October 6, 2014
    • amir October 9, 2014
      • BILAL Malik October 9, 2014
        • amir October 10, 2014
          • BILAL Malik October 10, 2014
      • Venkat Suraj K February 13, 2016
  3. tarik October 11, 2014
  4. siva November 18, 2014
  5. naqash awan December 17, 2014
  6. najib December 21, 2014
  7. Abi January 31, 2015
  8. kira February 12, 2015
  9. Sam February 15, 2015
    • BILAL Malik February 15, 2015
      • Sam February 16, 2015
  10. rahul jkb February 16, 2015
  11. ashutosh February 18, 2015
    • BILAL Malik February 18, 2015
  12. Sam April 13, 2015
  13. Nan April 25, 2015
  14. Nan April 25, 2015
  15. Bentum April 30, 2015
    • BILAL Malik May 12, 2015
  16. Raymond Michael June 9, 2015
  17. hailegebrel nigu June 14, 2015
  18. sujit September 23, 2015
  19. Zero Coder January 27, 2016
    • Zero Coder January 27, 2016
  20. Miguel March 14, 2016
  21. IMRAN March 23, 2016
  22. Bernice March 23, 2016
    • BILAL Malik March 23, 2016
    • BILAL Malik March 23, 2016
  23. Shri March 25, 2016
    • Deyan March 30, 2016
      • Shrikant M March 31, 2016
  24. Srideep April 6, 2016
  25. ali May 25, 2016
  26. Francisco Morales June 8, 2016
  27. cauchy June 21, 2016
  28. Muhammad Nisar June 24, 2016
  29. Bianca Mendoza June 30, 2016
  30. chiranth July 18, 2016
  31. Aswin August 18, 2016
  32. Mohamed Chehidi October 21, 2016
  33. trungquan October 28, 2016
  34. sintu November 20, 2016
  35. Ines November 23, 2016
  36. Ines November 23, 2016
  37. Drogo December 10, 2016
  38. hamza December 25, 2016
  39. hamza saleem December 28, 2016
  40. CARMELO MAXIMILIANO, OBIANG EYANG January 18, 2017
  41. swetha January 18, 2017
  42. Richard January 31, 2017
  43. Zahid February 2, 2017
  44. dan February 3, 2017
  45. muhammad umar February 13, 2017
  46. kiru February 27, 2017
  47. Sungu malick February 27, 2017
  48. gajanan nalbalwar March 4, 2017
  49. Meshack March 5, 2017
  50. Namrata March 5, 2017
  51. Hammed March 6, 2017
  52. azimah March 8, 2017
  53. Kasun Will April 1, 2017
  54. NIYA SHARMA April 6, 2017
  55. Kojo Mbia April 7, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 972 other subscribers