# Temperature sensor

Discussion in 'Programmer's Corner' started by RRITESH KAKKAR, Mar 21, 2015.

1. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
Hello guys,
I have LM35DZ it has 3 pin working at 5V of micro controller supply inbuilt ADC of 8 bits.
so, I want to convert 8 bits maximum value 0-255 5v, 10mV mean 1*C
please tell algorithm to convert it in 0 to 99*C

thanks

2. ### nerdegutta Moderator

Dec 15, 2009
2,660
919
Hi, I found this on a website, while I was searching for answers:

I found it here.

3. ### GopherT AAC Fanatic!

Nov 23, 2012
7,983
6,786
Option 1
Set the ADC reference voltage to .99 volts. Then you get a full scale from 0 to 0.99 volts = 0 to 255 ADC value.
This leaves messy math to do in the Microcontroller to convert ADC value to degrees.

Option 2
Set reference ADC voltage to 2.55 volts
Your ADC value will be 0 to 255 (1 tick per 10 mV) which corresponds to 1 tick per degree C
Directly send your ADC value to your display. It is not a full 8-bit accuracy but neither is your 2-digit display. I assume 2 digit display because you said 0-99C instead of 0-99.9C.

Cheers.

RRITESH KAKKAR and cmartinez like this.
4. ### John P AAC Fanatic!

Oct 14, 2008
1,748
260
Run the processor on 5.12 Volts, with the power supply used as the reference. Probably the A/D actually has 10 bits of resolution; read it in "right justified" mode and ignore the top 2 bits which will be in another register. You've then got 256 levels of resolution over an input range of 1.28V, which equates to .005V per step. To get 100 levels over a 1V range, all you have to do is divide by 2.

Alternatively, if you don't really need it to be very accurate, just use a 5V supply. It'll only be off by a couple of percent at the high end, and proportionally less at the low end.

RRITESH KAKKAR likes this.

Feb 19, 2010
4,667
745
6. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
Hello,
There is ds18b20 which work in serial data is that fine? than LM35?

7. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
Hello,
The LM35 will require more ADC bits to capture solution is tio have less price micro with DS18b20, is that fine with PIC16F72?

8. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
Hello,
Anyway, I have PIC16f887 which has more than 8 Bits ADC so, could i use it to get all range of temp -40 to 155*C and i listen that hot iron for solder run at 350*C which sensor is taht which can indicated large *C?

9. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
I have more question, how to communicate with DS18B20? what does 1 wire mean?

Feb 10, 2009
217
34
11. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
Which communication to use?
How to send read data some example i use serial to parallel shift registers i can do that!
Thanks

12. ### DumboFixer Active Member

Feb 10, 2009
217
34
1-Wire communication has its own protocol so you will need to use that if you are going to use the DS18B20 temperature sensor.

Did you look at the bottom of the page I gave you the link to ? There are several links to external pages that will provide more info or do you just want us to provide you with the solution ?

13. ### shteii01 AAC Fanatic!

Feb 19, 2010
4,667
745
Why are you buying stuff when you have no clue how it works?

14. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
I am learning it, can we do this with pic micro?

15. ### DumboFixer Active Member

Feb 10, 2009
217
34
Yes, one of my projects uses the same temperature sensor and a Pic Micro

16. ### RRITESH KAKKAR Thread Starter Senior Member

Jun 29, 2010
2,823
91
so, if you dont mind can you teach me?

17. ### jacklai New Member

Mar 26, 2015
7
0
I'm working with DS18B20 & also have the same confuse...