While the world originated analog, with physical data such as audio and visual signals that change continuously, we now also make regular use of digital signal processing to turn the continuous analog signals into number samples, often transmitted using binary 0/1 sets. A leading mechanism for sharing binary digital data streams of all kinds is the Internet Protocol. In this set of exercises, you’ll get a chance to connect your Raspberry Pi to a Local Area Network (LAN) and test out performance of the Raspberry Pi on the Internet.
Some choices of interest may include:
- Exercise: Connect a Raspberry Pi to a Wired Ethernet Port
- In many cases in which reliable, high-performing Internet is needed, the best choice is to make use of wired Ethernet.
- Exercise: Connect to a WiFi Network from the Raspberry Pi Desktop
- Recommended if you are running your Raspberry Pi with desktop GUI and have it connected to a keyboard, mouse, and monitor.
- Exercise: Connect to a WiFi Network via the Command Line
- Recommended if you are running your Raspberry Pi headless, that is, without a monitor (NOTE: the Orange Unit chapter 4C: Getting Started with the Raspberry Pi provides instructions on using Real VNC for headless connectivity between a personal computer and a Raspberry Pi, and instructions on adding an Adafruit PiOLED to display the IP address assigned currently to the Raspberry Pi for remote access.)
- Exercise: Unusual Additional Registration Requirements
- Some Wi-Fi networks employ measures to restrict access to enhance security. Here’s one example of setting up a reliable network connection used at the University of Illinois at Urbana-Champaign.
- Configuring Networking on the microSD card (Raspberry Pi Website)
- It is possible to create or further edit a wpa_supplicant.conf file in the boot folder of the microSD card on which the Raspberry OS is installed. You use plain text to enter in the Local Area Network’s identifier (its SSID, which is the Wi-Fi name you often see listed in drop down menus) and passphrase, and therefore can be easily be accessed by anyone who picks up the microSD card. Use this option only if you’re OK with others being able to log into this LAN.
We live today in a wireless society. In some cases, even our phones no longer provide a plug-in for our wired headsets, moving us to instead primarily use Bluetooth headsets. When our mobile phones are located someplace in a building with limited cell service, we can make use of the building’s Wi-Fi connection to get us to that cell service. Our laptops and even many desktops today depend on Wi-Fi Internet access. After all, it’s much simpler and cleaner-looking than yet another wire.
When mobility, flexibility, and simplicity are important, wireless Ethernet connectivity is a solid choice.
But here are some key reasons why wired Ethernet remains the better choice for networking more often than you might think.
- Performance: Wired Ethernet makes use of Cat5 or Cat6 cables that provide synchronous upload and download of data at either 100 Mbps or 1 Gbps. The 802.11a/b/g speeds are improving and can now provide creative forms of synchronous transfers of data at upwards of 54 Mbps. Wired Ethernet provides synchronous communication from a single computer to a switch. Meanwhile, the wireless radio waves are shared by all connected devices simultaneously, thereby changing performance without notice.
- Reliability: Cat5/6 cables are designed to limit interference, and are often installed within walls or ceilings to further improve reliability. While WiFi has improved over the years, it remains susceptible to interference from a range of fixed and dynamic factors.
- Security: While the wireless 802.11 protocol and interconnected devices used to provide network access to Wi-Fi devices have improved significantly, it remains that a wired Ethernet connection is less susceptible to security attacks than wireless Ethernet.
When doing some home improvements many years ago, I used the opportunity to run wired Ethernet to a few locations in each major room of the house. This helps improve performance of all devices, as the high-demand Roku, solar panel interface, and office computer all make use of the wired Ethernet Cat5b cables. And especially at times when many devices are making active use of the network, the 1-Gbps wired Ethernet connection has proved essential when I am teaching or collaborating online from my home office.
When consulted on new construction and Ethernet, I strongly recommend installation of as much wired Ethernet as possible, especially in libraries, schools, and community centers where there will be more statically located networked devices. This both improves performance, reliability, and security for these static devices and reduces demand for the many wireless devices within the space.
What about the Raspberry Pi? While it is capable of both wired and wireless networking, the choice may vary by project.
For basic educational and prototyping activities, especially when close access or mobility is important to work with breadboarding and electronic testing in a range of locations, Wi-Fi continues to be the preferred means of connecting to the LAN. However, when prototyping moves to the next level and is used for ongoing data collection and distribution—for instance, as a soil and weather sensor database system accessible via web server—I move the Raspberry Pi to a waterproof case and connect it to the LAN via an outdoor Cat5 cable. When the Raspberry Pi is used as a multimedia server or a location-based collective networking toolkit, I’ve found it ideal to locate the Raspberry Pi right next to the gateway router, connected via a short Cat5 cable.
When the Raspberry Pi is running headless (without a keyboard, mouse, and monitor), Secure Shell (SSH) is a quick and easy way to connect to and control the microcomputer. The Pi’s microSD card must be edited to enable SSH access within the Raspberry Pi Operating System, but after this, I can connect the Raspberry Pi to a router with a wired Ethernet cable. This will automatically provide it with an IP address that I can use to SSH into the Pi on its very first boot.
Exercise: Connect a Raspberry Pi to a Wired Ethernet Port
- Connect one end of an Ethernet cable to the wired Ethernet port on your Raspberry Pi.
- Connect the other end of the Ethernet cable to an available LAN Ethernet port. Some places where these may be found include:
- An Ethernet port on the wall.
- One of the four LAN ports commonly found on home and small office gateway routers used to connect to the Internet service provider.
- An Ethernet switch that itself connects to a wall connection or to the gateway router for the LAN.
- Most home and small office gateway routers provide a quick guide with login and password information to help you connect to their web servers to determine the assigned IP address for connected devices.
Exercise: Connect to a Wi-Fi Network from the Raspberry Pi Desktop
A GUI is provided for setting up wireless connections with the Raspberry Pi OS. If you are not using the Raspberry Pi Desktop, you can set up wireless networking from the command line in the next exercise.
Wireless connections can be made via the network icon at the right-hand side of the menu bar. If you are using a Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, left-clicking this icon will bring up a list of available wireless networks, as shown below. If no networks are found, it will show the message “No APs found—scanning…” Wait a few seconds without closing the menu, and it should find your network.
Note that on the Pi 3B+, which supports the 5G protocol, wireless networking is disabled for regulatory reasons, until the country code has been set. To set the country code, open the Raspberry Pi Configuration application from the Preferences Menu, select Localisation, and set the appropriate code.
The icons on the right show whether a network is secured or not, and give an indication of its signal strength. Click the network that you want to connect to. If it is secured, a dialogue box will prompt you to enter the network key.
Enter the key and click OK, and then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When it is ready, the icon will stop flashing and show the signal strength.
Exercise: Connect to a Wi-Fi Network via the Command Line
This method is suitable if you don’t have access to the graphical user interface normally used to set up Wi-Fi on the Raspberry Pi. It is particularly suitable for use with a serial console cable if you don’t have access to a screen or wired Ethernet.
Step 1: Get Wi-Fi network details
- Connect your laptop to your Raspberry Pi via serial console and begin a remote terminal session to scan for Wi-Fi networks.
- Using a TTL to USB cable, connect the black TTL wire to a GPIO Ground pin, the white TTL wire to GPIO 14 (TXD or transmit), and the green TTL wire to GPIO 15 (RXD or receive).
- Attach the USB side of the cable to your laptop.
- Adafruit provides a lesson on how to run software in the Mac, Windows, and Linux operating systems to connect your computer to the Raspberry Pi from here.
- To scan for wireless networks, use the command:
sudo iwlist wlan0 scan
- This will list all available wireless networks, along with other useful information. Look out for:
- “ESSID:”testing”” is the name of the Wi-Fi network “testing.”
- “IE: IEEE 802.11i/WPA2 Version 1” is the authentication used. In this case, it’s WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. Visit the FreeBSD manual for WEP hex keys, scrolling down to see the last example on the webpage.
- You’ll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router.
Step 2: Connect to a network through raspi-config
- Once you know the network name (SSID) and password, the quickest way to enable wireless networking is to use the command line raspi-config tool.
- From the Raspberry Pi terminal window, enter:
- Select the Network Options item from the menu, and then the Wi-Fi option.
- On a fresh install, for regulatory purposes, you will need to specify the country in which the device is being used.
- Then set the SSID of the network, and the passphrase for the network.
Exercise: Unusual Additional Registration Requirements
Businesses, schools, libraries, and other organizations use various measures to restrict access to their network to enhance security. This often means that a password is required to access a network, whether wired or wireless; two-factor authentication may also be required. Sometimes, only registered devices can access a network. And sometimes, the level of registration determines what can be done over the network.
At the University of Illinois at Urbana-Champaign, two primary wireless Ethernet networks are available for general use: IllinoisNet and IllinoisNet_Guest. For the most part, IllinoisNet_Guest is used for easy first access to the core technical services. Visitors can use this to create a 24-hour login, while regular users can use this to gain up to 12-month access for certain devices, such as gaming consoles, streaming devices, and your Raspberry Pi. As one example, the following steps will help those who are part of the University of Illinois at Urbana-Champaign system to register their Wi-Fi nodes, such as a Raspberry Pi, to the IllinoisNet_Guest network.
MAC Address Overview
Before we start, let us take a step back and look at how devices are differentiated. In the Orange Unit, we learned how different integrated circuits perform different tasks in a device. For a device to connect to a network, it requires an integrated circuit called a Network Interface Card (NIC). There is a NIC for each type of network connection: Ethernet, Wi-Fi, and Bluetooth. The Raspberry Pi 3 includes all three NICs.
To differentiate between different NICs and different devices, each NIC is assigned a Machine Access Control (MAC) Address. The MAC address is comprised of 6 groups of 2 hexadecimal digits. Hexidecimals contain the numbers between 0-9, but also include the uppercase letters A-F, to give 16 possible digits. Some information about your device is contained in the MAC address, such as the vendor or manufacturer of your device.
The following steps will walk you through registering your device.
First, you will need to find the MAC address of your Raspberry Pi’s Wi-Fi network card. To do so, open a terminal window in your Raspberry Pi and type the following command:
$ ifconfig wlan0
This will output the data related to your wireless network interface. The first line should contain:
Link encap:Ethernet HWaddr XX:XX:XX:XX:XX
Instead of Xs, your MAC address for your Wi-Fi NIC will be printed.
Either write this down or leave the window open, as you will need this information to register.
Next, using your laptop, navigate to http://go.illinois.edu/illinoisnetdevices and log in using your NetID and password. Click the “Manage Devices” button.
Click the “Create” button to create a device account.
Insert the following information for each required field:
- MAC Address: Copy or type the MAC address found in the steps above.
- Device Name: IS401-RaspberryPi
- AirGroup: Leave the box unchecked.
- Account Activation: Now
- Notes: Leave empty unless otherwise needed.
Click “Create.” Restart your Raspberry Pi before attempting to connect to the network.
- Instructions for Real VNC start at step 6 of Exercise: First Boot of the Raspberry Pi OS. ↵
- Raspberry Pi learning resources and documentation are licensed under CC-BY-SA 4.0. This exercise is a remix of the “Wireless connectivity in the Raspberry Pi Desktop” tutorial. ↵
- Raspberry Pi learning resources and documentation are licensed under CC-BY-SA 4.0. This exercise is a remix of the “Setting up a wireless LAN via the command line” tutorial. ↵