Home Interests Raspberry Pi

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

No monitor, keyboard, or mouse? No problem.
howchoo   (467)
August 8, 2023
9 minutes

Share

You'll Need 1

What you'll need
Interests
Series
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
linux • 12 guides
pi • 92 guides
wifi • 2 guides

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 configure a WiFi connection on the Raspberry Pi without having to first connect to ethernet, a monitor, keyboard, or mouse.

1 – Put the Raspberry Pi OS SD card into your computer

If you don’t have Raspberry Pi OS installed, go ahead and install it. Make sure the SD card with Raspberry Pi OS is in your computer using an SD card slot or SD card USB adapter.

How to Install Raspberry Pi OS on Your Raspberry Pi
Get the new official Raspberry Pi OS on your Pi.

 If you're using Raspbian (an older version of Raspberry Pi OS) for some reason, thats okay too!

The SD card will mount as a drive/directory on your computer called boot. Open the drive using Finder (Mac) or Explorer (Windows).

In Finder on Mac, you can also select Go > Go to Folder from the menu bar and enter /Volumes/boot.

3 – Add your wpa_supplicant.conf file

Open a plaintext editor such as Notepad (Windows) or TextEdit (Mac) and create a new file. Add the following to the file for Raspberry Pi OSRaspbian Stretch, or 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
}

If you’re using Raspbian Jessie or older, use this instead:

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

Finally, save the file. If you’re using TextEdit on Mac, you’ll need to go to Format > Make Plain Text in the menu bar before saving. Make sure the filename is exactly wpa_supplicant.conf (remove .txt if it gets added).

Connecting to unsecured networks

To connect to wireless networks with no password on your Raspberry Pi, 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, Raspberry Pi OS will automatically move it in /etc/wpa_supplicant/ when the Raspberry Pi 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 – Put your SD card in the Raspberry Pi, boot, and connect

Next, put the micro SD card into the Pi, boot it, 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 – Troubleshooting

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).

If you’d like to monitor your network performance with your Raspberry Pi, check out guide on setting up a network monitor with a Raspberry Pi.

NEXT UP

How to Run a Minecraft Server on the Raspberry Pi

A whole world trapped inside your Pi.
howchoo   (467)
December 7, 2023

There are several ways to go about running a Minecraft server on the Raspberry Pi. In this guide, I’ll cover how to install Nukkit—a cross-platform Minecraft server that’s super easy to set up on the Raspberry Pi. This server should work with PCs, consoles, and tablets running Minecraft 1.14. I’ll be using a Raspberry Pi

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore