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.

WebPageTest.org 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!)

Intro

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.

Wifi

edimax
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:

[code]startx[/code]

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.

VNC

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. 192.168.0.100:1

References

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