|TEMPer USB Thermometer|
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.
# cd /opt # ## forked from http://www.manialabs.us/downloads/Temper.py # sudo git clone https://github.com/kiloforce/PyTEMPer # cd PyTEMPer # ## Get PyUSB (if you do not already have installed) # sudo git clone https://github.com/walac/pyusb # sudo ln -s pyusb/usb usb # ## Get sample temperature to verify code is setup correctly # sudo python temper.py 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 sys.path.append('/opt/PyTEMPer') import temper temp = temper.Temper() if not temp.devices: print "Error: not TEMPer devices found!" sys.exit(1) device = temp.devices while True: # get temperature tempc = temp.getTemperature(device) print "Celsius: " + str(tempc) # only check temperatures every 10 seconds time.sleep(10)
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 https://github.com/oeey/lala-pi
More to come... see label: lala-pi