Creating a 4G router using a Raspberry Pi and a mobile phone

A few days ago these workmen were using cutting machinery dangerously close to my broadband cables:

Shortly after this picture was taken – bang! No internet! They cut the cables while doing their work!

Two adults working from home on back to back video calls, one high-schooler also on video classes, and one primary-schooler with streaming classes – all suddenly disconnected from the world!

That afternoon we huddled around the kitchen table, mobile phones on with hotspots enabled to get through the rest of the day – but this wouldn’t work for regular use.

The broadband company said it wouldn’t be fixed for weeks due to how badly everything was damaged; the pavement would have to come up! I had to think of a pragmatic solution.

In this article I’ll go through the steps I took to completely swap my home broadband for a Raspberry Pi and a spare mobile phone – and show the results!

Continue reading

Setting up an Android phone as a WebPageTest agent

Pixel 2 connected to a raspberry pi

Running detailed website performance tests is often necessary to understand how a website is experienced by an end user in order to identify opportunities for improvements. gives us the ability to run these tests from all over the world – the public instance even gives us access to real devices, so we can check how a site works across different browsers on different versions of different operating systems on different real devices!

In my previous articles I explained how to easily set up your very own private, autoscaling, WebPageTest server. This private instance creates test agents in AWS, dotted around AWS regions, which can emulate a mobile browser; this uses the device emulation in Chrome to throttle network, CPU, memory, etc and change the available screen size.

While this mobile emulation is simple to set up and use, sometimes an emulator isn’t enough; device-specific edge cases, operating system limitations, and performance on a real device may need to be validated to get confidence that everything works as expected in the real world.

In this article I’ll show you how to set up an Android phone as your own WebPageTest agent to connect to your private WebPageTest server, controlled by a Raspberry Pi!

Continue reading

RaspberryPi 101: Part #3 – Uses #1: Media PC

(Apologies in advance for what will be an image-heavy post!)


XBMC (originally the XBox Media Centre) is an award-winning free and open source (GPL) software media player and entertainment hub for digital media. Raspbmc is a distribution of XBMC tailored specifically for the raspberry pi.

Using it you can easily stream audio and video from your local network, USB devices, and the interwebs for the price of a ‘pi, the cables needed, and an SD card.

Raspbmc Installer for Windows

Download the installer

There are various download options including getting the full ISO yourself and manually doing the install. The easiest and recommended option is to download the bootstrap installer which ensures you get the correct, and latest, version of XBMC and can also set up networking prior to the install, which saves the need to configure this manually from the pi itself.

The download options are all on the raspbmc download page

Run the installer

Insert the SD card you’re going to install raspbmc to; be sure you select the correct device in the setup screen as it does wipe the entire device during installation.

xbmc - windows installer - 1

Set up networking

I think this is a great touch; allowing you to configure your network settings (wired or wireless) as part of the install process, so that your pi should just work after plugging in the power and SD card

xbmc - windows installer - 2 - network config

Plug it in, Go Go Go!

Once the bootstrap installer has been written to your SD card, put the SD card into your pi, plug it into the HDMI port and turn on the pi. If it supports HMDI CEC, your TV should automagically turn on and change to the new HDMI input.

2013-03-04 08.20.06

CEC (consumer electronics control) is the control protocol in HDMI which allow systems which run over an HDMI port to interact with the host device, either via the host’s remote control for input or transmitting similar input in order to control the host.

Automatically turning on your TV and changing to the correct HDMI source when you turn on you pi whilst running Raspbmc is one example of the device controlling the host.

Interacting with Raspbmc on your TV just using the TV remote control is an example of the host’s remote controlling the device.

This makes what could be a complex and nerdy device available to those other family members who may not be as nerdy as yourself; no need to ssh in to start a service to download a plugin, or VNC over to browse your network, or plug in a keyboard and mouse to search for some music. Pretty clever stuff!

After a lengthy wait to download the full latest XBMC distro (I presume) and setup your system you should be presented with the default XMBC home screen

2013-03-04 08.19.39

From here you can do oh so many things! Stream your music from your network or attached USB device, stream video likewise (y’know, bog standard media centre stuff), if you have a PVR backend then you can use it to view live TV, the EPG, configure recording and pause of live TV.

2013-03-04 08.18.23

You can install a selection of plugins for audio, video, themes, and other things like weather apps. If you choose to install video add onsyou can find such awesome plugins as Wired and TED (and Anime Vice.. there’s some weirdass cartoons on that one):

 2013-03-04 08.17.03

2013-03-04 08.16.49

2013-03-04 12.23.14

These can effortlessly stream HD video to your TV, which I think is pretty impressive for something so small and cheap!

The weather app is pretty decent too, except I could not for the life of me figure out how to change it from Fahrenheit to Centigrade.

 2013-03-04 08.17.32    

