Last Updated on Sep 2, 2020

Currently there are two Raspberry Pi types which come with built-i WiFi modules: the Raspberry Pi 3 and the Raspberry Pi Zero W. I’ll show you how to use them “headless”.

If you don’t have a display to connect the Pi to set it up, or you’ve ordered a Pi Zero W without the mini-HDMI adapter, HDMI cable and USB OTG cable for an USB keyboard, you can still use your Pi’s built in Wifi to connect to your home WiFi router, and reach the Zero W via SSH, using the IP address the router has assigned to it via DHCP.

Ho do I enable SSH?

In November 2016 the Raspberry Pi foundation started to ship the official Raspbian OS images with SSH disabled by default. There’s an easy workaround though, put a file named “ssh” to the /boot/ partition of the fresh Raspbian installation. The boot partition is visible under Windows too. The “ssh” file needs to be without any extension, so “ssh.txt” will not work, it has to be purely “ssh”.

How do I connect to my WiFi router?

Most people have passworded WiFi networks at home, but even if you don’t, how would the Pi Zero W know to which WiFi network should it connect?

Again we will use the /boot/ partition which is visible in Windows, too.

You’ll need to create a file called “wpa_supplicant.conf”, and put your home WiFi’s credentials into the file. When the Pi Zero W boots, it will check for this file, and if it finds it, it will automatically copy it to it’s proper place in a WPA Supplicant’s config directory /etc/wpa_supplicant/wpa_supplicant.conf

If you use Raspbian Stretch, you’ll need to paste in this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
	ssid="Haper"
	psk="hellohello"
	key_mgmt=WPA-PSK
}

After the reboot, the Pi should automatically connect to your home WiFi router, get an IP address assigned, and since we have enableed SSH on the Zero W, you can SSH to this IP address, and proceed to configure the Pi Zero W as you wish.

Remember to use the “sudo raspi-config” tool to enable SSH server persistently. This is the menu option you need to use:
5 Interfacing Options > P2 SSH > Enable?

Enjoy your headless Pi!

This tutorial has been revised on: 2017-Oct-10
Tested on OS image: 2017-09-07-raspbian-stretch-lite.img