Nerves, Pi Zero and Edimax EW-7811UN WiFi

How to add an Edimax WiFi stick to a Raspberry Pi Zero and use it with the Elixir Nerves framework.

The Raspberry Pi Zero is a perfect board if you want to build small compact embedded systems with the Elixir Nerves framework. The only caveat is, that this board doesn't contain any form of wireless connectivity. But it is quite easy hack a USB WiFy dongle directly onto the Pi Zero.

Elixir Nerves supports the Raspberry Pi 3 WiFi out of the box and also has support for some USB WiFi modules built into its default Raspberry Pi targets. Sadly the driver for the Edimax EW-7811UN stick is currently not compiled into the Kernel. So if you want to use this dongle in your Nerves application, you have to tweak the Nerves system image.

This tutorial shows you how to solder a USB WiFi dongle directly onto the Raspberry Pi Zero board and how to enable the Kernel driver in a custom Nerves system image.

Connect a WiFi USB dongle to your Raspberry Pi Zero

On the bottom side of the PCB you can find some test pads that are connected to one of the two USB ports of the Raspberry Pi Zero:

Pad USB
PP1 +5V
PP6 Gnd
PP22 D+
PP23 D-
If you crack open a USB WiFi dongle, you can solder the USB connector pads directly to the Pads of the Raspberry Pi Zero, to get a working WiFi interface:

a

With a piece of two sided adhesive tape you can wack the dongle onto the Raspberry Pi Zero PCB. If you don't need to use the four connectors around the composite video output, you can use these two feed the wires from one side of the PCB to the other and put the WiFi stick on the top side of the PCB. In this way the dongle doesn't add much to overall thickness of the Raspberry board.

a a

Compile a custom version of the Nerves firmware

First clone the nerves buildroot scripts and the default system for the Raspberry Pi Zero. Then create a directory in which the custom Nerves system should be built:

mkdir nerves_build
cd nerves_build
git clone https://github.com/nerves-project/nerves_system_br.git
git clone https://github.com/nerves-project/nerves_system_rpi.git
./nerves_system_br/create-build.sh nerves_system_rpi/nerves_defconfig rpi_wifi_out
cd rpi_wifi_out

Add the Realtek 8192C USB device driver to the Linux kernel:

make linux-menuconfig
Device Drivers --->
  [*] Network device support --->
    [*] Wireless LAN --->
      <*> Realtek 8192C USB WiFi

And finally build the custom Nerves system:

make

Configure your Nerves project to use the custom firmware and connect to a WiFi network

export NERVES_SYSTEM_CACHE=none
export NERVES_SYSTEM_COMPILER=local
export NERVES_SYSTEM=../nerves_build/rpi_wifi_out

In your Nerves project, you still reference the system by its original name rpi . When you now compile your firmware, it will be build with the custom base system from the nerves_build/rpi_wifi_out directory.