Put the Raspbian SD card into your computer
If you don’t have Raspbian installed, go ahead and install it. Make sure the SD card with Raspbian is in your computer.
Navigate to the boot directory
You’ll have to locate the boot directory, on my Mac it’s in /Volumes/boot.
cd /Volumes/boot
Add your wpa_supplicant.conf file
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:
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:
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.
Put your SD card in the Raspberry Pi, boot, and connect
The next step is to put the micro SD card into the Pi, boot, and then try to connect via WiFi.