If you have a Raspberry Pi 3, WiFi is built into the Pi, if you have a Pi2 or earlier model, then you'll need a wifi dongle. You can check to see if your wifi dongle is compatible here. You may want to use an USB WiFi dongle, then see here.
NOTE: In order to use the WiFi on the Raspberry Pi, you will need to first configure the WLAN Country via raspi-config
. It’s under menu 5 Localisation options in raspi-config
. You can start raspi-config
from the RetroPie
menu in EmulationStation or from the command line with sudo raspi-config
.
There are 5 main methods to configure Wifi:
- Wifi Module
- Connecting to Wifi Without a Keyboard
- Manual Configuration (Interfaces)
- Manual Configuration (WPA_Supplicant)
- WICD-Curses
WiFi Module
You can access this from the Retropie menu in emulationstation (you can also access it from option 3 in the RetroPie setup script):
It will open into this menu:
Choose your SSID from a list:
Type your Wifi Password (You may need to wait a bit after you finish for the configurations to save)
After it's done configuring you should see your wifi info in the original menu:
Connecting to WiFi Without a Keyboard
If you wish to connect to wifi without needing an extra keyboard you can add a file to the boot partition of the sd card called wifikeyfile.txt
place your network details here (note only works on WPA networks)
ssid="NETWORK_NAME"psk="NETWORK_PASSWORD"
You can then access the wifi module and select the option to "Import wifi credentials from /boot/wifikeyfile.txt
"
Connecting to WiFi Without a Keyboard
Starting with Raspbian Stretch, loading the wifikeyfile from the setup script is not necessary.
Create a file called wpa_supplicant.conf
in the boot partition using the following template. (This will be moved at boot to the /etc/wpa_supplicant directory
).
country=USctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1# RETROPIE CONFIG STARTnetwork={ ssid="your_real_wifi_ssid" psk="your_real_password"}# RETROPIE CONFIG END
Make sure to include the RETROPIE CONFIG ...
lines as shown to ensure that the RetroPie-Setup wifi configuration module will be able to cleanly edit/delete your configuration if you wish to change it later.
Wifi will not start up if you have an hard wired ethernet connection. After disconnecting the ethernet cable you'll need to reboot to get Wifi started.
If you want ssh to be enabled by default as well you can create a blank file called ssh
in the boot partition too. This is a 'flag' file and will be deleted during boot after ssh is enabled.
Manual Configuration (Interfaces)
sudo nano /etc/network/interfaces
WPA/WPA2
auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0auto wlan0iface wlan0 inet dhcp wpa-ssid "NETWORK_NAME" wpa-psk "NETWORK_PASSWORD"
wireless-power off
at the end if you have issues with your wifi dongle turning off and on a lot and not being able to maintain a connection.WEP
auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0auto wlan0iface wlan0 inet dhcp wireless-essid NETWORK_NAME wireless-key NETWORK_PASSWORD
Open Network
auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0auto wlan0iface wlan0 inet dhcp wireless-essid NETWORK_NAME wireless-mode managed
Hidden SSID
auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0auto wlan0iface wlan0 inet dhcp wpa-ssid "NETWORK_NAME" wpa-psk "NETWORK_PASSWORD" wpa-scan-ssid 1
Static IP
The following only applies to Raspbian Jessie
You can use the default /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto loiface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug wlan1iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/dhcpcd.conf
and add at the top modifying it for your own router and IP address:interface wlan0 static ip_address=192.168.0.120/24 static routers=192.168.0.1 static domain_name_servers=8.8.8.8
interface eth0 static ip_address=192.168.0.120/24 static routers=192.168.0.1 static domain_name_servers=8.8.8.8
sudo reboot
for changes to take effect.
on reboot (if configured correctly) your wifi will be working.
Manual Configuration (WPA_Supplicant)
Taken from the Raspberry Pi Foundation here:
This method is suitable if you do not have access to the graphical user interface normally used to set up WiFi on the Raspberry Pi. It is especailly suited for use with a serial console cable if you don't have access to a screen or wired Ethernet network. Also note that no additional software is required; everything you need is already included on the Raspberry Pi.
Getting Network Details
To scan for WiFi networks, use the command sudo iwlist wlan0
scan. This will list all available WiFi networks along with other useful information. Look out for:
ESSID:"testing"
. This is the name of the WiFi network.IE: IEEE 802.11i/WPA2 Version 1
. This is the authentication used; in this case it is WPA2, the newer and more secure wireless standard which replaces WPA1. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise; for WEP hex keys see the last example here. You will also need the password for the WiFi network. For most home routers this is located on a sticker on the back of the router. The ESSID (ssid) for the network in this case istesting
and the password (psk)testingPassword
.
Adding Network Details to Raspberry Pi
First you'll need to ammend /etc/network/interfaces
to point to wpa-supplicant if it isn't already:
auto loiface lo inet loopbackiface eth0 inet dhcpallow-hotplug wlan0auto wlan0iface wlan0 inet manualwpa-roam /etc/wpa_supplicant/wpa_supplicant.conf#The following line specified in /etc/network/interfaces will activate and configure each 'default' network in wpa_supplicant.conf with DHCP upon a successful connection to an access point (this line needs to be here for wpa-roam)iface default inet dhcp
Open the wpa-supplicant
configuration file in nano:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Go to the bottom of the file and add the following:
network={ ssid="The_ESSID_from_earlier" psk="Your_wifi_password"}
The following are different ways of configuring your network depending on what encryption your router is configured to.
WPA/WPA2
network={ ssid="NETWORK_NAME" psk="NETWORK_PASSWORD"}
WEP
network={ ssid="NETWORK_NAME" key_mgmt=NONE wep_tx_keyidx=0 #this forces it to use wep_key0 wep_key0=YOURWEPKEY}
Open Network
network={ ssid="NETWORK_NAME" key_mgmt=NONE}
Hidden SSID
network={ ssid="NETWORK_NAME" # it can be any encryption type, just make sure to add the "scan_ssid=1" line after your settings. key_mgmt=NONE scan_ssid=1}
At this point,wpa-supplicant
will normally notice a change has occurred within a few seconds, and it will try and connect to the network. If it does not, either manually restart the interface with sudo ifdown wlan0
and sudo ifup wlan0
, or reboot your Raspberry Pi with sudo reboot
.
You can verify if it has successfully connected using ifconfig wlan0
. If the inet addr
field has an address beside it, the Pi has connected to the network. If not, check your password and ESSID are correct.
WICD-Curses
Note that this may cause a small amount of background cpu usage, which can stop the CPU from scaling to lowest frequency.
you first need to install it with sudo apt install wicd wicd-curses
and then type wicd-curses
in the terminal to open it.
(of course you'll need to be connected by ethernet to install it)
Navigate to your wireless network and Press the RIGHT
arrow to configure your wifi
check automatically connect to this network (by pressing enter) and type in your wifi password where it says "key" press F10
to save and then press SHIFT+c
to connect and press Q
to exit back to the terminal.
There are some noted issues with the daemon using some CPU and preventing the Pi from scaling to lowest frequency, so if that's the case you can remove wicd-curses by typing sudo apt remove wicd-curses
and proceed to setup your wifi using method 2 or 3.
You may want to use an external Wifi dongle: maybe your pi case is blocking or slowing the signal (with a metal case it's pretty common), for instance.
The easiest way is to first configure wifi with the internal controller, using one of the above methods.
Plug your dongle, reboot, and make sure it's connected using ifconfig
: it should appear as wlan1, and have an IP address.
Then, disable the onboard wifi by editing /boot/config.txt
and adding dtoverlay=pi3-disable-wifi
.
That's it :)