FlightAware Discussions

Raspbian Image - Howto Enable & Configure WiFi Before First Boot

How To Enable WiFi on Raspbian Image Before First Boot

NOTE: This method does NOT apply to Piaware SD card image. For Piaware SD card image, you have to edit file /boot/piaware-config.txt

 

All the steps below should be done while the microSD Card is still in the Laptop/Desktop’s card reader after writing the Raspbian image.

If you want your RPi to connect to local network/internet using a wired connection to router, do not enable WiFi, and skip this procedure.

If you want your RPi to connect to local network/internet using WiFi, enable Wifi as given below.

Use only one connection at a time, either wired or WiFi. It is not recommended to use both simultaneously.

STEP-1: After image is written, and while the microSD Card is still in the Laptop/Desktop, open File Explorer (Windows) or Finder (Mac), and open the microSD card.

NOTE:
If you have used Etcher, it will automatically eject the microSD card after writing the image.
Physically remove the microSD card or USB adapter and plug it back into the computer before you carry-out steps below.

STEP-2: The microSD card will appear with name “boot” as shown in screenshot below.

STEP-3: Open the drive named “boot”. This will open the /boot folder of PI24. In this folder create a new text file, as shown in screenshot below

STEP-4: Open the text file using Notepad (Windows) or TextEdit (Mac)
In the opened text file, copy-paste following text:

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

network={ 
ssid="YOUR_SSID" 
psk="YOUR_PASSWORD" 
}

Replace:

  • CA by two letter code for your country e.g. GB for UK, US for USA, DE for Germany, FR for France, SE for Sweden, CH for Switzerland, NL for Netherland, AU for Australia, NZ for New Zealand, etc etc. (click here for complete list)

  • YOUR_SSID by your router’s wifi ssid

  • YOUR_PASSWORD by your router’s wifi password.

STEP-5: Save file.

STEP-6: Change the name of file from “New Text Document.txt” to “wpa_supplicant.conf”

NOTE: If your Desktop/Laptop does not show file extensions, the newly created file “New Text Document” will NOT show .txt extension at the end, as shown in screenshot below.

In the case of hidden extension .txt , even after you change file name to “wpa_supplicant.conf” its full name will be “wpa_supplicant.conf.txt” with “.txt” not visible. If the file has a hidden extension .txt, it will not enable wifi.

Configure Windows File Explorer to show file extensions as shown in the screenshots below:

Now change the name of file “New Text Document.txt” to “wpa_supplicant.conf” , as shown in screenshot below:

To Reconfigure WiFi at later stage:

The file wpa_supplicant.conf which you created in /boot folder is moved to folder /etc/wpa_supplicant, and after booting the Pi, you will NOT find it in /boot folder.

For editing the WiFi config later, open config file by following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf  

 

NOTE:

You should also enable SSH while the microSD card is still in the card reader of Desktop/Laptop after writing the Raspbian image to microSD card. Please see this post:

For Beginners - How-to SSHto RPi - Setup Putty in Windows

 

 

1 Like

You should add a note that SSH needs to be enabled as well, otherwise WiFi only doesn’t make that much sense.

The country code should be highlighted in red, took me forever to figure out that is what was needed. In older versions of raspbian that was not needed.

@foxhunter

Thanks for pointing out. Note added at the end of post.

@hellhound604
Cannot make “Country” red color. Flightaware Forum does not have provision to colour the text

2 Likes