Sure Gordon...it is possible to make a lib to handle both DS1820 and DS18B20!
The only difference (as @tickTock correctly sad) is the resolution:
DS1820 has fixed 9bit resolution (0,5°C per bit);
DS18B20 has a register (Byte 4 of the scratchpad) that permits to choose the resolution( 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively);
What i've done in the previous post, was to raise the fixed 9 bit resolution by using some additional register value in the scratchpad.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sure Gordon...it is possible to make a lib to handle both DS1820 and DS18B20!
The only difference (as @tickTock correctly sad) is the resolution:
What i've done in the previous post, was to raise the fixed 9 bit resolution by using some additional register value in the scratchpad.
In a nutshell for:
Note: is it possible that formulas above doesn't work for temp below zero....in that case you have to play with bits (2 complements...and so on)
...finally reading the LSB of 64bit ROM you can understand if you are using either the DS1820 sensor (0x10) or DS18B20 (0x28) one.