Category Archives: Random

Digital Holga part 3 – taking photos with the inputs

This is my follow up to my previous posts about building a digital camera out of a Raspberry Pi Model A and a medium format Holga 120 film camera.

My aim being to build a hackable portable digital camera which hopefully would be able to capture images not possible with a normal digital camera, and to recapture the unpredictable spirit of film cameras (without the expense of the chemicals).

In my first post I fitted a Raspberry Pi model A and camera board into a hollowed out Holga 120. The Holga’s plastic construction makes it easy to work with and it’s roomy enough to accommodate a Pi without having to remove components from the board.

Pi camera case with Pi fitted
Here it’s sitting in it’s case. Snug.

In my second post I added the final inputs to the Holga case – a rotary selector switch with 3 positions, a push button switch on the side (with a trigger input on the bottom) and a power switch. I added a filter adapter to the front lens and I also took a few pictures by remotely triggering commands on the Pi.

Holga 120d Raspberry Pi Camera Case
Here’s the 3/4 view with the big clunky switch. It now switches the mode of the camera.

I’ve now connected up the switches and added 2 LEDs to the Raspberry Pi, making the Holga 120d a practical portable digital camera.

The rotary switch combined with the trigger switches effectively gives the Holga 120d 3 input buttons. The 2 LEDs (blue and orange) indicate the ‘mode’ the camera is in when I push the shutter button.

Each of the 3 ‘modes’ is programmable – at the moment I have 2 set up – one takes a photo which is saved to the Pi’s SD card, and the other performs a safe shutdown. It’s possible to add any command to the python script – and I’m working on an additional artistic mode which I’ll detail in a later blog.

I soldered all the inputs & the 2 LEDs to a Slice of Pi Breakout Board – these are available for around £5 and fit neatly over the Raspberry Pi without taking up too much space.

Raspberry Pi Holga 120d internals
Bit of a cram, but it all fits.
Holga 120d LED viewfinder
These light up to tell you the mode the camera is in.

From the board leading to the case, the green wires are to the push switch and trigger input, the 3 red wires & black to the right lead to the rotary switch and the red and black pairs lead to the LEDs.

The yellow wires just out of shot are to the flash hot-shoe. I did consider connecting this using an opto-isolator LED and there this space to do this at a later date.

There is also (just) about enough space to add a real time clock module – I used the Adafruit DS1307 Real Time Clock which connects to the 5v, GND, SDA and SQL pins on the slice of pi board. I followed Adafruit’s instructions (leave the resistors off the board!) and it works well.

The LEDs themselves slot into the viewfinder and light up according to the position of the switch. So in mode 1 the blue LED lights up, 2 both LEDs light and in 3 just the orange LED. This gives a bit of useful feedback to show that everything is working properly and the Pi is taking pictures when you click the shutter button.

For an easier to understand diagram – here’s the circuit laid out in Fritzing.

GPIO 23,24 & 25 are the inputs, with GPIO 17 and 18 driving the 2 LEDs. The switch at S2 is the rotary selector switch.

I used 330 ohm resistors for the LEDs and 10K resistors for the GPIO inputs.

Holga 120d wiring schema
Try on a breadboard first


The code I used is really simple.

Make sure you’ve run sudo apt-get update and have installed the Camera py modules first.

#!/usr/bin/env python

import time
import picamera

from time import sleep
import os
import RPi.GPIO as GPIO

GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)

while True:
        if ( GPIO.input(23) == False ):
                print('Orange: Taking photo')
                GPIO.output(17, True);
                date_string = time.strftime("%Y-%m-%d-%H:%M:%S")
                with picamera.PiCamera() as camera:
                        camera.capture('image' + date_string + '.jpg');
                GPIO.output(17, False);
        if ( GPIO.input(24) == False ):
                GPIO.output(18, True);
                os.system("sudo shutdown -h now")
        if (GPIO.input(25) == False):
                GPIO.output(17, True);
                GPIO.output(18, True);
                GPIO.output(17, False);
                GPIO.output(18, False);

In the code above, one of the settings takes a photo which is saved with a time / date stamp, the other safely shuts the Pi down, and the other is yet to be used.

The easiest way to get your photos off the Pi is to use Filezilla and to connect to your Pi using sFTP – this uses your SSH login and enables you to easily to download and delete photos.

For connecting to your Pi remotely see my previous post about finding your Pi on your network.

I’ve had lots of interesting feedback about the Holga 120d – with the Pi model A (and potentially a smaller model A+ in the works) there are lots of opportunities for adding a digital camera to an existing film camera.

Now i’ve got my Holga 120d up and running I’m going to do some experimenting – my aim being to capture images that you can’t recreate with Instagram. If you’ve got any creative ideas to share please leave them in the comments below!

China to Cheltenham: Great Walls of Fire and Web Tempora

Here’s my post for this year’s Blog Action Day which is my geeky take on the subject of Human Rights.

Adafruit's Onion Pi
Adafruit’s Onion Pi

Privacy is one of those human rights that we take for granted. It’s listed by the United Nations as article 12 of the Universal Declaration of Human Rights:

No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks.

 along with the freedom of expression, listed as article 19:

Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers.

Since the early days of the world wide web, privacy and the freedom of expression are central, as no single person or entity controlled the chaotic sprawl of servers that spewed out opinions, information and videos of cats.

This freedom cuts both ways – the web isn’t just freedom fighters and unsigned artists, it’s also terrorists, music pirates and pornographers, but the individual was the filter, not governments or corporations. 

For years in the west, we’ve looked down at China’s great firewall that filters the internet, and  the behaviour of giants like google who meekly provide pictures of pretty gardens rather than tanks when you search for ‘Tianamen Square’ 

China now employs 2 million people to monitor the internet in a move most people in the west would regard as a creepy throwback to the cold war era.

Yet here in the UK, the government are proposing a catch all, opted-in internet filter with the noble intention of ridding the web of porn. Sadly good intentions can have unintended consequences – what makes the block list is vague at best, and could include things like ‘web forums’, ‘esoteric material’ (whatever that is) and ‘anti-blocking software’. Very little is said about who would decide what is acceptable and what isn’t, and how this would be policed. What would stop a future government blocking the websites of political parties, environmental campaigners or minority groups? how would the right to appeal a block work? would a company abuse it’s control over the block to silence criticism? could a less moderate government use this to stifle debate and eliminate opposition?

Governments do have a duty to protect their citizens – whether its from terrorism or internet nasties, but there is an issue of accountability, and trust. We need to be able to trust that government agencies are keeping an eye on the activity of people who are a genuine threat, and that this eye is accountable and itself scrutinised. It’s no longer enough to rely on the over used argument that  people with nothing to hide have nothing to fear.

Recently Chris Huhne, who was in the cabinet for two years until 2012, said ministers were in “utter ignorance” of the two biggest covert operations, Prism and (the deep fried in batter sounding) Tempora. Worrying indeed; who are these covert operations reportable to? what would stop this power being abused? 

And there is the case of undercover police officer Mark Kennedy who unlawfully spied on environmentalists – an example of an agent abusing his power in what should be a moderate country governed by a moderate government.

In any democracy, checks and balances are needed to ensure that the rapid rise in surveillance isn’t abused, or could be abused in the future by less moderate governments – 

Tony Benn put it quite well:

“What power have you got? Where did you get it from? In whose interests do you exercise it? To whom are you accountable? And how can we get rid of you?” If you cannot get rid of the people who govern you, you do not live in a democratic system.”

When checks and balances fail, as always, the web itself has found ways around the issue of censorship and to secure privacy:

It’s possible to use a Raspberry Pi to peek round the Great Firewall of China, and for the paranoid you can protect your privacy with Privoxy or using TOR with the Onion Pi.

I’m not reaching for my tin hat yet, but it’s good to know what’s possible just in case.

You can find out more about internet freedom, and join the campaign at the Open Rights Group.



Alternative endings

Recently Brixton Book Group discussed Ernest Hemmingway’s A Farewell to Arms – a book I suggested after hearing a Radio 4 article about authors writing alternative endings – often to make film audience focus groups happy, and often at the detriment of the original story.

Hemmingway wrote 47 different endings to his book. If you want to read through all 47 endings they’re available in this edition on the kindle.

Here’s my alternative ending in graphic novel format (click to make it bigger) representing”the biggest and most unforgivable cop-out .. (the alice in wonderland dream)” or Bobby in the shower in Dallas, depending on your cultural reference points.

The Alternative Alternative Ending to A Farewell to Arms
I did consider making the Doctor Who / Scooby Do ending

Brixton Book Group meets every 3 weeks or so to talk about books in the pub. Everyone can suggest a book to read next time, and we vote on which one to read next using a doodle.

Get iplayer on the Raspberry pi XBMC – RaspBMC

I wrote a post a while back about installing Sam Nazarko’s Raspberry Pi flavoured XBMC – Raspbmc, but now things have moved on a bit, rendering my original instructions out of date. Updated update: RaspBMC is now available as part of the NOOBS installer.

