Table of Contents

2011.06.03 - temperature measurement

today i've built my first digital thermometer connected to linux. it is based on the ds18b20 IC – digital thermometer connected via 1-Wire communication bus. it appears that it can be easily connected to RS232 using ds9097 adapter. it is supported by digitemp out of the box.

hardware

since RS232 to 1-Wire would require voltage converter (for example max232) and then some uC to translate between protocols it is best to use well checked ds9097 adapter with above mentioned digitemp package. note that is you're debian or ubuntu user you have this package already available in your distro's repos (apt-get install digitemp).

here is the electrical view. notice that rs232 is regular 9-pin connector, mail-sided on the computer (i.e. schematic shows how it should look, if you'd solder straight to the PC's mail connector).

ds1820 connection via ds9097 adapter (original image taken from http://mod-planet.com/modules/subjects/pages/termometr/zdjecie01.jpg)

notice that you can also connect multiple devices to this bus without need of changing anything. cables are said to work for up to 100 meters1).

software

using the digitemp software is a bit tricky at first so i'll spear you searching and give ready-to-go solution. first thing is to determine serial port to use. typically this is /dev/ttyS0 is you're using raw RS232. in my case i used USB to RS232 adapter, thus my device was /dev/ttyUSB0. first thing to do is check if the software sees the device(s) connected:

digitemp_DS9097 -s /dev/ttyUSB0 -q -w

at this moment you should see your device(s) list. now comes the tricky part – save this list along with other configurations to file:

digitemp_DS9097 -s /dev/ttyUSB0 -q -i

now file ~/.digitemprc has been generated for you. from now on you can query all of the sensors by simply typing:

digitemp_DS9097 -a

notice that you not need device names any more!

as you can see the tool is made the-unix-way, so it allows easy integration with other scripts and data collection mechanisms. example on-screen monitoring can just run forever displaying measurements every 2 seconds:

digitemp_DS9097 -a -q -n 0 -d 2

see the command's manual for more details.

final notes

looks cool for me. now i think about spreading few such a sensors through my home to monitor temperature in key points (server's “closet”, room, outdoors, and so on…). integration with data visualization would be nice too. i already use ganglia for load and PC's temperatures monitoring. why not extend it to house temperatures as well.

recently at my work i've wrote pluin for nagios - API's nice. can be an option as well, though ganglia is probably more straight forward solution.

1)
i haven't checked it yet.