Now that Raspberry Pi 3 has been released with wireless capabilities including Wi-Fi and Bluetooth, I thought I’d write a quick guide in order to get up and running. This guide includes setting up the Wi-Fi via the graphical user interface (GUI) and command line (CLI), connecting a Bluetooth keyboard, and connecting a Bluetooth speaker to play audio. The following examples will also work with Raspberry B+ and Raspberry Pi 2 using universal serial bus (USB) dongles.
Setting up Wi-Fi via the Graphical Interface
This process is probably the most effective method of connecting to your Wi-Fi and also the quickest. First of all, before we get started, please make sure you are running the latest Raspberry Pi operating system; if you’re not sure, then you can head to the Downloads section on the Raspberry Pi website. Follow these steps:
1. In the Desktop environment locate the network icon in the top right hand side and click on the icon to see the list of available Wi-Fi networks to connect to (Figure 1).
2. Select your Wi-Fi SSID in the drop down list (Figure 2).
3. You will be prompted to enter your Wi-Fi password into the text box, so go ahead and do so (Figure 3).
4. Finally, click ok and you will be connected to your Wi-Fi. You should now see your signal strength displayed in the upper task bar on the right (Figure 4).
5. You should now be connected to your Wi-Fi successfully; test your connection by opening up the web browser.
Setting up Wi-Fi via the Command Line Interface
This method is suitable for those who don’t have access to the GUI normally used to setup Wi-Fi on the Raspberry Pi. It’s especially suitable for those with a serial console cable if you don’t have access to a screen or wired Ethernet. No additional software is required; everything is already included on the standard Raspberry Pi image.
First thing you need to do is scan for local wireless networks using the command sudo iwlist wlan0 scan . This will list all available Wi-Fi networks including all sorts of other useful information (Figure 5).
1. Locate the name of your Wi-Fi network in the list; this will be listed next to ESSID.
2. Under the ESSID you should also see your authentication method, which could look like the following IEEE 802.11i/WPA2 Version 1. In my case the authentication method is WPA2, which is the newer and more secure method; this quick guide will work with both WPA and WPA2. You will also need the password for your Wi-Fi. If you don’t already know this, it is usually located on the reverse side of your modem/router.
3. Now you need to add your Wi-Fi settings to the wpa-supplicant configuration file. Type the following in the command line to the configuration file: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf. Go to the bottom of the file and add the following Wi-Fi setting, adding your setting in the quotation marks.
Save the file by pressing CTRL+X and then Y on the keyboard and press enter to confirm. At this point, the wpa-supplicant configuration file will normally notice within a few seconds when a change has occurred and it will try to connect to the Wi-Fi network. If the Wi-Fi does not connect then a reboot maybe required with sudo reboot . Once your Wi-Fi has connected successfully you can verify it by typing ifconfig wlan0; if the inet addr field has an IP address in it then it has successfully connected (Figure 6).
Connecting a Bluetooth Keyboard
The best method for connecting a Bluetooth device is using the bluetoothctl command from the common line interface. There is a GUI application called blueman, but this is not stable on the Raspberry Pi and will cause it to crash.
If you are running the latest Raspberry Pi OS, then all the software has already been installed. If not, then you can simply type the following to install the Bluetooth module: sudo apt-get install pi-bluetooth . Once installed, follow these next steps to pair with your Bluetooth keyboard:
1. Run the Bluetooth program by typing bluetoothctl.
2. Turn on the Bluetooth, if not already on, by typing power on.
3. Enter device discovery mode with scan on command if device is not yet listed in devices.
4. Turn the agent on with agent on.
5. Enter pair MAC Address to do the pairing between devices.
6. You maybe prompted to enter a pass code on the Bluetooth keyboard; if so, type this on the keyboard and press enter.
7. You will need to add the device to a list of trusted devices with trust MAC Address.
8. Finally, connect to your device with connect MAC Address.
Note: For a list of Bluetooth commands type help in the command line (Figure 7).
Connecting a Bluetooth Speaker
Before you get connected to your Bluetooth speaker, you will need to install Pulse Audio and its associated Bluetooth module. Pulse Audio is a sound server that receives audio input from multiple channels and filters them through to one single output or sink, as it’s known. Needless to say, go ahead and install it by typing the following in the command line: sudo apt-get install pulseaudio pulseaudio-module-bluetooth . Once installed give the Raspberry Pi a quick reboot to make sure everything is in order before we start: sudo reboot .
Now that everything we need to connect to the Bluetooth speaker is installed, you can follow these steps in order to connect. The process is the same as connecting to a Bluetooth keyboard (Figure 8):
1. Turn on the Bluetooth speaker and enter discovery mode
2. Open up the command line terminal on the Raspberry Pi and run bluetoothctl
3. Power on the Bluetooth device: power on
4. Turn the agent on: agent on
5. Scan for devices: scan on
6. Pair with your Bluetooth speaker pair MAC Address, at this point there should be no pass code to enter
7. Add the new Bluetooth speaker to the list of trusted devices: trust MAC Address
8. Now finally connect to the Bluetooth speaker: connect MAC Address
Now that you are connected to the Bluetooth speaker, you can test the connection by opening up the web browser and playing a YouTube video or something similar.