phdigetsI have been playing with, what is for me, a new electronics ecosystem call Phidgets.  After doing some research I found out they have actually been around for over a decade.  In my short time playing with them, they appear to offer a very interesting twist on the open source hardware model.  A twist that should be particularly appealing to those who come from a software background.  At a glance, the hardware looks similar to an Arduino or other microcontroller platform.  But rather than writing code on a computer and uploading that to the microcontroller to run, phidgets are simply a USB-based interface between sensors and actuators and your computer.

But to say they are “simply” an interface is perhaps too simplistic and misses where I think the real power of phidgets lies.  The name phidgets is a mash-up of physical and widgets.  Physical as in physical computing, meaning a way to interface with computers in more natural ways than keyboards, mice, and monitors.  Widgets being a shorthand for graphical control element of graphical user interfaces (GUI), such as onscreen buttons or checkboxes.

Unlike an Arduino, phidgets do require a computer to work.  Thankfully single board computers such as the Raspberry Pi are quite capable of handling phidgets and preserve the small form factor we’ve come to expected for our embedded electronics projects.  At this point I should also point out for those interested in a having a wider range of hardware options that there are general interface kits that provide digital I/O and analog inputs.

phidgetsatworkSo what makes Phidgets such an attractive solution for software folks?  Simply put, phidgets support a metric crapton of programming languages.  They provide APIs for languages such as C, C#, Java, Python, Cocoa, Visual Basic and many, many others.  Check this page for a complete overview of all the supported languages.  To get started you will need to install a set of core drivers, fortunately they are available for the big three OSes Windows, OS X, and Linux.  There is also apparently support of varying degrees for Android and iOS, but I haven’t yet explored that yet so I will save it for another day.  Through the APIs you can read from sensors, control servos and control digital I/O.  And the phidget provides some level of protection from hardware issues like short circuits that could otherwise from your computer mobo.  In short, this would have made my undergraduate capstone engineering project a lot more powerful.

Now, as a hardware a guy, it took me a bit to get my head wrapped around having to call on rather robust API calls to control hardware as compared to my microcontroller work.  But once I did get my head wrapped around, I really enjoyed it.  Especially for projects that need the computing power of a Raspberry Pi or greater, while still have physical world interfaces.

Below is a piece of sample code I wrote/mashed together to control a servo and read from an analog slider.  It also let me get my feet wet with Tkinter to produce a basic GUI.  In short, the code has these 5 major sections:

  • Import Python and Phidget libraries
  • Define GUI parameters, if you want a Tkinter GUI
  • Define functions to handle I/O and GUI interactions
  • Setup and initialize Phidgets
  • Main loop for your GUI

I really like the exception handling aspects of Phidgets and the able to hot swap phidgets once your app is running.  You can find the code below and at my GitHub page (https://github.com/geekcowboy/TkServo)

In summary, if you need a quick, computer-based physical computing project with a GUI try out Phidgets and Raspberry Pi.  You might be surprised at what you can accomplish.