New Blog

All new posts will be going on my new blog hosted here:


Spark Core Shower Room Door Sensor

We’re a healthy and environmental bunch where I work and a lot of us cycle in. However, there is only one shower in the building and if you don’t sit near it then it’s a bit of a pain to turn up and find it engaged. So I decided to use my spark core to push the occupancy status to a web page.

Click for video

This seems to be a common problem and there are lots of similar hacks about. A distinguishing feature of this project is that it detects the bolt of the door lock so it is more accurate than just seeing if the door is shut. There was no easy visual indication that this particular door was locked before this. It also uses web socket push notifications to almost instantly show a change in status.

Time to prototype. Paper-clips, post-it notes, breadboards and gaffer tape are your friends here. The prototype was battery powered to avoid having to run cables but it has since been wired in. At this stage the core was programmed to switch off it’s wireless when no state change was occurring to save power.


This was then “productionised” with a JTAG programming board, some choc-block screw terminals and a small “enclosure” from a famous Swedish manufacturer.


All the code is on Github if you want to play with it. You’ll need to flash the firmware to the spark and add the core ID and OAuth token to the web page.

This all works really well but there are some improvements I could make. Even though the web page is not online, having the security token in it is not ideal and it expires occasionally. So the plan is to use a Raspberry Pi to receive the notifications and forward them on. This also means that I can connect my Blinky Tape to it and have another visual indicator as the LED that changes colour on the core is not that obvious.

Sweden Solar System Photos

On a recent visit to Stockholm I geeked out for a day and went on a hunt for planets in the world’s largest permanent scale model of the Solar System. We followed this guide but the Wikipedia page is more accurate. I also had a quick look at a data centre in a nuclear bunker.

Here’s the entrance to the data centre in Södermalm. It was shut but you could see quite a lot through the glass door.
Data Centre

The metro stops for the day going south to north. You get good value out of a T-bana pass.

The Sun is the Globe arena.
Sweden Solar System Sun

Mercury was inside a locked courtyard but had a hat on.
Sweden Solar System Mercury

Venus is now a building site.
Sweden Solar System Venus

The Earth and Moon are in the ticket hall of the natural history museum.
Sweden Solar System Earth
Sweden Solar System Earth and Moon

Mars is at the end of the line in a shopping centre. Just at the exit from the metro and easy to miss.
Sweden Solar System Mars

We tried to find Jupiter at the airport (which is made of flowers) but it didn’t seem to be there.

Next time I think a trip to the historic Ytterby quarry is in order. Maybe Venus will be back or we can check out the nuclear reactor at the same place.

Raspberry Pi Electricity Monitor

FORTH UPDATE: I gave a talk on this project at HN London. Here is the video:

THIRD UPDATE: I gave a talk on this project at HN London. Here are the slides:

SECOND UPDATE: I won a competition with this project:

UPDATE: Interactive example graphs now at

I’ve built a system for monitoring the electricity consumption of my home with a Raspberry Pi.

I bought a wireless electricity monitor from Maplin. It’s one of the standard affairs which has a transmitter with a current clamp that you put around the main in-feed and a portable display unit. However, this unit has a serial connection (accessible via an RJ45 socket) which allows you to download live and historic data to a PC.

There are limitations though; the on-board memory only stores daily totals and the windows software that comes with it is awful. So I reverse engineered the communication protocol and built my own logger. A Raspberry Pi was a great choice for the host machine as it would be far too ironic to leave a power hungry PC on to monitor electricity consumption. I have a plug in power meter and have measured the draw of the whole system as negligible (barely a few watts). Here is the whole system (the Pi and receiver obviously don’t always have to be next to the transmitter). The cable was excessively long so I shortened it by crimping on a new plug.

Pi power

The Pi power monitoring system

Parts list (hardware):

  • Maplin wireless electricity monitor
  • Raspberry Pi
  • Micro USB power supply
  • SD card (mine is 32GB high speed but 2GB would be fine)
  • WiFi adapter (optional; you could just plug it into your router)
  • Case (optional; but it looks nice and stops shorts)


