How come temperature from LM35 is different from room temperature?

Status
Not open for further replies.

Happy3

New Member
Hello, there. I am currently doing the Cytron PR11 Temperature Control using LM35. Unfortunately, the temperature display on the LCD are 5 degree Celsius. May I know whether the problems come from the programming itself?
 

Attachments

  • ask in forum.txt
    6.2 KB · Views: 228
Measure the output voltage of the LM35 with a voltmeter. It measures the temperature as 10mV per degree C so it's output should be 250mV for a room temperature of 25C, for example. If that voltage is ok, then you have a programming problem.
 
Your code is just displaying the ADC value! You need to convert it to a temperature. Assuming a 5V reference, try temp=result*5/1024 to get the temperature * 100.

Mike.
 
Just change my coding to this one? while the rest remain the same? I had tried it, unfortunately my LCD display 0.1 degree Celsius at room temperature @@

unsigned short read_temp(void)
{
unsigned short temp;
temp=result*5/1024;
return temp;

}
 
izzit just change this part ?
unsigned short read_temp(void)
{
unsigned short temp;
temp=result*5/1024;
return temp;

}
 
If you want to add Fahrenheit temperature indication just apply this formula:

DegF=(DegC/5*9)+32

Boncuk
 
If you want to add Fahrenheit temperature indication just apply this formula:

DegF=(DegC/5*9)+32
At first glance I thought that was incorrect, but it's not. I'm just used to seeing it as DegC * (9/5) + 32.
 
Last edited:
Always do multiply before divide in case they're using integer maths. So, DegF=(DegC*9/5)+32

Mike.
 
My math teacher taught us to keep the magnitude of numeric values as low as possible to avoid errors and enabling to calculate mentally.

So division comes before multiplication.

However, most important is the final result.

Cheers

Boncuk
 
I have experience averaging too much giving incorrect results.I usually go for arrays like 8,16,32 etc....... so the division will be much faster.
 
If you're using integer maths to convert 24C to 75F then

24/5*9+32=68

24*9/5+32=75

So, when working in assembly, do multiply first.

Edit, Yes, I know, I did pick the worst case.

Mike.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…