K8055 USB + Python + Twitter + IRC: Space Indicator as a OS Service

Andrew Bolster

Researcher at the University of Liverpool, Founder/Director at Farset Labs

[caption id=”attachment_768” align=”alignright” width=”231” caption=”Big Red Button, Does what it says on the tin”][/caption]

After a long time in the oven, Farset Labs is up and running. Unforanately we don’t have any of the crazy equipment yet, since we’re broke.

As my first ‘official’ Farset Labs project, I’ve installed a ‘Big Red Button’ to notify the @FarsetLabs twitter feed and #FarsetLabs on Freenode to the status of the space.

Basically, first person pushes the BRB down in the morning, then one of the directors key-unlocks the space to ‘close’ it.

This was accomplished using the  Velleman K8055 USB interface board and a lot of speaker wire.

Simple enough, but a process fruaght with stupid mistakes, such as:

  • Whoops, have to run as sudo to access the USB device

  • Whoops, OAuth2 is a pain in the ass

  • Whoops, have to change each message slightly or Twitter thinks I’m spamming the joint

  • Whoops, have to do PING/PONG responses to the IRC server (easier to use irclib since it manages that for you)

  • Whoops, need to keep talking to the IRC server otherwise it disconnects us (hence the irc.process_once() call in the main while loop)

  • Whoops, Ruby isn’t any better than python at OAuth2


sudo apt-get install build-essential libusb-dev python-dev python-setuptools python-irclib

sudo easy_install oauth2

sudo mkdir /opt/bin

Actual Work

cd /tmp/

wget package from <a href="http://sourceforge.net/projects/python-k8055/">http://sourceforge.net/projects/python-k8055/</a>

tar -xvjf python-k8055-0.2.tar.bz2

cd python-k8055-0.2

sudo python setup.py install

cd /opt/bin/

sudo wget <a href="http://pastebin.com/KqCKhKG6" target="_blank" title="Occupy Farset Python Script">occupy-farset.py</a>

cd /etc/init/

sudo wget <a href="http://pastebin.com/mzRZWP75" target="_blank" title="Occupy Farset Upstart Conf File">occupy-farset.conf</a>

sudo initctl reload-configuration

sudo service occupy-farset start

sudo service occupy-farset status


  1. Download and install python wrappers for the Velleman K8055 USB interface board

  2. Copy our customised (but highly customisable) python script that talks to IRC, Twitter, and the interface board

  3. Copy and install the Ubuntu Upstart conf file to use the script as a service

  4. Fire off the service and test that it’s still up.

That’s all folks!

Published: April 10 2012

blog comments powered by Disqus