Posts: 2
Joined: Mon Sep 26, 2016 3:42 pm

Headless WiFi configuration

Tue Sep 27, 2016 6:20 pm


I am building a mobile game that uses the Pi as a HW accessory (data feeder). I'd like to configure the Wifi settings (AP + pwd) on the Pi in headless mode. Has anyone tried to do that before? What good solutions are available out there?


User avatar
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Headless WiFi configuration

Tue Sep 27, 2016 7:39 pm

By way of explanation...

The Raspberry Pi normally uses a MicroSD card formatted with two partitions, called boot, and root. The root filesystem (if you're using Raspbian, the most common case) is an ext4 filesystem that contains the entire normal Unix/Linux filesystem, mounted as "/" after startup, while boot is a DOS-style FAT filesystem, that is used only during booting, and ends up mounted as "/boot" after the system is running. When you attach the MicroSD card from a Raspberry Pi to a typical "desktop" computer (Mac or Windows), you'll get read/write access to the boot partition, while the root partition is normally invisible - it can only be mounted by installing extra drivers and fiddling around.

Also, the SSIDs and passphrases for WiFi networks are normally kept on the Raspberry Pi in the file /etc/wpa_supplicant/wpa_supplicant.conf.

My apologies if I'm overexplaining and you already know these bits; they make this next part understandable...

Quoting from the article on this site titled, "The latest update to Raspbian":
• If a wpa_supplicant.conf file is placed into the /boot/ directory, this will be moved to the /etc/wpa_supplicant/ directory the next time the system is booted, overwriting the network settings; this allows a Wifi configuration to be preloaded onto a card from a Windows or other machine that can only see the boot partition.
So, if you do the initial configuration of a Raspbery Pi, you should be able to then copy the file /etc/wpa_supplicant/wpa_supplicant.conf into /boot, where it will be accessible when the MicroSD card is mounted in a PC or Mac, where you'll be able to change the contents as needed.

I'm not actually certain whether the file gets copied or moved (yes, I know it says "moved"), as I've not had a reason to try it myself. But if it does get removed from /boot in the process, you can simply keep a copy there with a different name, say, wpa_supplicant.base, and then edit that as needed and make a copy named wpa_supplicant.conf when you're done.

The file has the network's SSID and passphrase in a section like this:

Code: Select all

	psk="Your Network's Passphrase"
You can add multiple entries like this, so you should be able to make the Pi connect to any of several WiFi networks, as needed.

User avatar
Posts: 5
Joined: Wed Oct 03, 2018 8:32 am

Re: Headless WiFi configuration

Fri May 31, 2019 11:51 am


I used Raspberry Pi 3 Model B+ for my project. In case you are interested, I can share my files (it's not yet finished though, have no time to get back to it). I also tried to create a Pi-based console emulator which actually looked like NES Classic.


Re: Headless WiFi configuration

Fri May 31, 2019 12:01 pm

The OP has not been here since 2016 (you can tell by clicking on his name).

There are many many questions on setting up the Pi in headless mode (WiFi, ssh, USB connect) on the forum now and a full set of documentation at https://www.raspberrypi.org/documentation/

Given the operating system has changed since the answer - the answer is technically wrong as it does not mention that the country value now has to be included in the file.

Please check before opening old old threads.

Return to “General discussion”