Alas they are not here are the differncenses (courtesy ChatGPT Pro) We only implemented the 18B20. PR wellcome
-
Family code
- DS18B20 has a family code of
0x28
. - DS18S20 (and the older DS1820) has a family code of
0x10
.
Many 1-Wire libraries check the family code to decide how to interpret the scratchpad data. If you’re using a routine that was written specifically for the DS18B20, it may ignore or misinterpret a0x10
device, giving the wrong reading.
- DS18B20 has a family code of
-
Resolution and scratchpad layout
- DS18B20 supports user-selectable resolution from 9 to 12 bits. Typically, people run it at 12-bit resolution, yielding 0.0625°C increments.
- DS18S20 outputs effectively 9 bits of resolution (0.5°C steps in the basic reading). However, it also uses additional registers (
COUNT_PER_C
,COUNT_REMAIN
) if you want the fractional part (this is the so-called “extended” or “improved” resolution method).
Because of these differences, the scratchpad (the block of bytes you read over 1-Wire) is laid out differently, and the formula for calculating the final temperature is different.
-
Data format & calculation
- DS18B20: The temperature data is in bytes 0 and 1 of the scratchpad, which can be directly interpreted (with some scaling, depending on resolution).
- DS18S20: It always gives a 9-bit value in the main temperature register (bytes 0 and 1), but then you use bytes 6 and 7 (
COUNT_PER_C
andCOUNT_REMAIN
) to get a finer resolution. The standard formula (from the Maxim datasheet) is:
[
T = T_\text{reading} - 0.25 + \frac{\text{COUNT_PER_C} - \text{COUNT_REMAIN}}{\text{COUNT_PER_C}}
]
This differs from how you would interpret DS18B20 data directly.
-
Default resolution
- DS18B20 is often used at 12-bit resolution (0.0625°C).
- DS18S20 is fixed 9-bit for the main measurement (0.5°C). You must do extra math with the count registers to improve the resolution.