Neon Society Electronics

Menu

Python USB and TEMPer V1.2

In preparation for a bigger project I’ve recently written a driver for the USB Temperature Sensor TEMPer V1.2. As this is going to be part of a bigger project that will interface with these sensors I wanted to integrate the driver with the project. So I decided to write it in Python.

Story

So a friend of mine wanted to use these relatively inexpensive USB Temperature Sensors (available on Amazon for less than $20) to keep an eye on his indoor garden. But he found the software available for these sensors to be inadequate for what he had in mind. So I told him I’d look into the issue of writing a better front-end Software for these sensors. Since he wanted to use them in controlling his indoor garden I decided it would be best to have the Software be compatible with low cost embedded boards that don’t take up as much power as a big Computer. Naturally this meant I had to check the sensors for Linux compatibility first. Fair enough it seemed that many people have worked with these devices before, even on Linux, so I bought one and started experimenting.

It turned out that the driver situation for these sensors is in no way straight forward. There were a bunch or Perl scripts and other things floating around, but I’m not a Perl programmer and I didn’t want to have to install a multitude of interpreters. I wanted it to be as plain and simple as possible and if at all possible I wanted it to be platform independent. After a while I found a C Program called pcsensor that would interface with the TEMPer V1.2. I was much more comfortable with a small C Program than with all thing Perl, but since the interface to the USB library in Python is very similar to C I decided I could just as well use the C program as a template and rewrite it in Python.

Source Code

So after about 2 hours of transcoding C to Python I had a working driver! This driver is still a little rough around the edges, as it very closely resembles the C Program, but it’s a good start.

I thought I would share this piece of code. I’ll of course write some more about this as soon as I make more progress with this project.