How to get up and running:

  • Install the Apache web server with apt  (sudo apt-get install apache2)
  • Install with apt (sudo apt-get install python-serial)
  • Download the repository from github (
  • Copy the www folder to /var/www
  • Copy the python file to anywhere you want (e.g. home folder)
  • Plug in the receiver (the USB serial driver should already be present)
  • Execute “sudo python &” (add this to /etc/rc.local to run at boot)
  • Visit your Pi in a browser to see the data (visit raw.html to see the noisy data)

The system has a sample period of 7 seconds as the transmitter only broadcasts this often to save power. This still results in far too much data to render (after a few days) so the software filters out the noise to reduce the data points. Future plans include using the ADC and micro-controller on my self assembled Gertboard with my new Pi to achieve a much higher sample frequency.


Gertboard with current clamp

FYI soldering zero ohm surface mount resistors is a real pain. Why Gert couldn’t have just used wire jumpers I don’t know.

Below are some screen-shots of the graphs that are produced by the system. This first image shows the filtered data over 5 days.

Filtered plot over 5 days

Filtered plot over 5 days

This next image shows a zoomed in portion of the 1st plot. You can see the thermostat in the oven on the left, an electric heater in the centre and the washing machine just after.

Filtered plot

Filtered plot over 2 days

This is a raw version of roughly the same region with the noise shown.

Raw plot over 2 days

Raw plot over 2 days

Here it is zoomed in to a high usage region where the electric oven is in use.

High usage raw plot

High usage raw plot

Here is a low usage region. You can clearly see the compressors of the fridge and freezer. Occasionally the inrush current of the motor shows up.

Low usage raw plot

Low usage raw plot

Thanks to for an awesome library and for the great hardware.

P.S. The dygraphs library is also used at (which is a service for monitoring how many computers have been left on out of hours). If you want to play with the interactive features of the graphs or see some of the more advanced interface options then take a look at the example dashboard.


I’ve started using GitHub to share my code, although I’m more of a Mercurial person and even use TFS when I have to. You can find it all at and there is even some stuff on there that didn’t warrant blogging about that you might like.

London Tube Status – Updated

I’ve updated the mobile London tube status at by tidying the code up a bit and using the official API. The code (PHP/XSLT) is on GitHub at

There is also a version for HTML5 smart phones which uses jQuery Mobile, but this is still a work in progress. or if you prefer to try before you view source.

Spotify Playlist Generator

I’ve made a Spotify Playlist Generator that uses to find songs by similar artists.

Download the Playlist Generator or as a zip with the instructions.

It’s Windows only (for now) and it requires the .NET framework v3.5 or greater.
The source code is available on GitHub under the GPLv3 if you would like to build on it.

Playlist Generator Screen Shot

Playlist Generator Screen Shot


  1. Enter an artist’s name in the artist box.
  2. Click the button and wait until completion.
  3. Select all of the links then drag into a Spotify playlist.

Listen and enjoy!

Select a few tracks and paste the Spotify track links into the large box. Leave the artist box empty and then click for a compilation.

Super Advanced:
The generator will try to auto detect your region but you can override it and other settings. Create a shortcut to the executable, go to the target in the properties and add the 2 character ISO country code after a space: e.g. PlaylistGenerator.exe GB. You can also modify the maximum number of artists: e.g. PlaylistGenerator.exe GB 49. And even the maximum number of tracks per artist: e.g. PlaylistGenerator.exe GB 49 3. If you modify these then they are displayed in the main window when you first run it.

Thanks to and

“This product uses a SPOTIFY API but is not endorsed, certified or otherwise approved in any way by Spotify. Spotify is the registered trade mark of the Spotify Group.”

MonitorES (Energy Saver) Tool

I came across this tool and think it’s awesome. I’ve been using it for a while and it works well.

MonitorES is a small windows utility that turns off your monitor when you lock your machine. It can also pause all running media programs and play when you return.

Alternatively, there is MonitorES Lite for low end & corporate machines which only has the turn off monitor feature and is also available as an MSI for easy deployment.

Outlook 2010 Email Delayed Send

Ever sent an email then instantly regretted it or hit Ctrl-Enter when you actually meant to hit Ctrl-K (check names)? You could just add a gibberish recipient to a draft email to prevent it sending, but there must be another way. Here is how to add a delay so that an email stays in your Outlook outbox for a minute before being sent.

From the Rules button on the home tab of the Outlook ribbon click Create Rule… then follow the pictures.

Remote Desktop Max Connections Fix

If you have the problem of not being able to log onto a server because it has exceed the maximum number of connections (usually 2) here is an easy fix.

Open a command prompt and type:
query user /server:{YOUR SERVER NAME}

You will get something back like this:

user1   1 Disc none 2011-03-10 20:25
user2 rdp-tcp#121 2 Active 6 2011-03-20 11:29

You can then either ask the users to log off or you can forcibly log them off by typing:

If the query user syntax doesn’t work (e.g. Win XP) you can type:
qwinsta /server:{YOUR SERVER NAME}