Raspberry Pi Tutorial
Learn Raspberry Pi step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is a Raspberry Pi? Meet the Raspberry Pi: a credit-card-sized Linux computer with GPIO pins. Learn what it can do, who it is for, and how this course teaches it.
- Raspberry Pi Models Compared Compare the Raspberry Pi 5, Pi 4, Pi 3, Pi Zero 2 W and Pico, and learn how to pick the right model for your project and budget.
- Hardware Tour and the 40-Pin Header Walk around the Raspberry Pi board: processor, memory, ports, the camera and display connectors, and the 40-pin GPIO header with power and ground pins.
- Accessories and a Starter Shopping List Plan your first Raspberry Pi purchase: power supply, microSD card, case, cooling, cables, breadboard, resistors and LEDs, with a budget calculator.
Setup and OS
- Raspberry Pi OS and the Imager Choose a Raspberry Pi OS edition, write it to a microSD card with Raspberry Pi Imager, preconfigure Wi-Fi, SSH and a user, and verify the image.
- First Boot and Headless Setup Boot your Raspberry Pi for the first time, find its IP address, connect over SSH without a monitor, set up key login and fix common first-boot problems.
- raspi-config, config.txt and Updates Configure your Pi with raspi-config, edit config.txt and cmdline.txt safely, enable interfaces like I2C and SPI, and keep the system updated with apt.
- Storage: SD Cards, SSDs and Booting Understand Raspberry Pi storage: microSD wear, USB SSD and NVMe boot, partitions, backups with image copies, and how to check disk space and health.
- Power, Cooling and Safe Shutdown Power your Raspberry Pi correctly, read its temperature and throttling flags with vcgencmd, add cooling, and shut down safely to protect the SD card.
GPIO and Python
- GPIO Basics and Pin Numbering Learn how GPIO pins work: digital high and low, inputs and outputs, BCM versus physical numbering, safe wiring with resistors, and Python libraries.
- Blinking an LED with gpiozero Wire an LED to a Raspberry Pi and blink it with Python and gpiozero: the circuit, the code, blink(), toggle, loops, and a virtual environment tip.
- Buttons and Digital Input Read a push button on the Raspberry Pi with gpiozero: wiring, pull-up resistors, polling versus events, debouncing, and controlling an LED with a button.
- PWM: Dimming LEDs and Driving Servos Understand pulse-width modulation on the Raspberry Pi: duty cycle, dimming an LED with PWMLED, driving a hobby servo with gpiozero, and hardware versus software PWM.
- Buses: I2C, SPI and UART Learn the three serial buses on the Raspberry Pi: I2C, SPI and UART. Enable them, scan for devices with i2cdetect and read registers from Python.
Sensors and Cameras
- Temperature and Humidity Sensors Measure temperature and humidity with a Raspberry Pi: the DS18B20 on 1-Wire, the DHT22 and the BME280 on I2C, with code, logging and averaging.
- Distance and Motion Sensors Measure distance with an HC-SR04 ultrasonic sensor and detect movement with a PIR sensor on the Raspberry Pi, with wiring, voltage divider and gpiozero code.
- Analog Sensors and the ADC The Raspberry Pi has no analog inputs. Add an ADC such as the MCP3008 or ADS1115 to read light, soil moisture and potentiometers, with scaling code.
- Camera Module and picamera2 Connect a Raspberry Pi Camera Module, take photos and video with rpicam-still and rpicam-vid, and capture images from Python with picamera2.
Linux on the Pi
- The Pi Filesystem and Package Management with apt Find your way around Raspberry Pi OS: the directory tree, boot and config files, and how apt installs, updates and removes software without breaking the system.
- Users, Groups and Permissions on the Pi Understand Linux accounts on the Pi: the gpio, i2c and spi groups, sudo, file modes like 640 and 755, and why hardware scripts should not run as root.
- Running Programs at Boot with systemd Services Turn a Python script into a systemd service on the Pi: write a unit file, enable it at boot, restart on failure, read logs with journalctl, and avoid rc.local.
- Temperature, Throttling and Performance Monitoring Monitor a Raspberry Pi's health: read the CPU temperature, decode vcgencmd get_throttled flags, understand under-voltage, and measure load, memory and disk.
Networking and Servers
- Network Setup: Wi-Fi, Ethernet and Static IPs Connect a Raspberry Pi to Wi-Fi or Ethernet, find its IP address, set a static address with NetworkManager, and understand subnets, gateways, DNS and mDNS names.
- SSH, VNC and Remote Access Control a headless Raspberry Pi: enable SSH, log in with key pairs instead of passwords, copy files with scp and rsync, forward ports, and use VNC or Raspberry Pi Connect.
- Serving a Web Page and JSON API from the Pi Turn your Pi into a web server: serve sensor readings as HTML and JSON with Flask or the standard library, bind addresses and ports, and run it behind nginx.
- MQTT: Messaging Between Pis and Devices Connect many sensors and Pis with MQTT: topics, wildcards, QoS levels, retained messages, Mosquitto and paho-mqtt, with a runnable publish-subscribe broker model.
Projects
- Project: A Weather Station with Logging and Averages Build a Raspberry Pi weather station: read a BME280 over I2C, calibrate and smooth values, store readings in SQLite, and compute hourly averages and min/max.
- Project: A Motion-Detecting Alarm with PIR and Buzzer Build a Raspberry Pi motion alarm: wire a PIR sensor and buzzer, arm and disarm it with a button, debounce triggers, and send notifications. Includes a state machine you can run.
- Project: A Network-Wide Ad Blocker with DNS Understand how a Raspberry Pi DNS sinkhole such as Pi-hole blocks ads for the whole network: DNS lookups, blocklists, wildcards, caching and router setup, with a runnable resolver model.
- Project: A Plant Monitor with Automatic Watering Build a Raspberry Pi plant monitor: read soil moisture through an ADC, drive a pump with a relay, use hysteresis and safety limits, and log watering events in Python.
Deployment and Automation
- Scheduling Jobs with cron and systemd Timers Run tasks on a schedule on your Pi: cron syntax, crontab pitfalls with paths and environment, @reboot, systemd timers, logging, and a runnable cron expression matcher.
- Backups and Taking Care of the SD Card Protect your Pi against SD card failure: image and file backups with rsync, retention rules, reducing writes, log2ram, read-only root, SSD boot and a runnable backup rotation model.
- Hardening Your Pi: Updates, Firewall and Safe Defaults Secure a Raspberry Pi that is on a network: strong accounts, key-only SSH, automatic updates, a ufw firewall, fail2ban, minimal services and secrets handling, with an audit script model.
- Logging, Monitoring and the Hardware Watchdog Keep an unattended Pi healthy: Python's logging module with rotation, journald, heartbeat checks, the hardware watchdog that reboots a frozen Pi, and simple uptime alerts.
Projects and Practice
- Project: A Data Logger with a Live Dashboard Combine everything: log sensor data to SQLite, expose a JSON API with downsampling, and draw a live chart page. Includes architecture, a retention job and runnable aggregation code.
- Troubleshooting Your Pi: A Systematic Guide Diagnose Raspberry Pi problems step by step: LED codes, power and SD card faults, no network, SSH refused, services failing, GPIO permission errors, plus a runnable decision-tree helper.
- Practice Exercises and Project Ideas Test what you learned with hands-on Raspberry Pi exercises: Linux, networking, services, cron, backups and data handling, each with runnable Python practice and a list of larger projects.