ds1820 temp sensor
Moderator: Benj
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
ds1820 temp sensor
hi all i am interested in making a basic program for a DS1820 temp sensor and also to gain some understanding of writing code for them, and have downloaded the one wire example from flowcode, the chip used is a pic16f877, i have altered the code so i can use a 16f88, i connected the data pin to RA0/AN0 but all i got on the lcd screen was no device found as per the program, the other 2 pins of the sensor were connected to +/- respectively, is it possible to do what i am intending ie substituting the chip for the 16f88 also does the data or d/q pin need to go to a ccp1 pin which i believe is capture/compare /pwm ? any input would be appreciated
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: ds1820 temp sensor
Hi
Please try this code attached here.
Edit: Did you put 4.7K pull-up resistor from data pin to Vcc=+5V? If not please do that as without that sensor will not work.
Please try this code attached here.
Edit: Did you put 4.7K pull-up resistor from data pin to Vcc=+5V? If not please do that as without that sensor will not work.
- Attachments
-
- 1. Single OneWire device.fcf
- (12 KiB) Downloaded 376 times
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
hi enamul in your flowcode i have noticed you are using the 877 im after using the 16f88
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: ds1820 temp sensor
Here the code is in PIC16f88..Data in RA0 and remember to pull-up by 4.7K
- Attachments
-
- 1. Single OneWire device.fcf
- (8 KiB) Downloaded 320 times
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
hi enamul i have tried your flowcode (compiled to hex) and i am using the 4.7K resistor but all i get on the lcd is crc error and if the sensor is not connected i get no device found,as per program canyou tell me what crc means please
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: ds1820 temp sensor
If you are having CRC error..this code will work for your case..please check in the properties of the one wire component whether the CRC check is enabled or not..I have checked that if not please click that enable.
- Attachments
-
- 1. Single OneWire device.fcf
- (8 KiB) Downloaded 348 times
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
ive compiled and run with the crc ticked and unticked but it makes no difference wondering if my ds1820 is defective
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
just a thought but would oscillator settings affect this i am using the internal oscillator at 8Mhz
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
ive tried with an external 20Mhz and i am now getting a reading but it shows 2.6 C if i touch the sensor i can get it to rise to around 3.8 C how can i get it to show room temp
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: ds1820 temp sensor
Can you try this please as your system improves?
- Attachments
-
- 1. Single OneWire device.fcf
- (8 KiB) Downloaded 353 times
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact:
Re: ds1820 temp sensor
i am now getting readings of 20C rising to over 30C if sensor touched so now close to actual room temp if not actual, can you explain the following code so i can see what prompted you to change the calculation to the values shown please
Temp2 = (( Temp MOD 2 ) * 10)/2
Temp = Temp / 2
Temp2 = (( Temp MOD 2 ) * 10)/2
Temp = Temp / 2
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: ds1820 temp sensor
In the datasheet I have seen that the value we read has a relation with temperature is following:
Temp = Data/2
So like for 35 Data temp should be 17.5
I have divided the data by 2 to get integer part of temperature. Decimal point can get by remainder. (Data mod 2)=1 so multiply by 10 will produce 10 so divide by 2 will produce 5. Which results to 17.5
Temp = Data/2
So like for 35 Data temp should be 17.5
I have divided the data by 2 to get integer part of temperature. Decimal point can get by remainder. (Data mod 2)=1 so multiply by 10 will produce 10 so divide by 2 will produce 5. Which results to 17.5
-
- Posts: 392
- Joined: Wed Jan 05, 2011 11:24 am
- Has thanked: 101 times
- Been thanked: 24 times
- Contact: