← Notes

March 8, 2021

Set up WiFi on a headless Raspberry Pi

Set up WiFi on a headless Raspberry Pi


Tags: raspberry pi wifi

Let's say you want to set up a headless Raspberry Pi, but you can't or don't want to connect it to an Ethernet cable. In order to connect to the Pi wirelessly it has to know to which network it has to connect to. This can be easily accomplished by creating a file called wpa_supplicant.conf in the root directory of the SD card. Copy the following inside the file and change the values accordingly.

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

network={
  ssid="NetworkName"
  psk="StrongPassword"
}

You can find the list of all 2 letter country codes here.