Education, Open Access, Digital Technology, Media, Maths and Science
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:.
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. ,
 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
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:
(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).