UPDATE: Some instructions were updated for later versions of Raspbian.
These instructions are for a Pi Zero 1.3. If you have a Pi Zero W, see: Setup Pi Zero W Headless Wifi.
To connect my Pi Zero 1.3 over WiFi I ordered an adapter from AdaFruit. The white cable in the picture above is a Micro-USB adapter. You can buy it separately or as part of the Pi Zero budget pack.
- Miniature WiFi (802.11b/g/n) Module: For Raspberry Pi and more
- USB OTG Host Cable – MicroB OTG (On The Go) male to A female
The cable is handy for testing and plugging in various devices. Later, if you need a more compact design you can buy a Tiny OTG Adapter.
Before you can get the WiFi to work, you need to connect to the Pi Zero so that you can edit a file. Because there is only one USB port, you need to look at a few options.
Even though it would be convenient to have the adapter plugged in while you set it up, that’s not completely necessary. You would need a powered USB hub, HDMI adapter, keyboard, mouse, etc.
Or you can go through the steps to ssh into the Pi Zero over USB and edit the files from a host computer.
Assuming you are now connected and in a terminal window on the Pi Zero, do the following (these instructions are for a Mac):
Expand the File System
This isn’t directly related to wifi, but if you’ve just setup a new image, the first thing you should do is expand the file system.
- At the command line type:
- Select: 7 Advanced Options
- Select: A1 Expand Filesystem
- Click: OK
Change the Hostname and Password
We are now going to put the Pi Zero on the network. Now would be a good time to change the hostname and password from their defaults.
Assuming you are still in raspi-config:
- Select: 1 Change User Password
- Follow the steps until you are back at the main menu
- Select: 2 Hostname
- Follow the steps to change the hostname (you do NOT need to include .local)
- When you are done select <Finish> at the bottom of the menu
- Select <Yes> when asked if you want to reboot
Remember that now you will need to use the new hostname and password when connecting to the Pi Zero via ssh. So if you renamed your Pi Zero to ‘myzero’ then you would need to login like this (using the new password):
After the Pi Zero reboots:
- Login in again using the new hostname and password as indicated
- Type the following at the command line:
sudo nano /etc/network/interfaces
- Edit the file so that it matches mine (but replace the wpa name and password settings with your network name and network password):
# Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 auto wlan0 iface wlan0 inet manual wpa-ssid "your-network-name" wpa-psk "your-network-password" iface default inet dhcp # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf # allow-hotplug wlan1 # iface wlan1 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
When you are done, save the file (Ctr-X, Yes, Enter).
Shutdown the Pi Zero by executing the following at the command line:
Connect over WiFi
Plug your WiFi Adapter into the USB OTG cable and plug the other end into the data / peripheral port on your Pi Zero (see picture above). Then plug in the power cable. Do that from a wall adapter so that you can prove that the Pi Zero is now wireless.
Give the Pi Zero enough time to boot. Then try connecting via ssh (using the new hostname and password!).
Get the Updates
Once connected over WiFi, the next thing you should do is run some updates:
sudo apt-get update -y sudo apt-get upgrade -y
These instructions were for a specific adapter talking to my Apple router. If you are using something different you may need to do some research into the make and model of your equipment. You may end up needing to install some drivers or update the properties in the /etc/network/interfaces file.
- Raspberry Pi Zero Headless Setup  – shows an alternate way editing the network files and additional info on setting up wireless
About the Author
Mitch Allen works for a robotics company in New England.