XloBorg – compass & accelerometer for the Raspberry Pi

This week, PiBorg released XLoBorg – a 3 Axis Accelerometer and 3 Axis Magnetometer add-on for the Raspberry Pi

XloBorg Compass and Accelerometer

Since its so new the current software only gives the raw magnetometer x y z values:

mX = +00371, mY = -00053, mZ = +02539

Magnetic flux strength values aren’t much use to us mere humans,
what we really want is a nice easy 0-360 degree heading value.

Maths to the rescue !

We can find the angle from those “lengths” with arc tan Y/X

heading = math.atan2 (mY,mX)
(For simplicity I’m assuming the Pi is level… a more complicated method would include accelerometer data)

Here’s my full python code to read the sensor, and convert to degrees:

#!/usr/bin/env python

# Load the XLoBorg library
import XLoBorg

# Load maths library
import math

# Tell the library to disable diagnostic printouts
XLoBorg.printFunction = XLoBorg.NoPrint

# Start the XLoBorg module (sets up devices)

# Read and display the raw magnetometer readings

mx,my,mz = XLoBorg.ReadCompassRaw()

print 'mX = %+06d, mY = %+06d, mZ = %+06d' % XLoBorg.ReadCompassRaw()

# get the heading in radians
heading = math.atan2 (my,mx)

# Correct negative values

if (heading < 0): heading = heading + (2 * math.pi) # convert to degrees heading = heading * 180/math.pi; print 'Heading: ', heading

Much better:

mX = +00371, mY = -00053, mZ = +02539
Heading: 351 degrees

Posted in Technology | Leave a comment

Raspberry Pi Biped Robot

2013-06-16 16.44.10

This is a biped based on the BRAT design from a few years ago, updated to be controlled by the raspberry pi and so giving access to usb peripherals, camera wifi etc.

The robot is a 6 servo biped walker featuring three degrees of freedom (DOF) per leg. The robot can walk forward or backwards and turn in place left or right with variable speed. It can even do lots of Robo-One style acrobatic moves.

Currently using the interrupt driven servoblaster software to drive 6 servos.

2013-06-16 17.02.14

Arms and head will increase the servo count, so may offload servo processing to an arduino in addition to the raspberry pi.

Posted in robots, Technology | 1 Comment

Setting up adblock on Raspberry Pi

So you’re used to browsing on the PC with Adblock installed,
then you use the default browser (midori)
on the raspberry Pi and find the web is full of annoying ads !

This not only distracts, but also slows down page loading.

Unfortunately the version of midori on the pi does not support ad blocking direct in the browser,

While Chrome and Firefox are actually available on the raspberry Pi in the form of Chromium and Iceweasel and they do support adblock plus, they are very slow and bring the low powered Pi to a crawl.

Here is a quick way you can block all the ads. Not only will your surfing be faster but you will also save some bandwidth.

Simply use a hosts file from the guys at MVPS – they maintain a list of ads which we can use.

Open a terminal window and type (or copy and paste) the following:

wget http://winhelp2002.mvps.org/hosts.txt
sudo mv hosts.txt /etc/hosts

Ads are now gone !

We could stop there – but you will quickly realise that many sites show an error where the advert used to be. There is a way around that too – by running a local webserver that shows a blank image in their place.

Kwakd – simple webserver to serve blank webpages / images

We’ll have to download and compile it on the raspberry pi:

wget http://kwakd.googlecode.com/files/kwakd-0.3.tgz
tar -xvf kwakd-0.3.tgz
cd kwakd-0.3

now we can run it:

sudo ./kwakd -p 80 &

Ads are now removed, and blank images are served in their place.

Enjoy a cleaner and faster web browsing experience !

Posted in Technology | Tagged | 2 Comments

Play DVD disks in XBMC on Raspberry Pi

