NOTE: This is an archive of my old blog. Go to for my current website.

USBTemp: Continuous Temperature Monitoring 4

Posted by md on January 03, 2009

Kaiserlautern, Germany

Its this time of the year: I have time for a small project. This year I have built an USB-powered thermometer. Basically, you just plug it into an USB port. Then you can query the module via a small commandline tool. I wanted to be able to use my NSLU for creating temperature graphs. The image above is the temperature in Kaiserslautern, Germany – updated every 15 minutes.

The code and the schematic are open-source, licensed under the terms of the GPL. The code is available at the Mikrowerk code repository:

USBTemp start page at Mikrowerk

On these pages you can read more about the actual device and the software. This post describes how to use USBtemp to record temperature information continuously. Im am using my trusty NSLU running Debian as a host – any other Linux/Mac machine will work the same way. The NSLU is a NAS device. It is small and doesn’t consume too much power (about 20 W).

My NSLU home server

The USBTemp device is attached to the second USB port of the NSLU. Using the host software I can easily query the sensors of the device:

$ ./usbtemp sensors
2 sensor(s) found, querying
sensor 0: ID 9F17A5010800 type: (DS18S20)
sensor 1: ID B46865010800 type: (DS18S20)

The first sensor is soldered on the USBTemp board itself – it monitors the temperature in my office. The second sensor is attached to my balcony:

Outside sensor

Actually the sensor is hidden in the white box to protect it from rain. The sensor is the second in the list above, so I can query it using the command

/usbtemp temp B46865010800
searching sensor with id B46865010800 - using sensor handle 1
reading sensor 1 (°C): +1.1875

In combination with RRDTool it is easy to create timeline graphs. The USBTemp package contains scripts that help you to do this. First, you have to edit the settings in etc/

# This file contains the configuration. Adjust it to meet your needs.

Then you must define the USB_HOME environment variable to point to your USBTemp installation directory, e.g. (for bash)

export USBTEMP_HOME=/home/md/Projects/usbtemp/trunk

As soon as you like the settings you can use bin/ to create the RRDTool database. Please review the script if you want to adjust some settings. I use the cron daemon to query the sensors periodically (every five minutes) and update the plots every 15 minutes. This is the crontab:

# Linux cron can handle environment variables
# set usbtemp path

# m h dom mon dow command
*/5 * * * * $USBTEMP_HOME/bin/ > /dev/null 2>&1
*/15 * * * * $USBTEMP_HOME/bin/ > /dev/null 2>&1

I use another little script to upload the graphs of the external sensor to my webserver. For my personal use, I also generate graphs of my office temperature – but I don’t publish these :-)

Here are the currently available temperature plots.


Use this link to trackback from your own site.


Leave a response

  1. nokka Fri, 31 Jul 2009 22:34:00 UTC

    where can i get the hole pieces listed on the USBTempHardware wiki page?
    i tried it with conrad & reichelt but i couldn’t find all of the needed parts with the given value/device description.

  2. md Sat, 01 Aug 2009 07:07:41 UTC

    Hi nokka,

    actually these parts should be rather easy to get. I purchased them all at Reichelt. Is there a specific part you have trouble with?


  3. nokka Sat, 01 Aug 2009 17:34:57 UTC

    oh … hm, could you post the Reichelt partnumbers?

  4. md Sun, 02 Aug 2009 09:54:12 UTC

    Hi nokka,

    no, I will not post order numbers – it takes some time to search for them. As I said, all parts are pretty standard and you should not have any trouble finding them.