Welcome to my website, about work, life, and other stuff.

From Bjoern Hassler

Jump to: navigation, search
Home

Welcome to my website, about work, life, and other stuff.

It's a personal website, so while some of the stuff here related to my work, much of it does not. On the whole, you'll find things about education, open access, digital technology and ICT, as well as about media, maths and science, across primary, secondary and higher education, both in European, African, and global contexts. If you dig for long enough, you'll also find things about music, languages, and archaeology.

You can contact me by email: bjoern (followed by AT sign) sciencemedianetwork (then a DOT) org

Note that this website is built on MediaWiki, and if you poke around for long enough, you'll also find the content is hosted on my wiki, which is a bit more experimental (and rough and ready) than the bits of the site that are my "official" website. The wiki links are marked with a little globe like this:.

 


B's blog, most recent: 20141113 measuring below zero temperatures with DS18B20

Measuring below zero temperatures with DS18B20

Measuring below zero temperatures with the DS18B20 doesn't seem to be widely discussed in step-by-step documents explaining how to use this sensor with Raspberry Pi (see e.g. [1], [2] and many more documents like that).

The issue is that the "w1_slave" file doesn't report the correct temperature for below zero temperatures in the "t=..." entry. The w1_slave file looks something like this:

AA BB CC DD EE FF 00 11 : crc=... YES
AA BB CC DD EE FF 00 11 : t=xxxxx

For below zero temperatures, the t=xxxxx entry is not correct. What I haven't seen discussed elsewhere (though it must be discussed somewhere), is that the first two bytes ("AA BB") are the temperature in hexadecimal.

The most significant bytes are BB, so the full temperature in hexadecimal (for above zero) is

BBAA

Actually, it's

BBA.A

i.e. BBAA is the temperature in 16th of degrees, and BBA.A is the actual temperature. For above zero temperatures, if you conver this to decimal, you'd get the same as the t=xxxxx above (which corresponds to xx.xxx degrees celsius).

For below zero temperatures, you need to decode BBAA, and determine the sign. I'll post a recipe, but the datasheet will tell you:

TEMPERATURE (°C), DIGITAL OUTPUT (BINARY), DIGITAL OUTPUT (HEX)
+125     0000 0111 1101 0000 07D0h 
+85*     0000 0101 0101 0000 0550h 
+25.0625 0000 0001 1001 0001 0191h 
+10.125  0000 0000 1010 0010 00A2h 
+0.5     0000 0000 0000 1000 0008h 
0        0000 0000 0000 0000 0000h 
-0.5     1111 1111 1111 1000 FFF8h
-10.125  1111 1111 0101 1110 FF5Eh
-25.0625 1111 1110 0110 1111 FE6Fh
-55      1111 1100 1001 0000 FC90h

(see datasheet). As you can see, it's the 11th bit (and higher) that determines the sign. For below zero temperatures, you need to take the two complement as well (and add 1/16th of a degree, i.e. add 1).

Also see http://www.raspberrypi.org/forums/viewtopic.php?f=32&t=88149

Leave a comment | Back to blog Share on Twitter Share on Facebook

Featured YouTube video:
Shuttleworth Fellowship Application