TEMPer1 temperature sensor in Linux

Posted by – 2012/01/15

Yey! Just got my PCSensor TEMPer1 USB thermometer logging in Linux. It automatically detects and does expose USB HID profiles, but there’s no way to access the data by holding down the CAPS key like it says in the docs.

Thankfully, a search for the device ID (0c45:7401 Microdia) finds ruby bindings for Temper.c by Michitaka Ohno, which conveniently includes the reverse-engineered USB protocol. So I’ve forked this on GitHub, removed the Ruby bits, edited the unit test wrapped it up in a little script that logs the time and temperature to a CSV file. It currently only supports one device, which will change if I ever get another one of these devices (spoiler: I probably will)

To start logging your TEMPer1′s data in Ubuntu just

 # install dependencies
 $ sudo apt-get install git build-essential libusb-0.1.4 libusb-0.1.4-dev
 # clone the logger
 $ git clone git://github.com/bitplane/temper.git
 # build it
 $ cd temper
 $ make clean
 $ make
 # start logging!
 $ sudo ./log.sh > temperature.log

Now I’m just waiting for my USB clip-on-mic to arrive. Once it does I can log the bubbles from the airlock on my beverages along with the temperature, and make some pretty graphs.

Watch this space!

9 Comments on TEMPer1 temperature sensor in Linux

Respond | Trackback

  1. [...] all that it appears to work okay. Here’s a graph that shows it in action along with my thermometer, the dip is caused by me dismantling it while taking the photos [...]

  2. Thomas says:


    this helped me a lot!!! Thank you!

  3. Andreas says:

    works like charming, thank you. Any hints how to handle two devices? I want to log flow/return temperatures of my boiler.

    Kind Regards

  4. Gaz Davidson says:

    @Andreas, those temper devices don’t have any sort of unique ID, so the order may switch around when you reboot your machine.

    If you can be sure of the order it shouldn’t be hard to just choose the second one instead of the first, hack “find_lvr_winusb” and make it choose the second device found instead of the first, then just run two binaries.

    If you do it properly and refactor it to allow more than one device at a time, please send me a pull request and I’ll merge.

  5. Gary says:

    First, thanks, this code / procedure worked fine. Question: I need a longer wire on one of them so I can put it outside my house (in a place where rain won’t get at it). Adding an extension USB cord should be fine provided I keep it less than 5m long?

  6. Gaz Davidson says:

    Yep should do, my USB extension cable is about 3 metres. If it doesn’t work then you may need to stick a powered hub in the middle, which would suck.

  7. Alex Atkin says:

    Just compiled this on Fedora 18, works like a charm.

    The only thing is every so often I get “libusbx: error [op_open] open failed, code -1 errno 19″ which is annoying.

    I presume this is coming from the library itself and can suppressed by running the command as “./temper 2> /dev/null”.

    I was wondering, when it has problems probing the sensors, is there a good reason you chose to wait 3 seconds before trying again or could that be reduced?

    I am wanting to use this for a near real-time display of the temperature outside so would like to reduce the delay as much as possible.

  8. Pongamorn says:

    thank you, you saves my day

  9. dr memals says:

    Love the way your code just works!
    Had a small issue that plugging it directly into my Raspberry Pi caused it to show the temp + 10 degrees. The Raspberry Pi was not over heating but was running warm, a small 50cm USB cable fixed that.
    I graphed the results with gnuplot.

    set term png size 1200,800 enhanced font ‘/usr/share/fonts/liberation-fonts/LiberationSans-Regular.ttf’ 12
    set xdata time
    set timefmt “%d-%b-%Y %H:%M”
    set output “/home/USER/temp/room_temp.png”
    set grid
    set xlabel “Time”
    set ylabel “Temp”
    set title “Room Temp”
    set key left box
    set datafile separator “,”
    plot “MYCSVFILE.csv” using 1:2 title “Office Temp”