Wifi-connect – quick wifi access point to tell a Raspberry Pi about a wifi network

This is all Andrew Nicolaou‘s work. I’m just making a note of it here so others can have a go.

An important part of Radiodan is the way it simplifies connecting a device to a wifi network. The pattern is more common now for screenless devices – Chromecast uses it and ESPs have code patterns for it.

The idea is that if it can’t find a known wifi network, the device creates its own access point, you connect to it on a different device such as a phone or laptop, it pops up a web page for you and you add in the wifi details of the network nearby that you want it to connect to.

Andrew, Dan Nuttall and Chris Lowis wrote the original code – which I wrote up here – and then recently Andrew investigated Resin’s approach, which seems to be more reliable. Resin uses their own platform and Docker images which we’re not using, so Andrew un-dockerised it, and has recently rolled it into the new iteration of Radiodan that we’re working on.

If you want to use it in your own project without Radiodan, here are some instructions. It uses a branch of the Radiodan provisioning code, but just installs the relevant pieces and doesn’t delete anything.

First make sure you have a wifi card with the right chipset – or a Pi3 (scroll down for special Pi3 instructions). Then:

Provision an SD card (this is on Mac OS X)

diskutil list
diskutil unmountDisk /dev/disk2
sudo dd bs=1m if=~/Downloads/2016-02-09-raspbian-jessie.img of=/dev/rdisk2

Put it in the Pi, login, expand the filesystem, reboot and login again.

Checkout the Radiodan code and provision the relevant parts.

sudo apt-get update -y && sudo apt-get upgrade -y
git clone https://github.com/radiodan/provision.git
cd provision
git fetch origin
git checkout -b minimal origin/minimal
sudo ./provision iptables node wifi-connect

reboot. Wait a minute or two and you’ll see a wifi access point called “radiodan-configuration”. Connect to it and a browser window will pop up. Select the wifi network you want to connect the Pi to, add the password and save. Connect back to the wifi network you selected for the Pi and you should be able to ssh to it at pi@raspberrypi.local

For a Raspberry Pi 3, you’ll need to tweak things in order to make it possible for the built in wifi:

sudo apt-get install raspi-config
sudo BRANCH=next rpi-update