Using a Classroom Computer as Screen and Keyboard for the Raspberry Pi
In settings where students have laptop or even desktop computers available, it may be preferable to use them rather than a separate screen, keyboard and mouse. For a tinkerer at home, it's easy to use the VNC server that comes with the Raspberry Pi operating system in place of screen and keyboard. For a classroom full of students each with their own Raspberry Pi and laptop or desktop computer, making sure each student connects to his own Raspberry Pi is a challenging problem, but itispossible. You will likely need the help of your school's information technology staff.
What follows assumes that you have a robust wireless network accessible from your
classroom, that your Raspberry Pi computers have onboard wireless adapters (all modern
full-size ones do) and that you will connect the classroom computers to the Raspberry
Pis wirelessly.
Install RealVNC Viewer
The first requirement is that the RealVNC Viewer be installed on the classroom computers that will connect to the Raspberry Pis. This may be a job for your school's information technology staff depending on how your classroom computers are configured and managed. You can the RealVNC viewerfor free, for Windows, MacOS, and Linux. It's available in the Apple App Store for the iPad and in the Google Play Store for Android tablets. If your school uses Chromebooks, the process may be more complex. Instructions on how to use RealVNC on a Chromebook can be found on the . If your Chromebooks will run Android apps, be sure to see the note at the bottom of that page.
Configure a "Headless" Raspberry Pi OS Image
You will probably make a master image of the Raspberry Pi operating system and duplicate it onto multiple microSD cards, one for each student. You must configure the master image for headless operation, that is, operation without keyboard, mouse, or monitor. That's very easy with the current Raspberry Pi OS (Bullseye). You enable VNC and set the resolution using the Raspberry Pi configuration program, Raspberry> Preferences > Raspberry Pi Configuration. VNC is enabled in the Interfaces tab and the resolution is set in the Display tab. You want to set the "Headless resolution" option. There are instructions for configuring older versions for headless operation; find them with your favorite search engine. Important:you must set the resolution for headless operation to the same as the resolution of
your classroom computers for best full-screen operation.
Configure DHCP and DNS
You will assign a name to each Raspberry Pi. Make them short, like "pi01" and "pi02" and so on until you've named all of them. The names should start with a letter and then contain only letters or digits. Use lowercase letters. With a label maker or just a pen, make labels small enough to stick on top of the Ethernet jack. (Writing directly on the jack with a felt-tip doesn't work; it rubs off easily.)
The real magic comes from configuring the DHCP (dynamic host configuration protocol) and DNS (domain name system) servers. Every network device has a built-in identifier called a MAC address. (That's short for medium access control.) You will need to know the MAC addresses of each Pi; they're all unique. You can do that by opening a terminal window and typing ip link show followed by the enter key.
The screenshot shows typing the command and a sample result. To find the MAC address for the wireless adapter, look forwlan0. In that group of data, look forlink/ether. The MAC address is six pairs of hexadecimal digits separated by colons, shown in
the third circled item in the screen shot.
Make a list of each Pi, its name, and it's MAC address, like this: pi01 dc:a6:32:f3:73:46
You, your IT staff, or perhaps the district IT staff, can use that list to configure DHCP so that it assigns an IP (Internet Protocol) address to each Pi when it's started up and associates the correct name with each pi.
The other part of the magic is something called thedomain suffix search list. If a name with no dots is entered into an Internet address, the operating system tries to resolve an address by appending a suffix from the domain suffix search list. For example, if your school is schoolhouse.k12.us, that first Pi might have an address of pi01.schoolhouse.k12.us, but we want the students to be able to type just "pi01." That will work if the domain suffix is set to "schoolhouse.k12.us." Some browsers send a string that doesn't look like a complete URL off to a search engine. There's often a configuration setting to prevent that. Adding "http" should also work, like http://pi01.
It might happen that your school doesn't have its own domain name. That's the case with the Cobb County School District, for example; all the schools are in the cobbk12.org domain. If two schools in a district set up that way each name their Raspberry Pis pi01, etc, there will be name conflicts. The solution is to use subdomains. Continuing with the Cobb example, we might have pi01.tapp.cobbk12.org and also pi01.mceachern.cobbk12.org. Presto! No more name conflict. Of course, the domain suffix search list must now contain an entry with the subdomain.
If You Can't Set DHCP and DNS
In a big district with centrally-managed DHCP and DNS you might find the IT staff
unable (i.e.unwilling) to set up DHCP and DNS as described above. There is another way. It will be more trouble in the long run, and possibly less robust, but it is quite likely to work with no help from the IT staff with the possible exception of getting the RealVNC viewer installed on the classroom computers.
The Raspberry Pi OS supports a mechanism called multicast DNS (mDNS) that does not rely on a central server. To use mDNS, you will have to boot each student microSD card and change the host name to the corresponding Pi name. You change the host name by clicking the Raspberry, selectingPreferences, thenRaspberry Pi Configuration.
Click the Change Hostname button, type the new host name, and click OK once in the
popup and again on the Raspberry Pi Configuration box.
The big difference between this method and the one above is that using DHCP and DNS attaches a name to the physical Raspberry Pi but this method attaches a name to the microSD card. You must set up the cards each time you re-flash them and you can't easily give a student a different card. However, you no longer need as much IT support.
If you've set up the cards this way, students connect to their Raspberry Pis by using
the name followed by ".local" so, pi01.local.
When using this method, the domain suffix search list is not used.
Getting Students Started
When students first start working with the Raspberry Pi using VNC, they should do
the following:
Power up the Raspberry Pi and give it time to boot up.
Start the VNC viewer program. It is not necessary to enter an email address or otherwise complete a registration process.
Type the name of the student's Raspberry Pi in the address box and press enter.
When the connection is made, an Authentication box (below) pops up. The user name is "pi" (lowercase) unless changed, and the password is "raspberry".
If you do not want students to change their passwords, they may check the "Remember password" box. If so, they will not have to enter the password when they connect again later.
Have Each Student Change the Raspberry Pi Password (optional)
If you are concerned that students may connect to a Raspberry Pi other than their
own, you can ask them to change their passwords after they first connect. To change
their passwords, students should do the following:
Log in as described in "Getting Started" butdo notcheck "Remember password."
ClickRaspberry > Preferences > Raspberry Pi Configuration
In the Preferences screen, click the "Change password" button.
Type the new password twice, click OK in the password box, then click OK again in the configuration box. The password is now changed.
The student can log off, log back on, and this time click "Remember password" in the
Authentication box.
Transferring Files
Files the students create on the Raspberry Pi are saved to the microSD card. You may want your students to save files to the school's file system, or the students may want to do so. VNC includes a file transfer capability. Start a file transfer by right-clicking the blue on black VNC logo at the top right of the screen.
In the file transfer dialog, select either "Desktop" or "Ask every time." The "Send files" button open a file picker in the Raspberry Pi. When a file is selected, if "Ask every time" was set a directory picker for the classroom computer opens. Once a destination is selected, the file transfer begins.