Converting decimal number to 16 bit temperature binary

I have a question about conversion.
In a document about DS18B20 temperature sensor i need to convert 18.25C to binary.
Can someone explain how to do it.
This is the examples i have

I tried looking for answers on the internet but i can’t find anything similar.

>Solution :

It looks like the binary value is the decimal temperature in increments of 0.0635 degrees (0.5 = 0.0625*8 = 0008h, 10.125 = 0.0625*162 = 00A2h)

so the conversion for 18.25 would be

18.25/0.0625 = 292 = 0124h = 0000 0001 0010 0010

Or, since 1/0.0625 = 16, you could convert it by multiplying by 16:

18.25 * 16 = 292 = 0124h = 0000 0001 0010 0010

Leave a Reply