Headlessly setting up a Raspberry Pi Zero Wireless
On Pi Day (3.14), Microcenter had the Raspberry Pi Zero Wireless on sale for $3.14, so naturally I had to pick one up, with a microSD card. But once I got home, I quickly realized that I had no mini-HDMI or micro-USB adapters, so I had no way to set it up. Fortunately, Raspbian has an official way to set up SSH and WiFi. However, it doesn't quite work.
Flashing Raspbian
Following the official guide makes this straight forward. Download Raspbian (I used desktop with recommended software
), then use Etcher to flash it to the SD Card.
Enabling SSH
This part is also quite easy, and works as expected. Following the documentation, you simply need to put a file called ssh
at the root of the boot partition. If you're on Windows, this is the only partition accessible. Once the Pi boots, it will remove the file and enable SSH.
Connecting to WiFi - maybe
Raspbian also gives you a way to connect to WiFi, in a similar way to enabling SSH. On the boot partition, create a file called wpa_supplicant.conf
with the following contents:
network={
ssid="Network Name"
psk="WiFi Password"
}
Raspbian will move the file to /etc/wpa_supplicant/
when it boots, which should let the Pi connect to the given WiFi network. In practice, I wasn't able to convince the Pi to connect this way. While the file was moved correctly, it never recieved an IP address from my router, and I couldn't diagnose the problem further since it was headless. Maybe this will work for you, but I had try another way.
Update 2019-04-07
After more searching, I found a StackExchange answer, that found Raspbian now required additional configuration in wpa_supplicant.conf to connect to WiFi:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
country=US
update_config=1
network={
ssid="Network Name"
psk="WiFi Password"
}
With this new section included, the Raspberry Pi Zero successfully connected to my network. Further fiddling with /etc/network/interfaces
was not required.
Conecting to WiFi - definitely
Instead, I had to modify some other files on the Pi's root partition. Since Windows can't read ext4 filesystems, you'll need access to an operating system that can, like Linux. If you don't have a Linux box around, you can run it from a flash drive too. Make sure the SD card is mounted and open /etc/network/interfaces
(on the card, not the computer) and add the following:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "Network Name"
wpa-psk "WiFi Password"
Now the Pi should connect to the WiFi after it boots. Since you have SSH access, you can go ahead and configure the Pi as you like.