Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardopereira/25b3916710d95a54d78b9f4193b1f272 to your computer and use it in GitHub Desktop.
Save ricardopereira/25b3916710d95a54d78b9f4193b1f272 to your computer and use it in GitHub Desktop.
How to setup a usb wifi dongle on the Raspberry Pi Model A+

Rationale

The Raspberry Pi Model A+ has just a single usb port, so getting the wifi configured has to done by editing /etc/network/interfaces from a command line prompt.

These instructions assume the Raspbian OS on the SD card, and a usb wifi adapter that supports the RTL8192cu chipset, since the current Raspbian has built-in support for it.

Before the first boot

  1. Put a keyboard in the usb slot
  2. Connect the HDMI slot to a monitor
  3. Power up
  4. Login as user pi
  5. Do any desired initial setup at the raspi-config screen, which appears automatically
  6. Don't reboot just yet

Editing /etc/network/interfaces

  1. Save the original file
cd /etc/network
sudo cp -ip interfaces interfaces.org
  1. Use the wpa_passphrase command to generate the wpa-psk value for the interfaces file (unless you already know it, of course)

Since the wpa-psk value is a long, random string, and there's no easy way to copy-and-paste in the raw terminal, use these commands to capture the passphrase output and append it to the interface file:

sudo chown pi:pi interfaces
wpa_passphrase ssidName passphraseString >> interfaces
  1. Edit the passphrase information in the interfaces file

The wpa_passphrase output looks like this:

network={
	ssid="ssidName"
	#psk="passphraseString"
	psk=a0b1c2 ... a0b1c2
}
  

which is a little different than what should be inside the interfaces file:

	wpa-ssid "ssidName"
 	wpa-psk "a0b1c2 ... a0b1c2"
  

so use vi or nano to make those edits and save the file (note that in the Pi default keyboard layout, the double-quotes character is at [SHIFT] 2, where the at-sign normally is).

Here's a diff of what the edited file should look like:

diff interfaces interfaces.org
< iface wlan0 inet dhcp
< 	wpa-ssid "ssidName"
< 	wpa-psk "a0b1c2 ... a0b1c2"
---
> iface wlan0 inet manual
  1. Full shutdown

Finally, reset the file permissions, and issue the shutdown command, and unplug the Pi from the power source.

sudo chown root:root interfaces
sudo shutdown -h now

Next (and all future) boot

This time, without the keyboard and monitor connections, power up the Pi like this:

  1. Unplug the keyboard from the usb slot
  2. Plug the wifi adaptor into the usb slot
  3. Plug in the power source

The Pi should be accessible on the local network, at the ssid specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment