PLEASE NOTE: THIS THIRD PARTY PYTHON LIBRARY IS OUT-OF-DATE AND NO LONGER WORKS WITH THE LATEST VERSION OF THE TEMPER SENSORS
The TEMPer USB sensors are super easy to get setup on your Raspberry Pi thanks to a python library available on GitHub. https://github.com/padelt/temper-python
Start by installing the required packages:
sudo apt-get install python-usb python-setuptools
Once that’s installed you can proceed to clone the git to your Pi
cd ~ git clone git://github.com/padelt/temper-python.git
Once you have downloaded the repository you have two methods of using it:
- Through a simple temper-poll script
- Writing your own python script
To install the temper-poll script simply cd to the downloaded repository
Then run the setup script
sudo python3 setup.py install
Once that is done, you can simply use the following command to get the temperature and humidity from the sensor
If you want to take things further and write your own script! Within the temper-python directory you will find another directory called temperusb, move into this dir.
In here you will notice a couple of scripts, we are interested in the cli.py and temper.py scripts.
temper.py is the actual library so we don’t need to edit that one, we just need to make sure we have a copy of it in the same directory as our own script.
cli.py is a good example to base our script off of.
Start by running the cli.py script and see what happens
sudo python cli.py
As you’ll see it produces the same result as the temper-poll script.
If you get this error:
ValueError: Attempted relative import in non-package
Edit the script and change this line
from .temper import TemperHandler to from temper import TemperHandler
From here you can copy the cli.py script and edit it to suit your needs!