digital thermometer using pic microcontroller and MCP9700



In this article you will learn, how to design digital thermometer using pic microcontroller and MCP9700? You will learn how to interface MCP9700 with PIC16F877A microcontroller?  How to measure temperature using MCP9700 low power voltage output temperature sensor. Before reading this article you should have idea of lcd interfacing with pic microcontroller and how to measure analog voltage using pic microcontroller? If you don’t know about them, I recommend you to read followings articles first. After reading following article, you will be able to understand circuit diagram and code of MCP9700 based digital thermometer using pic microcontroller.



MCP9700 temperature sensor

It is voltage output sensor. It is low power and low cost temperature sensor. It converts temperature into voltage. Voltage can be easily measured with the help of microcontroller. Microcontroller reads voltage with the help of analog to digital converter. Measured voltage converted back into temperature using mathematical manipulation in programming. I will discuss it later in programming part of this article. It can give accuracy up to ±4%°C. It can measure temperature from -40°C to +125°C. It consumes a minimum amount of operating current 6μA. It can derive large capacitive loads.

you may also like to read  wirless temperature sensor using gsm 



MCP9700 temperature sensor working

MCP9700 temperature sensor consists of PN junction diode. The main temperature sensing element is PN junction diode. PN junction electrical characteristics contains temperature coefficient which provides change in voltage with change in temperature.  The change in voltage is scaled with change in temperature according to  following step per division:

1°C = 10mV

MCP9700 interfacing with microcontroller

MCP9700 based digital thermometer does not require any external components. It does not require any signal conditioning circuit. It can be directly interfaced with ADC of microcontroller. In MCP9700 1°C = 10.0 mV . General interfacing diagram of MCP9700 is shown below:

MCP9700 interfacing with microcontroller

MCP9700 interfacing with microcontroller

As shown in above figure. MCP9700 comes with three pins package. Three pins are power supply pin, ground pin and output voltage pin.

circuit diagram of MCP9700 interfacing with pic microcontroller

Its interfacing diagram with pic microcontroller is shown below. LCD is interfaced with pic microcontroller to display temperature. PIC16F877A microcontroller measure output voltage of temperature sensor with the help of ADC as shown in figure below:

MCP9700 interfacing with pic microcontroller

MCP9700 interfacing with pic microcontroller

Note: MCP9700 power supply pins are hidden in proteus. By default it is connected with sensor. You should connect 5 volt power supply with temperature sensor.

Code for MCP9700 interfacing with PIC

Code for this project is written using Mikro C pro for pic.

sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

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



void main() {
 unsigned long int Temp;
 unsigned int ADRead;
 unsigned int vDisp[3];
 unsigned char Display[7];
 PORTA = 0;
 TRISA = 0X01;
 PORTB = 0;
 TRISB = 0;
 LCD_Init();
 LCD_Cmd(_LCD_CURSOR_OFF);
 LCD_Cmd(_LCD_CLEAR);
 LCD_Out(1, 1, "Temp:");
 //Display = "+125 'C";
 Display[4] = 39; //'
 Display[5]= 'C';
 ADCON1 = 0x0E;
 ADC_Init();
 while (1){
 ADRead = ADC_Get_Sample(0);
 if (ADRead > 102){// 'If temperature is positive
 Temp = (100 * ( (10 * ADRead) - 1024 ) ) >> 11; //'Get temperature
 Display[0] = '+';
 }
 else{ // 'If temperature is negative
 Temp = ( (1024 - (10 * ADRead) ) * 100 ) >> 11; //'Get temperature
 Display[0] = '-';
 }
 vDisp[0] = Temp / 100;
 vDisp[1] = (Temp / 10) % 10;
 vDisp[2] = Temp % 10;
 Display[1] = vDisp[0] + 48;
 Display[2] = vDisp[1] + 48;
 Display[3] = vDisp[2] + 48;
 LCD_Out(1, 8, Display); // 'Show temperature
 }
}



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 1,395 other subscribers