ssh is running by default, but the default pi password doesn’t seem to be "raspberry". As such, I had to connect it to my tv to set the password (under Programs -> Add-ons -> System Configuration -> Password Management). I believe the default settings are username “root” password “root”

In summary

This is a fantastic use for a pi, especially if you don’t already have a media centre setup. However, as you can read from my Year of 101s #2 : Smart TV posts, I already have a media centre built into my TV for this sort of thing; it can already install apps (the TED app works great, as do all of the catch up tv ones) so I wouldn’t use Raspbmc myself.

Raspberry Pi 101: Part 2b – More setup

Before I get onto XBMC, here’s a little extra setup I’ve done with my rPi. Remember, I’m currently using the raspbian distro, so don’t go trying the same steps when you’re using RISC or something else.


The edimax wifi dongle I bought needed a little massaging to get working; unfortunately I could’t set it up directly from the command line and it appears that currently the only solution for configuring wifi within raspbian is to start the GUI desktop:


and punch the wifi config desktop icon. This will open the wifi config gui and allow you to scan and setup your connection.

Once this is done a restart should still keep the wifi connectivity

SSH via Connectbot sans password

I like to use connectbot to ssh into many things and I’m lazy so don’t fancy typing passwords if I don’t need to.

As such, here’s how to set up your raspberry pi with authorized key ssh access:

Generate a key

Install Connectbot from the android store

Generate a new key from the “manage keys” page
connectbot generate key

Copy the public key to clipboard
connectbot copy to clipboard

SSH into your raspberryPi from your connectbot instance using the username “pi” and password “raspberry” (unless you changed it from the default)

Paste the key into a new authorized_key file (there isn’t one created by default):

[code]cd ~
mkdir .ssh
chmod 700 .ssh[/code]

Then use the menu soft key to select “paste” after typing “echo”:

[code]echo [paste clipboard contents] >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys[/code]

Now you can exit the session and should be able to log back in without needing to enter a username or password. Whoop.


Just for the hell of it (and because I’ve become interested thanks to the blog posts at the end of this article) I’ve set up VNC on the pi. To do this is as easy as

[code]sudo apt-get install tightvncserver[/code]

and then start the server using something like

[code]sudo vncserver :1 -geometry 1024×768 -depth 24[/code]

You can then connect using your VNC viewer of choice to {the rPi’s IP}:1, e.g.


A great couple of posts on SSH and tunnels using the rPi here and here

RaspberryPi 101: Part #2 – Setup

So part 1 was a quick intro to what a pi is and what it can do. This post is about getting and setting yours up.


1. Get a raspberryPi

You can get one from a few places these days, but the big UK reseller is element14/Farnell
element14 farnell

2. Get a linux distro

As mentioned in the last post, you can get a few different operating systems to run and the recommended ones to start with are on the raspberrypi website

3. Put the distro on a suitable SD card

3.1 Writing the image to the SD card

The methods for doing this differ depending on your dekstop OS;

  • Mac and Linux you can use the existing “dd” and “df” commands to check and write the image to the SD card
  • For Windows you need to use the Win32DiskImager “used for writing images to USB sticks or SD/CF cards on Windows”

3.2 BerryBoot

Steps 2 and 3 can actually be shortcut by either buying an SD card with a distro already installed, or installing BerryBoot bootloader which bootstraps your installation to give you the easiest possible route to installation:

Berryboot is OSS and you can even dig into the source over on github

Random tangent #1: HDMI CEC
BerryBoot supports the fantastic HDMI CEC which “is an HDMI feature designed to allow the user to command and control up-to ten CEC-enabled devices, that are connected through HDMI, by using only one of their remote controls”; this means that you don’t even need to connect a keyboard for most of the berryboot setup process and can just use your tv remote.

There’s more info over on elinux about just how important CEC is for HDMI capable devices and writing software for these devices.

Want to start understanding the CEC messages? Check cec-o-matic

This is the same feature that XBMC uses to allow full and simple navigation of the media centre features just using your remote control – more on XBMC later.

Checkpoint! Base Installation Complete

You’ll now have a version of linux (or RISC OS) running on your pi. If you’ve chosen RISC then I can’t really help you, since the last time I used it was playing games on my uncle’s computer as a young lad (check out those vids – classic 90s gaming at its “best”).

Anyway. From here on in I’ll assume you’ve gone with Raspbian. Wheezy should be pretty much the same I think.

Starting it all up #1: Raspbian

Plug it all in

Put the SD card in, the HDMI cable to your tv/monitor, the network cable in, your USB keyboard which you’ll need for the initial installation (unless you’re berrybooting with it’s CEC awesomeness), and finally the power cable; there is no power switch on the pi so once the cable is plugged in you’re running.

You should see the initial configuration screen where you can setup the locale and turn on SSH (do so).

Then you can choose to get to a terminal or boot into a desktop environment.


