Raspberry Pi 3, Pi Zero, and USB WiFi dongle

How to Set up WiFi on Your Raspberry Pi Without a Monitor

  • by Tyler (252)
  • Time to complete: 5 minutes

I'm one of the rare software developers that doesn't have an extra HDMI monitor, keyboard, and ethernet connection ready to go at a moments notice. So in the past, setting up a new Raspberry Pi has been tricky. Fortunately, you can now configure a WiFi connection on the Raspberry Pi without having to first connect to ethernet.

1

If you don't have Raspbian installed, go ahead and install it. Make sure the SD card with Raspbian is in your computer.

2

You'll have to locate the boot directory, on my Mac it's in /Volumes/boot.

cd /Volumes/boot
3

Create a file in this directory called wpa_supplicant.conf. The file should contain the following details:

For Raspbian Jessie:

network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

For Raspbian Stretch and Raspbian Buster:

country=US # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

Connecting to unsecured networks

For wireless networks with no password, use the following:

country=US # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev # Include this line for Stretch
network={
    ssid="YOUR_NETWORK_NAME"
    key_mgmt=NONE
}

With this file in place, Raspbian will move it in /etc/wpa_supplicant/ when the system is booted.

The next step is to boot the Pi and test, but while the SD card is still in your computer I'll mention this now. If you're going to try to connect via SSH, you may need to enable it first. The process is similar to this one.

4

Next, put the micro SD card into the Pi, boot, and your Wi-Fi should be connected!

The wpa_supplicant.conf file should disappear from the SD card's boot directory automatically—so if you don't see it next time, that's normal.

5

If your Pi hasn't connected to Wi-Fi, try these wpa_supplicant troubleshooting tips:

  1. Double-check that the file was written in plaintext, without any special characters.
  2. Double-check that the file has disappeared from your boot directory.
  3. Connect the Pi to a TV or monitor via HDMI to ensure it is booting normally.
  4. If you're using a Raspberry Pi Zero W, make sure you're attempting to connect to a 2.4GHz network (the Zero doesn't support 5G).
  5. If you're using a Raspberry Pi Zero, make sure it's a Raspberry Pi Zero W, not a regular Zero (only the W supports Wi-Fi and Bluetooth).