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 OS, Raspbian 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.