Here’s how to add DVD playback support into RaspBMC n your Raspberry Pi
(requires MPEG2 key installed on SD card – buy one here:

i.e. Playback commercial DVDs direct from attached USB DVD drive

While it works well, it only plays the film, no dvd menus.

SSH into the running RaspBMC

Download and compile libdvdcss

wget http://www.videolan.org/pub/libdvdcss/1.2.12/libdvdcss-1.2.12.tar.bz2
sudo apt-get update
sudo apt-get install -y bzip2 gcc make
tar -xvjpf libdvdcss-1.2.12.tar.bz2

cd libdvdcss-1.2.12
sudo make install
sudo cp /usr/local/lib/libdvdcss* /lib

Install mplayer

sudo apt-get install -y mplayer

Make a directory to store the virtual file

sudo mkdir /dvd

Make the background script:

sudo nano /sbin/playdvd.sh

mkfifo /dvd/dvd.mpg
while :
        mplayer dvd://1 -dumpstream -dumpfile /dvd/dvd.mpg 1>null 2>null
        sleep 5

ctrl+X to save the file

Make it executable

sudo chmod a+x /sbin/playdvd.sh

Add it to startup:

sudo nano /etc/rc.local

add the line


before exit 0.

(ctrl+x to save and close)

In the XBMC GUI:

Add /dvd as a video folder in XBMC

When you want to play a dvd, play the dvd.mpg file

The script running in the background will take care of dvd changes.

Posted in Software | Tagged , , | 1 Comment

Play DVD disks on Raspberry Pi

In August the Raspberry Pi Foundation started selling MPEG2 codec licenses for the popular Raspberry Pi.

With this installed, the Pi can decode MPEG2 directly on its GPU chip, with very little CPU usage. The ARM CPU used in the Pi isn’t really powerful enough to decode MPEG2 on its own.

Since DVDs use MPEG2, this is a very welcome addition as it means hardware accelerated playback for DVDs.

Unfortunately due to the legal position on decrypting the CSS encryption on DVD disks, many distributions don’t include the relevent files.

You can get around this by compiling it yourself on the Pi, and here’s how:

Download and extract the libdvdcss source code:

wget http://www.videolan.org/pub/libdvdcss/1.2.12/libdvdcss-1.2.12.tar.bz2
sudo apt-get install -y bzip2
tar -xvjpf libdvdcss-1.2.12.tar.bz2

Compile it (only takes a few minutes):

cd libdvdcss-1.2.12
sudo make install

All done, now copy the libraries over:

sudo cp /usr/local/lib/libdvdcss* /lib

Now we can play a DVD direct from the disk:

mkfifo /tmp/dvdpipe
mplayer dvd://1 -dumpstream -dumpfile /tmp/dvdpipe 1>/dev/null 2>/dev/null &
omxplayer -r /tmp/dvdpipe

This may come to XBMC eventually, but current XBMC DVD code doesn’t allow for hardware acceleration.

Posted in Technology | Tagged , | 3 Comments

Instagram for firefox

View your latest feeds and images from instagram in a quick popup.

– View your feeds
– Show pictures full screen
– Browse by tags

– Like pictures
– Follow / Unfollow users

Popular photos and browsing by tag possible without being logged in.

Log in to instagram to browse user profiles and your photo feed.

– window resizes to screen
– some speed improvements

Install Instagram for Firefox

Posted in browser add-ons | Tagged | 16 Comments

Synergy – share mouse and keyboard across network

Looking for a cross platform network  mouse sharing program (KVM) I came across synergy:


It works well, but I did run into a less than obvious configuration issue –
initially once I’d installed it on a PC (with the mouse) and a Macbook (as client),
the Macbook couldn’t connect.

These messages appeared in the log:

Warning: Unrecognized client name “XXX”, check server config


It turns out you need to add the hostname of any connected computer in the settings page,
by dragging the screen icon from top right onto the grid somewhere next to your main screen:

and then it’s important to rename it to match the client ‘s hostname, otherwise you’ll get the same errors as above.

Once that’s done it works great, and I’m now able to share the same mouse across multiple computers just by moving the mouse off the edge of each screen.


You can download it for yourself over at



Posted in Technology | 5 Comments

Slim down your Raspberry Pi with an RSMMC card

Just a quick tip for those who want to fit their Raspberry Pi into a small case,
SD cards installed in the Rapsberry Pi stick out a fair amount:
Image Hosted by ImageShack.us
Image Hosted by ImageShack.us

and frank26080115 over on the raspberry Pi forums has even soldered in an adaptor to use a microSD card: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=45&t=9936

If you don’t want to get your soldering iron out, a simpler way is just to use an RSMMC card.
RS-MMC cards are available which are half sized SD cards which usually come with an adaptor to make them SD sized:

Installing an RS-MMC card in the Pi sits flush with the edge, and no longer sticks out:

Image Hosted by ImageShack.us

Image Hosted by ImageShack.us

Enjoy your new “slimmer” Pi !

Posted in Technology | Tagged | Leave a comment

Raspberry Pi case made from a 99p iphone 4 case

Tinkering with the popular Raspberry Pi, one of the first things you need is a case of some sort to protect it.

eBuyer.com are currently selling iphone4 silicone cases for just 99p delivered:

Silicone Case for iPhone 4G, Green and Black

99p including delivery in the UK



and you can probably buy them similarly cheap elsewhere.

It turns out these are just the right size for the Raspberry Pi to sit in:

There’s a handy cutout for Pi’s HDMI socket which happens to be in approximately the same place as the iPhone’s sim holder.

Posted in Technology | Tagged | Leave a comment

Watch UK TV in firefox and chrome

I’ve just written another firefox/chome addon, this one to watch UK TV live in your browser.

Watch UK TV channels via TV Catchup

Watch any of 58 UK freeview channels live streamed right in your browser.
BBC1, BBC2, ITV1, Channel 4 ,Channel Five
Film 4, Dave etc

Popup clickable list of channels, click to immediately watch in browser.

Click the icon at bottom right on the addon bar.

If you have the add-on bar hidden, you might have to re-enable it:
Press CTRL+/ or goto the menu view->toolbars->addon-bar

V 1.0


  • View any of 58 UK freeview channels
  • Clickable list of channels with a single click

Get it yourself direct from:

Watch UK TV for Firefox

and for chrome:

Watch UK TV for Chrome
Youtube video

Posted in browser add-ons, Software | Tagged | 11 Comments