Continue to Site

[Moved] 1-wire protocol {ds18b20 temps. Sensore}

Status
Not open for further replies.

MRBehera

Newbie level 2
[Moved] 1-wire protocol {ds18b20 temp. sensore}

how to convert 12bit digital data from ds18b20 to degree celcius

Re: [Moved] 1-wire protocol {ds18b20 temp. sensore}

By a quick look on datasheet we can note that temperatures above 0oC can be divided by 16, therefore could be something like that:

Code:
 result = (float) temp / 16.0;   //calculation with 0.5 deg C resolution
result = (int) temp / 16  ;   //calculation with 1 degree C resolution

Re: [Moved] 1-wire protocol {ds18b20 temp. sensore}

Hi,

datasheet... always a good idea

****
//calculation with 0.5 deg C resolution
isn´t the resolution 1/16 °?

****
The choice of values in the table is a mystery to me..
Why 0.5°, or 25.0625° ???? Does it make sense?
Why not 0°C, 0.0625°C, 1.0°C (to see the zero point, the resolution in °C and how much LSBs are 1°C...

***

Klaus

Re: [Moved] 1-wire protocol {ds18b20 temp. sensore}

You are absolutelly correct, I made an elementary miscalculation :bang:.

Re: [Moved] 1-wire protocol {ds18b20 temp. sensore}

Hello

@Andre:

No, the temperature calculation is correct as far as I can see.

**
@MRBehera:
I ask myself why you ask about 12 bit. It is more effort to generate the 12 bit from the 16 bits than using 16 bits.
The next question is: What 12 bits do you want? Upper, lower or some inbetween?

Klaus

Status
Not open for further replies.