The Pi, the card and the lab
The Raspberry Pi 5 is a small but complete Linux computer
Start-of-lab checklist
Do these at the start of every Pi lab. Five minutes here saves an hour of confusing errors later.
The microSD card (clock, saving, corruption)
The Pi has no hard disk. It boots from your microSD card, and the card is the disk: the operating system, everything you install and all your files live on it. Take the card home, bring it back, and your work is still there. This page covers what that means in practice and how to repair the card when something gets damaged.
How LAMP fits together
Lab 5b installs LAMP: Linux, Apache, MariaDB, PHP. The lab sheet gives the install commands. This page explains what each part does and how they talk to each other, because most "it doesn't work" problems are one link in this chain being broken.
Apache (web server)
Apache is the web server behind http://localhost, your PHP pages and phpMyAdmin. The lab sheet installs it; this page is for when it misbehaves.
phpMyAdmin (how it works and fixes)
phpMyAdmin is a set of PHP pages that manage MariaDB from the browser. It is not a separate server
MariaDB and SQL
MariaDB is the database (a drop-in replacement for MySQL: the mysql and mariadb commands are the same program). You can manage it with phpMyAdmin or from the terminal. The terminal is faster once you know it, and it still works when phpMyAdmin does not.
MariaDB users and permissions
Most database problems in the lab are not SQL problems. They are login and permission problems: a user missing, made for the wrong host, or with no rights. This page explains how MariaDB decides who gets in, and how to fix each case.
Python, venv and Thonny
The labs use three extra Python libraries: pyserial (import serial), pymysql and flask. They live in a virtual environment (venv) called env in /home/pi. Nearly every Python problem in the labs is really "the wrong Python is running".
Arduino to Pi over USB (Lab 5c)
In Lab 5c the Arduino reads the sensors and prints lines like Dist=42 and Temp=25.31, and a Python program on the Pi reads those lines through the USB cable. The program is on your lab sheet. This page explains the pieces so you can fix them.
Python to MariaDB (Lab 5d)
In Lab 5d the readings from Lab 5c go into a MariaDB table (MySensor → Data). The lab sheet has the table design and the program. This page covers what it does not explain: why each part is there, and how to find out what is wrong.
Flask web pages (Lab 5e)
Flask is a small Python web framework: it turns Python functions into web pages. In Lab 5e it shows the MySensor table in the browser. The lab sheet has the code; this page explains how Flask works so you can fix and extend it.
PHP pages (extra)
The labs show the data with Flask, but the Pi already has PHP from LAMP, and it can do the same job with no program to keep running: Apache runs the PHP code every time someone opens the page. This is beyond the lab sheets, for anyone who wants to try.
SSH, VNC and copying files
You do not need the lab monitor to use the Pi. From your laptop on the same network:
GPIO pins
The 40-pin header lets the Pi read buttons and sensors and switch LEDs, buzzers and relays directly, without an Arduino. GPIO means General Purpose Input/Output. The labs use the Arduino for sensors, so this page is extra: for projects and for understanding what the Arduino does for you.
Python and GPIO (gpiozero)
gpiozero is the recommended Python library for GPIO (extra, not in the lab sheets). It is installed with Raspberry Pi OS and works on every model, including the Raspberry Pi 5.
Sensors on the Raspberry Pi
These sensors are extra: the labs read sensors on the Arduino. Use this page for projects. Python packages that are not part of Raspberry Pi OS must be installed in a virtual environment first. See Python virtual environment and Thonny.