How to Configure the Raspberry Pi 3 and BeagleBoards for Wireless Connections
Contributed By DigiKey's European Editors
2016-06-24
The low cost Raspberry Pi single board computer has been a tremendous success, providing system designers with an affordable controller board that can be programmed in industry standard Debian Linux. What the Pi has lacked so far has been integrated wireless capabilities. The Raspberry Pi A and B, and the Pi2 all needed an external Wi-Fi or Bluetooth dongle in order to create wireless links. Raspberry Pi's latest version of the board, the Raspberry Pi 3, adds a 64-bit quad core ARM® Cortex®-A53 processor with the frequency boosted to 1.2 GHz and adds both Wi-Fi and Bluetooth Smart 4.0 for a similar price as the earlier boards.
This opens up a huge opportunity for using the board in the Internet of Things (IoT), connecting easily to a router or gateway to deliver data from sensors or provide control from a smartphone or Internet-connected terminal. The quad-core processor also provides more processing power for analyzing data locally and running a wider range of control algorithms locally, as well as providing faster responses.
Many of these IoT applications do not use a screen, and so the boards are configured via a ‘headless’ approach. This uses the Ethernet connection to a terminal or a serial console cable. The software for making this connection is included in the standard software image that is included with the Raspbian operating system on an SD card that slots into the board.
Raspbian is based on Debian Linux and regularly updated with libraries from the Raspberry Pi Foundation and installed via the NOOBS installer application on the board. However, the Foundation has deliberately made it straightforward to replace the root partition on the SD card with another ARM Linux distribution so that other operating systems can be used. These can be downloaded onto the card from a PC or laptop to be used with the board before a connection is made.
Figure 1: The Raspberry Pi 3 board adds Wi-Fi and Bluetooth Smart to the same board as a 1.2 GHz quad-core ARM Cortex-A53 processor.
With Raspbian, the first step for configuring the wireless link is to scan for the local networks. This is done with the sudo command, with the format
: sudo iwlist wlan0 scan
This returns a list of all the Wi-Fi networks as well as the security connections and other details.
To connect the board, the name of the chosen Wi-Fi network will be listed under the ESSID (Extended Service Set Identification). This will also include the authentication method being used, which could be WEP, WPA or WPA2.
This gives the data needed for the configuration file. This is accessed with the command:
: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
At the bottom of the file are the Wi-Fi settings that need to be changed to the local network.
In the network= block, the ssid="" entry needs to be changed to the local network, and the psk="" changed to the Wi-Fi password.
The configuration file is then saved by pressing CTRL+X and then Y on the keyboard and enter to confirm. The configuration file will normally be updated within a few seconds and try to connect to the Wi-Fi network. If the Wi-Fi does not connect then a reboot maybe required with sudo reboot. Once the connection has been successful, it can be verified with the ifconfig command:
: ifconfig wlan0
If the inet addr field returns with an IP address, then the connection is successful and the IP address is useful for connecting to the board remotely.
Connecting a Bluetooth peripheral
One of the advantages of the Raspberry Pi 3 is the built-in Bluetooth capability. This allows a Bluetooth peripheral to be easily connected to the board for building IoT networks.
The best method for connecting a Bluetooth device is using the bluetoothctl command from the command line interface that is included in the Raspbian operating system.
For other operating systems, a Bluetooth module can be installed using the command:
: sudo apt-get install pi-bluetooth
Running bluetoothctl requires the Bluetooth chip to be switched on with:
: power on
Which will deliver a list of devices that have previously connected to the board. Using the
: scan on
command, it enters discovery mode to find nearby Bluetooth devices.
It is then necessary to switch on an agent to handle the pairing of the peripheral with the board:
: agent on
The MAC address of the peripheral is necessary to perform the pairing, and this is usually printed on the peripheral and entered using the command:
: pair MAC Address
There may also be a prompt for a password for peripherals such as a Bluetooth keyboard.
If the peripheral is to be used regularly, it can be added to the trusted devices list with the command:
: trust MAC address
Then a connection is made using the command
: connect MAC address
BeagleBone Green
Other popular low cost single board computers such as the BeagleBone Green do not have wireless embedded in the board and so require an adaptor or dongle to be configured to provide a Wi-Fi connection. This can vary depending on the dongle used. However, these are generally handled through the operating system, which for the BeagleBone Green is version 3.8 of the Debian Linux distribution.
Figure 2: The BeagleBone Green board uses a 1 GHz Sitara processor using an ARM Cortex-A8 core
One issue with a Wi-Fi connection on the board is that the ground and power planes of the Grove ports are next to the USB port where a Wi-Fi adaptor would be plugged in. This dampens the signal and leads to a poor connection. For many headless embedded applications these ports may not be needed and can be switched off using the device tree. The command for this is found in the uEnv.tx file.
Another approach is to use a short USB extension cable so that the Wi-Fi adaptor can be placed a short distance away from the board to avoid the problem.
The board also needs to have sufficient power for the Wi-Fi adaptor, and this needs a 5 V supply with at least 1 A of current.
In either case, the first step is to connect the USB port on the board to a PC using SSH and a kernel upgrade ensures that the latest libraries are available for the Wi-Fi adaptor:
: cd /opt/scripts/tools/
: ./update_kernel.sh
The kernel image should download and install automatically, and then reboot.
Adding a small script to automatically switch on the adaptor when the board boots helps ensure that all the different adaptors can be used. This is handled with
: cd ~
: ntpdate -b -s -u pool.ntp.org
: apt-get update && apt-get install git
: git clone https://github.com/adafruit/wifi-reset.git
: cd wifi-reset
: chmod +x install.sh
: ./install.sh
This script automatically switches the adaptor on when the board is booted, then running the iwconfig command brings up a list of available networks and the ESSID that is needed for the /etc/network/interfaces file to specify the appropriate connection.
Configuring the file uses the nano editor command:
: nano /etc/network/interfaces
This will show a commented configuration block for Wi-Fi:
# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
# wpa-ssid "essid"
# wpa-psk "password"
Removing the comments and replacing the ESSID and password with the relevant network name and password will configure the adaptor. The connection can be tested manually using the ifup wln0 command, which will return the IP address of the connection, which again is helpful for addressing the board remotely. Rebooting the board should now bring up the script to switch on the adaptor and configure the network connection.
Conclusion
The addition of Wi-Fi and Bluetooth Smart to the Raspberry Pi 3 board opens up a new range of embedded, headless applications for developers with a simple configuration process. This allows the boards to be easily accessed remotely from PCs, smartphones and cloud services. However, users of other boards can still use wireless adaptors to provide the same level of capability.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of DigiKey or official policies of DigiKey.