Sam has now released the final release version of Raspbmc so I thought I’d give it a go.

Now with a lovely logo too!

My criteria in trying this out is, is this something I could use everyday and is this something I could set up for an older relative and just leave in place

The updated release version of Raspmbc now has a very easy to use installer, and is really simple to get running. Just prepare your SD card using the appropriate installer (I’ve been using the Mac version) pop it into your Raspberry Pi (ensuring it has an ethernet connection) switch on the power and then go and have a cup of tea.

Everything’s lovely and smooth – the menus work slickly, and the behind the scenes hard work on Raspbmc has really paid off. It behaves like a commercial product, and although it does pause occasionally it’s still far superior to the bundled apps that come with a lot of  (often very expensive) smart TVs.

It also works well on a Motorola Lapdock (adjusting the screen size automatically from the HDMI monitor I originally installed it on).

In face you often have to remind yourself that this is running off a $25 computer.

Once you’ve got it running adding WiFi is nice and straightforward – I’ve been using the Edimax EW-7711UAN 150Mbps Wireless adapter which is detected and works with my BT hub without any issues. You just need to enter your network SSID and login using the Raspbmc settings option which is under programs.

Installing iPlayer on RaspBMC

Youtube and Vimeo plugins can be found in the ‘add plugins’ section and work out of the box.

To add iplayer – possibly the main thing I use my streaming box for these days there are a few additional steps (for just iplayer follow the step by step guide see this blog)

You’ll need to add some additional repositories –

There’s actually a handy plugin which automates the addition of new repositories, so we’ll install that first.

With the Raspberry Pi connected to the internet:

Home Screen to Settings > System Information. You need to locate and take note of your Pi’s IP address – this usually starts with 192.168.1.(then a number)

Next on another computer, you’ll need to connect via SSH – on a Mac or Linux PC open the console and use:

ssh pi@(your IP address)

the standard password is raspberry. Select yes and enter your locale details in the menus that appear – this will then end up with a [email protected] prompt.

On a PC you’ll need an SSH tool like PuttY

Copy and paste the following into your terminal window:


Then back on the pi go to system -> addons (in XBMC backspace moves up through sub-menus, so you might have to hit this a few times to find the top menu) and select install from zip file option.

Select homefolder and then

you should get a little message in the bottom right hand corner to say it’s been installed.

then select the programs icon and run the Repositories Installer

There’s a long list – iplayer can be found in Hitchers Repo, 4OD in the Mossy repo. Once this is installed you can navigate to system – settings – add-ons to install, and then video- Add-ons to watch.

For much more – including things like setting this up for airplay, using an ipad as a remote – and to support this excellent project – check out Sam Nazarko’s book for more info: Raspberry Pi Media Center

Tweet your MP

Ever wanted to send a tweet to your MP? not sure if your Member of Parliament has embraced social media? want to put a handy tool to do so on your website?

Tweet Your MP
Tweet your MP

Here’s a little script I wrote to find your MP using a postcode (via the API) and send them a tweet. Info, source and background below.

It’s possible to tweak this tool to return email address, postal address, phone number and facebook page (if they have one) – you can also add custom information to each MP as well. My data set includes 436 twitter accounts for MPs – slightly more than Tweetminster’s 409 but I have included auto twitter accounts (so people can see you’re tweeting your MP, even if they don’t respond). I’ve tried to avoid spoof accounts.

Bit of background about this tool

This tool works by converting the postcode into a constituency name on, and then matching this constituency name with MP’s details on a local MySQL database table. If you don’t want to use’s API it is possible to buy a constituency postcode database from Ordinance Survey for £350.

For a while I’ve been working on an open-source activism tool. It was born out of curiosity, an excuse to learn a bit more about php and as a way of proving email to MP actions courtesy of the very useful API.

Unfortunately it became on of these projects that got more and more complicated – once I’d got round to adding a graphical user front end, SMS texting, and add on modules it started getting a bit too big for me to handle. Plus I started encountering problems with PHP’s send mail function getting blocked by outlook servers, experimented a bit with pop mail senders and then started looking at using online cloud services.

The past 2 organisations I’ve worked for have used off the shelf tools instead, making the aim of the project a little bit redundant.

I still have a copy of all the code (with lots of comments) if anyone would like it – it’s in an alpha sort of works if you’re prepared to spend a bit of time tinkering with it state. Just drop me a line. All I ask is that if you do improve on it, please make it publicly available (it is GPL licensed).

