Connecting Raspberry Pi to the Internet

Suparna S Nair
Secure and Private AI Writing Challenge
4 min readAug 16, 2019

Udacity Secure and Privacy AI Challenge

In the last article, I walked you through setting up your brand new Raspberry Pi, and connect to it via SSH from your laptop. This story takes you through the steps to connect your Pi to the internet, so that you can download and install packages while doing your IoT projects (Now the fun begins!). In case you missed it, here it is!

Yaay! Now we are all connected!

First Steps

Assuming you have experience in setting up Raspberry Pi and enabling SSH, in order to connect to internet you should have any of the following:

  • A Raspberry Pi with WiFi functionality and a network router to access internet
  • If the Raspberry Pi does not support WiFi, then a network router through which you can access internet via Ethernet cable

Check-list

So, this is an extended check-list for the first article in this series.

  • Raspberry Pi with SSH enabled
  • A Network Router with internet access
  • Two Ethernet cables! (not required if your RPi supports WiFi)
The network router

Connecting Raspberry Pi to internet via Router

If the Raspberry Pi does not support WiFi

  • As a prerequisite, ensure that Raspberry Pi has SSH enabled.
  • Connect the Ethernet cable from Raspberry Pi’s ethernet slot to the Ethernet slot of your network router.
Connect RPi to the router via Ethernet Cable
  • Connect your laptop to the other ethernet slot of the router.
  • Connect Raspberry Pi to the monitor and hook up keyboard and mouse with the Pi.
  • Power up Raspberry Pi. The Graphical interface gets launched.
  • Open terminal from Raspberry Pi and type in:
hostname -I

This will give the IP address of Raspberry Pi for the local area network. Note that this address will be different from the last article, where you have connected the Pi and laptop via Ethernet without a network router.

If the Raspberry Pi supports WiFi

In this case, you do not need an Ethernet cable to access internet. Follow the steps below:

  • Click on the WiFi icon from the task bar (top bar) of the Raspbian Desktop.
  • Select the Wireless network’s name and enter the password. Here you go! Your Pi is now connected wirelessly over the network!
Connect Raspberry Pi over WiFi

Updating your Pi OS via Internet

Now that you have connected your Pi over the local area network, let’s test this by performing an update and upgrade for the OS via terminal

  • Login to Raspberry Pi via SSH using PuTTy
  • Type in:
sudo apt-get updatesudo apt-get upgrade

If you get loads of debug messages in the Raspberry Pi informing you on package updates, congratulations! You have successfully connected your Pi over the internet! 👏 Time to celebrate! 🎉

Updating the Raspberry Pi OS

Connecting Multiple RPis in the network and accessing them from your laptop!

Now that we have successfully connected Raspberry Pi to the internet using a network router, let’s extend this to more Raspberry Pis! Suppose you need to access multiple Raspberry Pi’s from your laptop, how do we achieve this? Extending the previous use case intuitively, you can connect each of the RPis to the ethernet slot of the router, and connect the laptop too, such that all these devices (the Raspberry Pis and the laptop or any other device which has Ethernet card and slot) come under the same network. Here’s how it looks:

Multiple devices connected over the same network

Now you can SSH into each of these Pis (using their IP addresses) from your laptop and also access the internet! 😃

This was pretty simple and straightforward, huh? Keep going! Once you get accustomed to the Raspberry Pi’s environment, updating and installing or even performing complex operations for Raspberry Pi projects would become second nature for you!

In the next series of articles, things get a little more adventurous! I will take you through the steps to install some of the cool packages to train an awesome neural network in your Pi using a concept called Federated Learning.

--

--

Suparna S Nair
Secure and Private AI Writing Challenge

An artist and tinkerer by passion, a software engineer by profession!