With raspbian this is just a case of enabling ssh from the config menu; after that you can ssh in from another machine on the same network. If you don’t know the IP address of your pi, either plug it in to an HDMI capable display and execute “ifconfig” or just check the devices attached to your router from the router admin screen.

more info on pi ssh


Setting up a bluetooth keyboard may not be much use if you’ve already got ssh running and want to access the terminal only, however if you’re accessing the pi directly you will either need to plug in a USB HCI device (keyboard/mouse) or set up bluetooth.

1. Get a supported device

There’s a list of confirmed working devices over on elinux.

I went for the dinky little TOPDIGI UA01 Bluetooth USB Dongle from Amazon
TOPDIGI UA01 Bluetooth USB Dongle from Amazon

2. Setup bluetooth on the pi

2.1 install bluetooth software

[code]pi@raspberrypi ~ $ sudo -s
root@raspberrypi:/home/pi# apt-get install bluez[/code]

2.2 scan for nearby devices

[code]root@raspberrypi:/home/pi# hcitool scan[/code]
Your device should appear in those found; use the MAC in the following steps.

2.3 pair your pi to the device

[code]root@raspberrypi:/home/pi# bluez-simple-agent hci0 00:11:22:33:44:55
RequestPinCode: 0000
Enter PIN Code: Release
New device (/org/bluez/3964/hci0/dev_00_11_22_33_44_55)[/code]

Obviously your MAC will be different to the dummy one I’ve used..

2.4 trust the paired device so it’ll auto connect in future

[code]root@raspberrypi:/home/pi# bluez-test-device trusted 00:11:22:33:44:55 yes[/code]


Since I’m bored with swapping the ethernet cable from my tv to get this on the network (the switch has no spare ports.. too much living room tech..), I’ve just ordered an Edimax EW-7811UN 150Mbps Wireless Nano USB Adapter
Edimax TEEEENY TINY wifi adapter

Portable Power

Since I’m bored with swapping my phone charger over to power the pi, I’ve just ordered a PowerGen 5200mAh External Battery Pack High Capacity Power Bank Charger

I’ll report back on how they work out for me soon. I should find that having a fully portable pi will allow me to mess around with it even more!


That’s it for this one! You’re now set up with a Linux computer, bluetooth keyboard, and ssh. You can do with this whatever you would do with a normal low power distro (Puppy, DSL, #!.. or is it !#.. hmm..), but you can also interact wiht the outside world via GPIO.

Next Up

I’ll be installing XBMC and having a play. I play, so you don’t have to. See? I care.

Year of 101s: March – RaspberryPi

Part #1 – Intro

I’m committing to doing 12 months of “101”s; posts and projects themed at beginning something new (or reasonably new) to me. January was all about node development awesomeness. February was (sort of) all about Samsung Smart TV apps.

March is going to be about me playing with the raspberryPi!

So what’s a RaspberryPi?

The Raspberry Pi is a credit-card sized, single-board, low cost, barebones computer, intented to be mainly used within the classroom as a cheap way to teach programming.

There are more than one version of the Pi and I’ll be referring to Model B during these posts, as it’s what I have.


A bare printed circuit board (PCB) contains:

  • a double USB port,
  • HDMI and composite video outputs,
  • an ethernet port,
  • SD slot,
  • headphone jack,
  • and a micro usb sized power socket (so chargers for most modern android or blackberry phones will work, as will a USB to MicroUSB cable plugged into a PC or even your TV)

It’s pretty low-power as it’s just got:

  • 512MB RAM,
  • 32-bit 700MHz ARM processor,
  • but – a GPU capable of decoding 1080p HD video!


Since the Pi runs from the OS loaded on to the SD card, then it’s up to your level of hackery skill to determine what software you’re going to run. Check out the wiki page to see what OSs are being, or have already been, ported to run.

The most popular ones are most likely those recommended by the fine people at, namely: a version of Debian (Raspbian), RISC OS, or a version of Arch Linux.

Raspbian is easy to pick up if you’ve ever played with Linux before.


Media centre
There’s a fantastic port of XBMC called Raspbmc which allows you to easily make a Media Centre PC (I’ll cover this in a later post).

Arcade machine
Play really old games on a really underpowered device. YES!

High Performance Computing (HPC) environment
Want to get some more power? Buy a truck of Lego and 64 raspberyPis and network them together in a HPC stylee!

Loads of others!
Srsly. (At least) One guy has sent his almost into space. Amazeballs.

It’s all up to your imagination and time; I have one but not the other so let’s see what I come up with this month..!

How do you use it?

Knowledge of either Python of C++ seems to be the main way to get into working with the device; python is the recommended language for general development most likely due to it reading like a high level language and not needing compilation; just edit, save, execute.

Next up

Setting up the thing; getting an OS on it, getting a bluetooth keyboard working, setting up SSH – that sort of thing.