Getting hooked up to a local network and the wider internet is easier than you might think, as long as you have all the right bits…
Everyone (and, it seems, everything) is online these days, and that means that if you want your Raspberry Pi to do anything “interesting” – even if that’s just browsing Facebook – you need to get it networked. As with everything Raspberry Pi, it’s made as hard as possible, to ensure you learn as much as possible along the way! No, actually, the only complication is that Raspbian doesn’t hide any of the nitty gritty of networking from you, combined with the need to add wireless dongles to all Raspberry Pi models except the latest Pi 3, which comes with built-in wireless and Bluetooth.Raspbian now supports easy GUI- based wireless connections – so modern!
Let’s talk wireless adaptors. The first thing you need to do before buying a wireless adaptor is to check whether the one you already have or plan to get will work with your Raspberry Pi. That’s where http://elinux.org/ RPi_USB_Wi-Fi_Adapters comes in – this is a huge list of both verified adaptors and those that cause issues.
The good news is that a huge range works with Raspbian, thanks to its Linux kernel. It comes with built-in support for a large number of adaptors. Because of the way Raspbian is built, an adaptor that doesn’t work with Raspbian might work with another Linux OS, such as Arch or OpenELEC, because of the particular version of the Linux kernel they ship with. You can confirm whether a USB device is working correctly – other than the Raspbian wireless being enabled – by opening a terminal and typing lsusb , then pressing Return. This provides a list of all your USB devices, and one should be something that sounds like your USB Wi-Fi device.
A second command, iwconfig provides a list of working wireless adaptors connected to your Pi. This offers a slightly more direct confirmation that the USB dongle is connected and working.
An easy way to avoid any worry is to buy an official Raspberry Pi Foundation Wi-Fi dongle. Designed to work with all Raspberry Pis and Raspbian, this eliminates any worries. There’s also the added point
that it helps fund the Foundation, too. You can get more details from www.raspberrypi.org/products/usb-wifi-dongle/.
TCP AND YOUR SORE IP
If you’re new to PCs and networking, then the sudden talk of IP numbers and the like might be very confusing. Let’s just say that local networks and the internet all use a very clever system called TCP/IP. On a pedantic level, that’s two – yep, two – communications protocols: TCP, alias Transmission Control Protocol; and the IP part, alias Internet Protocol. You don’t really need to know anything about it, other than this: it assigns a unique number to each and every device on the internet. This enables messages to get to and from your devices, finding their way to the right place.
Each device gets an address made up of four numbers, separated by full stops. Each number can be between 0 and 255. So, typically, an address would be something like 192.168.0.1 or 192.168.100.23. Generally, your home and business network has its own IP range – the broadband router you use to connect to the internet creates this automatically using something called a DHCP server, and uses Network Address Translation, or NAT, to route messages to and from your local network and the wider internet. See, it does get awfully complicated very quickly!
Usually, when we talk about IP addresses, it’s when you want to know the address of a device or server on your network or on the internet, or you want to give a device a specific address. You won’t have to know much more than this.
Back in the day, you had to edit text files to configure your wireless dongle, but these days, Raspbian has been fully updated to provide a GUI for connecting to any wireless network. How civilised! Wi-Fi connections can be made via the familiar network icon at the right-hand end of the menu bar. If a working Wi-Fi dongle is plugged in, left-clicking this icon brings up a list of available Wi-Fi networks, as shown in the picture on this page. If no networks are found, it shows the message “No APs found – scanning…” Wait a few seconds more without closing the menu, and it should find your network.
The icons on the right show whether a network is secured or not, and its signal strength. Click the network that you want to connect to; if it is secured, a dialog box appears, prompting you to enter the network key. Do so and wait a couple of seconds. The network icon flashes briefly to show that a connection is being made; once it is ready, the icon stops flashing and shows the signal strength.
Older versions of Raspbian provided a Wi-Fi Config tool on the desktop. There’s no reason why you should encounter an older version at this point, but if you do, it’s no more complicated than running it and then using its Scan button to locate your desired wireless network.
We should also mention wired networks while we’re here. All Model B Raspberry Pis have a wired network connection called an Ethernet port. This uses an Ethernet cable to connect to a standard router. A wired connection remains the most reliable and the fastest option for transferring files and getting an internet connection. In terms of having to do anything, you don’t – just plug in the cable, and as long as it’s connected to a working router that already has an internet connection, Raspbian is allocated an IP address.
Most Ethernet ports provide two status LEDs (the original Pi did not; these status lights were moved to the board itself). The green confirms a working connection (any blinking shows activity), while the amber one announces a full-speed 100Mbs connection (or 10Mbs if it’s off).
It’s also worth noting that the Linux kernel can happily handle multiple network connections over different network adaptors. This means you can connect to a different network or the same one via both a wired connection and wireless at the same time – the kernel’s TCP library happily balances transfers over both the adaptors. It also means you can remotely connect to the Pi via either assigned IP address.
As with USB Wi-Fi dongles, it’s also possible to add wired Ethernet adaptors via a USB port – a full list of verified and problem adaptors can be found at http://elinux.org/RPi_USB_ Ethernet_adapters. While this doesn’t make total sense for a Model B board, it may be exactly what you need when it comes to the Model A or the Pi Zero.
The subject of networking can get highly involved, so we’re going to leave things with a standard IP connection.
With the addition of the embedded dual wireless/Bluetooth abilities in the Pi 3, Raspbian was updated to support Bluetooth out of the box. Prior to this, you had to “hack” in the Bluetooth support, with the command sudo apt-get install –no-install- recommends bluetooth and, once it was installed, use sudo service bluetooth status to enable it.
While this was a simple case of installing a manager tool, it’s far neater having it around by default. If you use a smartphone you’re likely to have used Bluetooth, with all the Bluetooth speakers, keyboards and headsets available these days, but if not, the good news it that’s it’s far simpler than connecting to a wireless network. This goes for all Bluetooth devices, but you first need to make them “discoverable” – this enables other Bluetooth devices to then attempt to connect with them, at which point you have to allow those connections or not, as the case may be. Left-click the Bluetooth icon in the top-right of the Raspbian desktop, select Make Discoverable, then choose Add Device to pull up a list of nearby Bluetooth devices. Select the correct one and click Pair. With keyboards and devices, you often have to enter a code on the device to finalise the connection. You’ll want to ensure that you choose Stop Discoverable afterwards.