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.
PyTEMPer Installation:
# 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[0] 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
Hi! Any idea on the accuracy of this device?
ReplyDeleteThanks
RE: "Any idea on the accuracy of this device?"
ReplyDeleteNot 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).
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 temper.py, but when i run the sudo python temper.py 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
ReplyDeletePlease check to see if your Raspberry Pi is even seeing the TEMPer device:
ReplyDeleteExample:
---
# lsusb | grep 1130:660c
Bus 004 Device 002: ID 1130:660c Tenx Technology, Inc. Foot Pedal/Thermometer
---
Thanks for this really helpful post! Finally got my Temper USB (Tenx type) to work :)
ReplyDeleteThanks for the tip, my Tenx TEMPer is also working well.
ReplyDeleteJust came across this script while looking for an Ubuntu script for my TEMPer.
ReplyDeleteThe company that makes it provide a nice script for Windows, buy I wish to use the device on my ASUS-eee now running Ubuntu 1710.
Anyhow-
when I did a lsusb, the temper device showed up as
0c45:7401 Microdia TEMPER device.
Just in case anyone wishes to modify your script....
- Tony Q. King, tech aqk-dot-ca
ADDENDUM-
ReplyDeletePlease see LINUX-JOURNAL
for a Python script for this newer TEMPer device that I mentioned above
- Tony, tech (at) aqk-dot-ca
Does not work. Please tell us pre-requisites.......
ReplyDelete