PIC16f877a temperature meter

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
Egor4eva
Posts: 12
Joined: 04 Sep 2016 05:14

PIC16f877a temperature meter

#1 Post by Egor4eva » 07 Sep 2016 00:04

Hi All,

Can someone tell me, I built the temperature unit with pic16f877a
and managed to add a led to flash at half second intervals.
But the temp is reading 120C/000C/45C and anything inbetween
when i check the AN0 it is showing constant 1.15v so i thought
it should be displaying 11.5C on the lcd?

Any ideas as to what could be the problem, I have tyred other
pic's and replaced the lm35 but no difference?

Thanks Michael

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: PIC16f877a temperature meter

#2 Post by lana.arsic » 07 Sep 2016 17:06

Hi Michael,

Please take a look in example from the compiler for LM35,
you can find it in installation folder.

It is written for PIC18F45K22, but it should not be a problem to
change it for PIC16F877A. You may also find this thread useful:

http://forum.mikroe.com/viewtopic.php?f ... 62#p188972

Best regards,
Lana

Egor4eva
Posts: 12
Joined: 04 Sep 2016 05:14

Re: PIC16f877a temperature meter

#3 Post by Egor4eva » 08 Sep 2016 22:03

Thanks for that Lana,

Now my problem is....

I'm trying to display the voltage from lm35 on lcd
do i have to convert it to a string? The way i have done
it so far, works sort of.

if temp<=20c the fan should be off
If Temp >20c it should come on.

But after testing the fan comes on at;
2-6c,8-12c,15-19c,21-25c, 27-31c which is every 4c.
I'm guessing i have missed something.
Here is the program;
*******************************************
do
{
{
{ // Power LED (Running)
PORTD.F0 = 1; // LED on
Delay_ms(500); // Half sec delay
PORTD.F0 = 0; // LED off
Delay_ms(500); // Half sec delay
PORTD.F0 = 1; // LED on
}
}
Lcd_Cmd(_LCD_CLEAR);
Lcd_out(1,1, "Room Temperature");
//Display Actual Temperature
t = ADC_Read(0);
t = t * 0.4887;
a = t%10;
lcd[2] = a + '0';

t = t/10;
a = t%10;
lcd[1] = a + '0';

t = t/10;
a = t%10;
lcd[0] = a + '0';
Lcd_out(2,1,lcd);
Lcd_Chr(2,4,223); // Different LCD displays have different
// char code for degree
strDisplay = (5000*ADC_Read(0)/1024);
// IntToStr((ADC_Read(0)/10), strDisplay);

{ if (strDisplay > 020) //If Temp is greater than 20C, Switch ON Fan
{
Lcd_out(2,9, "Fan=On");
PORTD.F1 = 1; // Fan on
}
else
if (strDisplay < 020) //If Temp is less than 20C, Switch Off Fan
{
Lcd_out(2,9, "Fan=Off");
PORTD.F1 = 0; // Fan off
}
}
Delay_ms(1000);
}while(1);
}
*******************************************************

Regards Michael

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: PIC16f877a temperature meter

#4 Post by lana.arsic » 09 Sep 2016 18:37

Hi Michael,

Yes, in order to display data on LCD, you should convert it into string.

Please take a look in the thread from the previous answer,
it is very similar to your code.

Best regards,
Lana

Post Reply

Return to “User Projects”