Phidgets are convenient USB interface gadgets. One board provides simple control over 8 digital input and output lines. Some have analog inputs, some drive small LCD panels, others drive servos or do RFID measurements.

The company that makes them provides easy-to-use driver libraries for windows, linux, and OSX.

I had to patch their linux library before I was able to successfully link anything against it: phidget21-linux.diff.

Python Bindings

There are a couple of python phidget libraries floating around out there. Before the linux port of the library was made available, an alternate library was written, which entered debian as the "libphidgets0" package. There is a python binding to this called python-phidgets, but it is a SWIG wrapper and is neither very python nor particularly functional when I tried it.

I wrote my own binding to the library, since I figure they're most likely to get the phidget-specific fiddly bits right. My bindings lack support for many callback functions and several devices, but provide a truly pythonic interface, and they seem to work for me. The release is available here: phydget-0.1.tar.gz. There is also a darcs repository with the latest code (which doubles as a browsable copy of the source tree) at .

If libphidget-2.1.0 (from is not installed in /usr/local/lib or some other directory that is on gcc's search path, you'll need to build the python binding with a command like this:

python build_ext -i -I../phidget21.linux -L../phidget21.linux -R../phidget21.linux

Otherwise the usual python build should suffice.

udev, permissions on /dev/bus/usb/ nodes

Add the following line to a file in your /etc/udev/rules.d/ directory. This file must sort after the 020_permissions.rules that debian or udev puts there, otherwise that file will override your own rules. I use 030_warner.rules for all my changes.

SUBSYSTEM=="usb_device", SYSFS{idVendor}=="06c2", MODE="0666"

Then restart udev, then unplug and re-plug in any Phidgets you've got. ls -l /dev/bus/usb/* should show you the phidget usb device nodes with permissions that let non-root users (i.e. you) use them.

Now, you need libusb to look at /dev/bus/usb instead of the obsolete /proc/bus/usb. The version of libusb that is embedded (statically) in libphidget-2.1.0 only looks in /proc/bus/usb, but you can set USB_DEVFS_PATH=/dev/bus/usb to override it.

Alternatively, you could patch their Makefile to let it link (dynamically) against the system's version of libusb, which is probably newer and should look in /dev/bus/usb in preference to /proc/bus/usb . This patch: native-libusb.diff is an attempt to do this.


Brian Warner <>
Last modified: Sun Dec 17 21:21:42 PST 2006