I’ve also been thinking about the effectiveness of email-your-mp actions with identikit emails embedded in them – I think using twitter or even printed out letters might be a better way forward to creatively attract attention, and avoid the boring accusations of ‘slacktivism’.

So in the meantime I’ve taken the bits of the tool that did work, and have reworked them into a much simpler ‘Tweet your MP’ toolkit. The idea of this is to provide a simple widget you can embed on your website – I’ve seen plenty of websites that just link to, or refer people to google, so this provides a way of keeping activists on your page.

In the example above I’ve just gone for twitter and website information – but with a few tweaks to the code you can add email your MP (via a mailto link) phone your MP or write a paper letter to your MP functionality.

Requirements & the code

To get this to work you will need access to a MySQL database and PHP. This is currently running on my server which is a cheap-as-chips 123-reg setup. Check your ISP’s documentation for support on how to get these logins. I’ve labelled the code to show what it does.

If there are any corrections please get in touch with me and i’ll add them.

Download the code from GitHub

I’m updating this to fix problems and add enhancements. At the moment the code does contain a bit of stuff left over from the webtivist project. The GitHub version will always be the most up to date.

To make this work you’ll need to upload the MP data spreadsheet to your MySQL server (I used the import function on my 123reg hosting and it worked fine) this has every MP’s contact details – if you’d like access to this please drop me a line as I’d like to keep track of who’s using it!

Then you’ll need to edit the settings.php file to include the login for your MySQL database, the hostname and tablename for your MP database.

You’ll also need to apply for a API key – there’s usually no charge to use this for small volumes. They prefer it if you ask them if you’re intending to use it a lot. Please Please don’t use this to send identical emails to MPs.

For the twitter part you’ll also need a Twitter API key  I changed this to use the more simple @mention option on twitter.

Corrections / suggestions and contributions

Thanks to MPs being arrested for things, standing down or departing, this data may become out of date over time.  If there is incorrect information please let me know and I’ll update it.

This script makes use of the API and Ruben Arakelyan’s php script. Check the comments in the code for more information.

Update: this script has now moved to

Elite – making a game that looks as good as the box art

This week it’s been announced that one of the original creators of the classic 8 bit video game Elite is seeking funds to launch a version updated for the 21st century.

I grew up playing Elite – originally on a BBC B and then a few years later on it’s 32 bit successor the Archimedes, it was brilliant, addictive and years ahead of it’s time.

Elite was a 3d space exploration game which featured open-ended play – you could explore the galaxy, play as a trader, bounty hunter or pirate in your quest to gain enough kills to be ranked as ‘Elite’ (starting from ‘harmless’ and working your way through ‘mostly harmless’, ‘dangerous’ and other often amusingly named ranks). Elite rewarded good acts like hunting down pirates, and punished bad behaviour – if you became a pirate yourself your legal status changed to wanted and you attracted the attentions of bounty hunters and ultimately the police. With the occasional mission for the galactic navy thrown in for good measure, Elite had the qualities that would make games like Grand Theft Auto a success – many years in advance.

BBC B Elite (Master version)

One of the things I used to wonder playing Elite, was whether or not computers would exist in the future that could actually depict the game as it was featured on the beautiful box art:

Elite Box art
Beautiful 1980’s sci fi art

The Sci-Fi art of the 1980’s is easily possible with todays’ computing power. Although there were sequels to the original Elite (Elite II, Frontier) none of them captured the playable spirit of the original – something that will hopefully be addressed in the update which promises “joyous immediacy”. If you can’t wait until 2014, I’ve prepared a short guide on how to play Elite on (what is arguably the modern day successor to the BBC B) the Raspberry Pi:

How to play Elite on the Raspberry Pi

It’s quite easy to just download an emulator on any modern PC or Mac and play Arc Elite – regarded as the best version of the original game. For a bit of fun I thought I’d have a go at running Elite on my Raspberry Pi.

For starters you need to be running RISC OS – this is a lightweight operating system originally developed by Acorn back in the 80s to run on the first generation ARM chips – this runs incredibly quickly on the Raspberry Pi. You can run various emulators (for example the Sinclair Spectrum) on the Linux Raspberry Pi build, but I’ve found these tend to run quite slowly.

First download RISC OS from the Raspberry Pi website and copy it to an SD card (or you can purchase a ready-made card from RiscOS open – it’s only £10, and worth it to support their very handy work! )

Because Arc Elite was originally written for ARM 2 and ARM 3 machines, it won’t run on the ARM 6  chip in the Raspberry Pi – but don’t worry you can emulate the older hardware using ArcEm – which is available from: 

