The ds18b20 reports temperature in sixteenths of a degree; however, the w1_therm driver reports temperature in millidegrees, as a truncated integer. It takes half-millidegrees to accurately represent every sixteenth of a deg, so how do you get full resolution from the sensor?

For example, here is an emulated ds18b20 with temperature set to 23.0625 degC:

pi@xenon:~$ cat /sys/bus/w1/devices/28-00da18b20000/w1_slave
71 01 4b 46 7f ff 00 10 4e : crc=4e YES
71 01 4b 46 7f ff 00 10 4e t=23062

The driver reports 23.062 deg, so it's off by 0.005 deg. Of course, that's pretty small, but if you're looking for small temperature fluctuations you'll miss it.

1 Answer 1


The first two bytes returned by the driver (71 01) are the actual reading from the sensor. They're in LSB order, so the reading is 0x171, which is 369 sixteenths of a degree, or 23.0625 deg C.

Another way to look at it is to enumerate the decimal values of all 16 sixteenths of a degree (see below). We then observe that any millidegree reading that ends in a 2 or a 7, should really have a 5 after it. The rest are zero.

const char *frac[ ] =
  "0000", "0625", "1250", "1875",
  "2500", "3125", "3750", "4375",
  "5000", "5625", "6250", "6875",
  "7500", "8125", "8750", "9375"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.