top of page

Serial communication display Temperature using LM35 Interface with PIC16F877A

By Bernice Zuiya

Introduction

                In this project I would like to show how you can monitor the temperature using a desktop application written in visual basic connected with a micro-controller PIC16F877A through a serial communication. 

LM35 Sensor

Working

              

              If you remember our project LM35 Digital thermometer , you may probably find that this simply an extension or modification of that. if you are using our board then you will simply need the LM35 sensor and some wires to establish the connections between the micro-controller and the sensor. but if you want to build one like this you need a USB to Serial adapter to interface the circuit with you desktop application or some other device using the serial communication interface, OSat v6.10 has an inbuilt USB to Serial converter so you will not worry about, what you need is connect you sensor to your board then using your USB cable connect the board to your computer.

 Steps:

1. LM35 sensor gives an analog signal at the output proportionally to the temperature

2. Using ADC converter module of our PIC16F877A MCU we converter the analog quantities at the output of the sensor into DC values

3. we apply the following formula to find the corresponding temperature in degree Celsius as shown below:

    

                      Formula: dc_v = ((4.9999 * adc)/1024)*100;  // temperature

: where > 4.999 is the voltage measured between the two pins (VSS and GND) of our controller in your case it maybe 4.53 you just have to check !!

            > adc represent the DC value converted from AC signal

            > 1024 this number is used in such away our PIC16F877A has a resolution of 2^10 which means 1024 samples corresponding to their voltages

            > finally is 100 as we already know that 10mvolt change at the output pin of the sensor correspond to 1 degree Celsius the change.

If you have respected everything then Download our software OSat Serial S. for free

Circuit Diagram

  • a resistor of value 4k7 ohm is connected in series with +5 volt and the reset pin (1st pin)

  • Q1 is the crystal oscillator in this case its frequency oscillation is 20 MHz.

  • supply: the circuit is connected with a voltage maximum equal 5 volt

  • C1 & C2 are of 22pF.

Code:

Download the full project here

unsigned int adc;
double dc_v;
int valve;
char temp[7];
void main()
{
   UART1_Init(9615);                  // baudrate = 9615
   delay_ms(30);                      // 30 msecondes delay
   while(1){                          // infinite while loop
   adc = adc_read(0);                 // read analog value from RA0 of your chip
   dc_v = ((4.9999 * adc)/1024)*100;  // temperature
   valve = dc_v;
   IntToStr(valve,temp);              // convert
   UART1_Write_Text(temp);            // Write through serial port
   UART1_Write_Text( ".");            // The dot show the end of charaters
   delay_ms(1000);
    }
}

Video:

I decided to record my screen when testing my project with Proteus simulator. Watch this video from youtube

bottom of page