A slice of Pi - Networking the Raspberry Pi
In this lesson, students will attach their Raspberry Pi to a network so that they can create a multiplayer Minecraft session. This lesson leads nicely into the next session in which students learn to program in Python using Minecraft Pi edition.
Learning Objectives:
Curriculum Mapping:
KS2:
KS3:
What is Minecraft Pi:
Minecraft: Pi Edition is a version of Minecraft that’s designed to work on the Raspberry Pi. The Pi edition has the added feature that you can program it using either Python or Java.
What you will need:
* This setup is designed for 4-8 students working in pairs (ideal for an after-school club). You may need to add more routers / Raspberry Pis depending on the size of your class. Note: If your want to do this with a whole class, look out for my blog post on networking the Raspberry Pi (coming soon!)
** This lesson assumes that students already have some experience of using the Raspberry Pi and that they have already installed the Raspbian Operating System. To find out how, click here
Starter:
Instruct students to setup their Raspberry Pis and hand out a copy of the Minecraft Pi installer files (along with installation instructions) for students to install. You can find the instructions here: http://pi.minecraft.net
Activity 1 (Installing & getting to know Minecraft Pi):
After all of the students have installed Minecraft Pi edition onto each of their Pis, give them a little time to play around with Minecraft to allow them to get to know the controls.
Activity 2 (Networking the Raspberry Pis):
After about 20 minutes or so of playing around, invite the students to the front of the class and explain to them that they are going to network their Raspberry Pis.
Explain that every computer has a unique IP address and that this unique address enables it to communicate over a wide area such as the Internet. Explain that the IP address is made up of four numbers (ranging from 0 to 255) and separated by 3 dots. Show the following example on the board:
192.168.0.1
Explain that the IP address can be either entered in manually or can be configured automatically using a Dynamic Host Configuration Protocol (DHCP) Server. Explain that, because most routers have a built-in DHCP server, the router will automatically assign a unique IP address to each of the Raspberry Pis once they are connected to the network. Ask the class what they think the benefit are of using a DHCP server – look for answers such as “You don’t have to manually assign the IP address for every device on the network” and “The DHCP will ensure that every device has a unique IP address” etc.
Note: All modern routers should have a built-in DHCP server and this service will normally be turned on by default. The Raspberry Pi will automatically send out DHCP request as soon as it is connected to the network and therefore should be assigned an address automatically without any user intervention.
Extension: At this point, you could also discuss other significant network terms such as default gateway, subnet mask, broadcast, DNS, MAC address etc., however, this is not necessary to complete this lesson.
Next, give each student a CAT 5 lead and ask them to connect one end to their Raspberry Pi and the other end to a spare port on the Router. Once the students have done this, instruct them to test if their device has successfully connected to the network by checking to see if it has a valid IP address.
To check that the Raspberry Pi has a valid IP address, open an LX Terminal session:
Learning Objectives:
- Describe the hardware needed to connect stand‐alone computers into a local area network, including hub/switches, wireless access points
- Explain the term IP addressing
Curriculum Mapping:
KS2:
- Understand computer networks including the internet; how they can provide multiple services, such as the world wide web; and the opportunities they offer for communication and collaboration
KS3:
- Understand the hardware and software components that make up computer systems, and how they communicate with one another and with other systems
What is Minecraft Pi:
Minecraft: Pi Edition is a version of Minecraft that’s designed to work on the Raspberry Pi. The Pi edition has the added feature that you can program it using either Python or Java.
What you will need:
- * 1 x Router (e.g. Linksys WRT120N Maplin)
- 2 – 4 x Raspberry Pis (with monitor, keyboard and mouse)
- 2 – 4 x 4gb SD Cards (With Raspbian OS installed **)
- 2 – 4 x CAT 5 leads
- Minecraft Pi installation files
* This setup is designed for 4-8 students working in pairs (ideal for an after-school club). You may need to add more routers / Raspberry Pis depending on the size of your class. Note: If your want to do this with a whole class, look out for my blog post on networking the Raspberry Pi (coming soon!)
** This lesson assumes that students already have some experience of using the Raspberry Pi and that they have already installed the Raspbian Operating System. To find out how, click here
Starter:
Instruct students to setup their Raspberry Pis and hand out a copy of the Minecraft Pi installer files (along with installation instructions) for students to install. You can find the instructions here: http://pi.minecraft.net
Activity 1 (Installing & getting to know Minecraft Pi):
After all of the students have installed Minecraft Pi edition onto each of their Pis, give them a little time to play around with Minecraft to allow them to get to know the controls.
Activity 2 (Networking the Raspberry Pis):
After about 20 minutes or so of playing around, invite the students to the front of the class and explain to them that they are going to network their Raspberry Pis.
Explain that every computer has a unique IP address and that this unique address enables it to communicate over a wide area such as the Internet. Explain that the IP address is made up of four numbers (ranging from 0 to 255) and separated by 3 dots. Show the following example on the board:
192.168.0.1
Explain that the IP address can be either entered in manually or can be configured automatically using a Dynamic Host Configuration Protocol (DHCP) Server. Explain that, because most routers have a built-in DHCP server, the router will automatically assign a unique IP address to each of the Raspberry Pis once they are connected to the network. Ask the class what they think the benefit are of using a DHCP server – look for answers such as “You don’t have to manually assign the IP address for every device on the network” and “The DHCP will ensure that every device has a unique IP address” etc.
Note: All modern routers should have a built-in DHCP server and this service will normally be turned on by default. The Raspberry Pi will automatically send out DHCP request as soon as it is connected to the network and therefore should be assigned an address automatically without any user intervention.
Extension: At this point, you could also discuss other significant network terms such as default gateway, subnet mask, broadcast, DNS, MAC address etc., however, this is not necessary to complete this lesson.
Next, give each student a CAT 5 lead and ask them to connect one end to their Raspberry Pi and the other end to a spare port on the Router. Once the students have done this, instruct them to test if their device has successfully connected to the network by checking to see if it has a valid IP address.
To check that the Raspberry Pi has a valid IP address, open an LX Terminal session:
Then, type in the command: ip addr. You should see similar to the following output:
If everything has been setup correctly, your Raspberry Pi should have a valid IP address. In the screenshot above, the Raspberry Pi has been configured with the following IP address: 192.168.0.90
Next, instruct the students to test the network further by pinging the router. You can obtain or manually change the routers IP address by logging into the router itself (See your routers instruction manual). Usually, by default, the IP address of the router will be 192.168.0.1
To ping the router:
Open an LX Terminal session then type in the command: ping followed by the IP address of your router. In our case, the students typed in ping 192.168.0.1 See below:
Next, instruct the students to test the network further by pinging the router. You can obtain or manually change the routers IP address by logging into the router itself (See your routers instruction manual). Usually, by default, the IP address of the router will be 192.168.0.1
To ping the router:
Open an LX Terminal session then type in the command: ping followed by the IP address of your router. In our case, the students typed in ping 192.168.0.1 See below:
This image above shows a ping between a Raspberry Pi and the router which, in this case, has an IP address of 192.168.0.1 The –c 10 option sends 10 packets and the echo replies are shown above with the time taken.
Activity 3: (Multiplayer Minecraft Pi)
Finally, once all the students have successfully networked their Raspberry Pis, ask one of your students to launch Minecraft Pi edition on their Raspberry Pi and start a new game. Once Minecraft has loaded, ask the rest of the class to also launch Minecraft on their Pis however, this time, to “Join Game”. Finish the lesson with a bit of Multiplayer Minecraft!
Hint: When the other students click on “Join Game”, they will need to select “Steve Pi” - Don’t ask me why :)
Resources:
http://pi.minecraft.net - Installation instructions and download link for Minecraft Pi edition.
http://www.ocr.org.uk/qualifications/by-subject/computing/raspberry-pi/ - OCR Raspberry Pi: Getting started tutorials.
http://www.raspberrypi.org/help/quick-start-guide/ - Raspberry Pi quick-start guide.
http://www.stuffaboutcode.com/2012/05/raspberry-pi-setting-static-ip-address.html - How to setup a static IP address for your Raspberry Pi.