Update: there is an issue transferring archived files between PC/Mac (which I’m writing this on) and RISC OS – which causes the filetype to be incorrect (StrongArm will open when you try to run !ArcEm) To fix this:

Open the original zip file on the Raspberry Pi in RISC OS, unpack !ArcEM
next re-download the !ArcEm archive:
open that in RISC OS using !sparkFS – then drag the unarchived files over your original copy (this preserves the ROM files you need)

!ArcEm should now run – if Elite gives you problems download the original archive:

Sorry about this – I’ve ordered a copy of the nutpi pack which includes the full copy of !SparkFS – i’ll recreate the zip archive so everything will work more simply in future!

Run !ArcEm, then open the HostFS drive on the desktop – Elite, along with the Dark Wheel Novella and User Manual are all available on there.

Arc Elite running on the Raspberry Pi
It’s a bit stretched on my screen, but smooth and playable!

It runs as smoothly as I remember, and is very playable – I’m still rubbish at docking though. On my lapdock display the screen was stretched – it might be worth experimenting with different settings to see what works best for you.

Interestingly there were a lot of 16 bit Amiga and Atari games converted to run on the Archimedes – so for anyone interested in emulating old games this should work for those as well. ArcEm is still under active development, so it’s well worth checking out.

If you enjoy playing Elite as much as I have, (and are suffering from I-didn’t-pay-for-this-amazing-game guilt) please help fund the next version on Kickstarter.

*the files I’ve used to do this were freely available from these sources:


RiscOS 3 Rom (in the archive)


GPL licensed

Getting a Nerdkit to work with the Raspberry Pi

Most of the things I do on a day to day basis are in relation to building websites and looking at ways to code interesting online actions – one thing I’m interested in however is the idea of the internet of things – smart, connected objects that bridge the gap between the online and actual world. Perhaps one day I’ll even find an ecampaigning application for this.

I just had a go connecting up a Nerdkit with the Raspberry Pi. Nerdkits are similar in some ways to the Arduino boards, although they’re a bit more hands on. Whereas the Arduino is nicely assembled and can be just plugged into a USB port, the Nerdkit comes as a pile of parts, a bit of breadboard and some instructions. What’s exciting about Nerdkits, Arduinos and microcontrollers (MCUs) in general is that they provide a flexible, re-programmable set of ‘brains’ with lots of interesting uses. Think of them as lego for electronics.

The ultra cheap Raspberry Pi makes a nice partner to the Nerdkit, as I’m still slightly nervous about attaching something I’ve put together myself to my shiny Mac. Along with the instructions come a set of makefiles which you compile and upload to the MCU via the USB to serial adapter.

The  Nerdkit is based around an Atmel AVR ATmega168 microcontroller which has it’s own bootloader. Also included are the crystal, various resistors, voltage regulators and a variety of input sensors and output electronics. Putting the whole thing together is very satisfying and has given me a bit more insight into how microcontroller based kits work (and what all the bits on the Arduino board do). One really nice additional feature of the Nerdkit is the lcd display panel, which provides feedback in the form of messages, poetry or temperature readouts – depending on what you program it to do. The example below shows it running as a thermometer (one of the included tutorials). Mounting the whole thing on a bit of board is highly recommended.

Photo of Nerdkit mounted on a board with a Raspberry Pi
Here’s my Nerdkit mounted on a board (an Ikea shelf panel) with power switch

Installing the software as in the user guide works fine -it’s all done in the command line, so there’s no Java based application to worry about –

sudo apt-get install avrdude
sudo apt-get install gcc-avr
sudo apt-get install avr-libc

You can edit the makefiles using Leafpad which is part of the default Raspbian operating system. Connecting the Nerdkit cable to the Pi’s USB port presented no problems either.

I did however run into a small snag – although programs would compile and upload successfully, the display on the Nerdkit was showing just on the top line:

Garbled text display
Not quite working

 A quick hunt through the forums later and I came across the fix – open the Makefile (in the example above it’s the one in the tempsensor directory and the one in the libnerdkit directory), look for the GCCFLAGS line and change the “-Os” flag to “-O0” (letter O, number 0). Then delete the .hex and .o files in both the directory your Makefile is in and the libnerdkit directory. That last bit is vital, I kept missing it.

Then it should work fine:

Normal nerdkit display
Working as it should. It was slightly chilly.

So there you go – my first steps in getting my Raspberry Pi to do a bit more than web surfing. I thought I’d highlight that the Raspberry Pi and Nerdkit work together happily, in case anyone else wants to try it out.