Sunday, December 22, 2013

TEMPer USB Thermometer on Raspberry Pi

TEMPer USB Thermometer
For a fairly cheap solution, nothing quite compares in price and convenience to the TEMPer USB Thermometer.  Due to their low price point, I have used several of these as secondary temperature check points in a server rack before.  They can be picked up for about $15 to $22 on Amazon, or cheaper on eBay.  The TEMPer is not as accurate, or reliable, as something like the Temperature@lert, which runs for about $130, but for general temperature estimation they work sufficient for my needs.

I found the easiest way to use the TEMPer with Python is to install the pyusb library and a simple temper Python class written by Bill Mania.  There were a few small issues that I ran into with the original code, so I forked the code on Github and posted the changes as the PyTEMPer repo seen below.

First let's make sure Linux can see your TEMPer device. We are looking for devices that have the VendorID of 1130 and DeviceID of 660c.
# lsusb | grep 1130:660c
Bus 004 Device 002: ID 1130:660c Tenx Technology, Inc. Foot Pedal/Thermometer

If your device is not found, the PyTEMPer script will not work with your device.

PyTEMPer Installation:
# cd /opt

# ## forked from
# sudo git clone
# cd PyTEMPer

# ## Get PyUSB (if you do not already have installed)
# sudo git clone
# sudo ln -s pyusb/usb usb

# ## Get sample temperature to verify code is setup correctly
# sudo python
0:2, 22.56 Celsius / 72.61 Fahrenheit

Now that we have the PyTEMPer class working, we can build the following Python script to get the current temperature repeatedly:
import sys
import time

import temper
temp = temper.Temper()

if not temp.devices:
    print "Error: not TEMPer devices found!"
device = temp.devices[0]

while True:
    # get temperature
    tempc = temp.getTemperature(device)
    print "Celsius: " + str(tempc)

    # only check temperatures every 10 seconds

In the final lala-pi TEMPer code, I included code to demonize the process, syslog for logging, and ZeroMQ messaging.  If you are interested in the full lala-pi source code (still a work in progress), this can be found in the GitHub lala-pi repo on Bitbucket.
# git clone

More to come...   see label: lala-pi


Lorenzo said...

Hi! Any idea on the accuracy of this device?

Kenneth Burgener said...

RE: "Any idea on the accuracy of this device?"

Not too accurate. Good enough to tell that temperatures are rising and falling. From what I have read, under ideal conditions it appears that it can detect changes in temperature to about .5°C (~1°F). The default temperature output also needs so calibration (shifting to correct temperature).

Anonymous said...

Hi, really new with my raspberry pi and to coding in general. I've followed the instructions to a T, but im not getting a sample temp. I looked in the /opt file and everythings there including the python, but when i run the sudo python string nothing happens. And if i try and run it straight from the terminal with no directions it says no such file or directory. Thanks for your time

Kenneth Burgener said...

Please check to see if your Raspberry Pi is even seeing the TEMPer device:

# lsusb | grep 1130:660c
Bus 004 Device 002: ID 1130:660c Tenx Technology, Inc. Foot Pedal/Thermometer

Mark Ziemann said...

Thanks for this really helpful post! Finally got my Temper USB (Tenx type) to work :)

jnihil said...

Thanks for the tip, my Tenx TEMPer is also working well.