A Raspberry Pi lab, with or without a Pi

Set up a Raspberry Pi headless with Raspberry Pi OS, connect to it over SSH and use GPIO safely, and learn what you can still practise on a normal Linux machine if you do not have the hardware yet.

  • Time: 45 minutes
  • Cost: free software, your own computer

What you need

A Raspberry Pi is a small, cheap computer that runs Linux and has pins (GPIO) for connecting sensors and LEDs. The Pi courses use it for Linux skills and for physical computing.

If you do not have a Pi yet, you can still learn most of the Linux and Python material on an Ubuntu VM (see the Linux lab guide), and use a browser simulator for the wiring ideas. Buy the Pi when you reach the hardware projects.

With a Pi you need: the board, a good-quality power supply of the right rating (weak supplies cause strange crashes), a microSD card (16 GB or more), and a card reader.

Set it up

  1. On your computer, install Raspberry Pi Imager from raspberrypi.com.
  2. Insert the microSD card, choose your Pi model, choose Raspberry Pi OS (the Lite version is perfect for headless work), and choose the card.
  3. Open the Imager’s settings (the cog) before writing: set a host name, a user name and password, your Wi-Fi details and country, and enable SSH. This lets the Pi come up ready to use without a screen or keyboard.
  4. Write the card, put it in the Pi and power it on. Wait a couple of minutes.
  5. From your computer: ssh youruser@yourhostname.local (or use its address from your router’s device list).
  6. Update it: sudo apt update && sudo apt full-upgrade -y.

Check that it works

  • You can sign in over SSH and hostname shows the name you chose.
  • cat /etc/os-release shows Raspberry Pi OS, and vcgencmd measure_temp shows a temperature.
  • pinout (if installed) draws the pin diagram, and a short Python script using the gpiozero library blinks an LED (with a resistor) on a pin.

If it will not join Wi-Fi, check the country and password in the settings, or use an Ethernet cable for the first boot.

Practise safely

  • GPIO pins are 3.3 V and cannot supply much current. Always use a resistor with an LED, never connect a pin directly to 5 V, and use a transistor or relay module for anything bigger than a small LED.
  • Never connect mains voltage to the Pi or to bare wiring; use ready-made, safety-rated modules and adult supervision for anything beyond low voltage.
  • Shut the Pi down properly (sudo shutdown now) before pulling the power; sudden power loss can corrupt the card.
  • Change the default password, keep SSH to your home network, and do not expose the Pi to the internet.
  • Keep a backup image of a working card so a mistake costs minutes.

Go further

  • Read a sensor with Python and log the values to a file, then view the log with tail -f.
  • Run a small web page or API on the Pi and reach it from your phone on the same network.
  • Create a service that starts your script at boot and restarts it if it fails (a systemd unit), then test by rebooting.
  • Practise remote work: scp a file, edit with nano over SSH, and schedule a job with cron.

Courses that use this lab

Other lab guides

Software changes quickly. Menu names and version numbers may differ a little from what you see; the ideas and the check at the end of each section stay the same. Always download from the project's own website, and read the licence terms for your situation.