Raspberry Pi Online Course: Beginner to Intermediate Projects and Programming
Learn Raspberry Pi setup, Linux, Python, GPIO, electronics, sensors, networking, cameras, automation, and practical beginner-to-intermediate projects.
Course overview
This Raspberry Pi online course takes you from first boot to practical physical-computing projects. You will learn how to install Raspberry Pi OS, use Linux, write Python programs, connect electronic components, communicate over a network, and operate projects automatically.
No previous Raspberry Pi, Linux, Python, or electronics experience is required. Basic computer skills and arithmetic are useful. Work through the lessons in order, test each change, and keep notes about wiring, software versions, and commands.
What you will build
- A configured Raspberry Pi connected to a display or managed remotely.
- Terminal-based file and system-management exercises.
- Python programs that use variables, decisions, loops, functions, files, and packages.
- An LED blink circuit and a push-button-controlled LED.
- A timed traffic-light sequence.
- A sensor monitor using a digital, I2C, SPI, or external-ADC device.
- A camera capture utility.
- A startup or scheduled automation service.
- A documented capstone application combining inputs, processing, outputs, and optional networking.
1. Raspberry Pi fundamentals
A Raspberry Pi is a small, general-purpose computer. It has a processor, memory, storage, operating system, networking, and connectors for peripherals. Unlike a conventional desktop computer, it is inexpensive, compact, power-efficient, and designed for experimentation. Unlike a microcontroller, it normally runs a full Linux operating system and can run several programs, network services, and graphical applications at once.
A microcontroller is often better for a tiny, predictable, low-power control task. A Raspberry Pi is better when a project needs Python, files, a camera, a network connection, a database, a web interface, or more complex processing.
Common board families
| Board family or model | Processing capability | Memory options | Connectivity | GPIO availability | Best use cases | Power considerations |
|---|---|---|---|---|---|---|
| Current full-size Pi models | High-performance multi-core processors | Several memory choices depending on model | USB, HDMI, Ethernet or Wi-Fi, and modern expansion interfaces | Usually a standard 40-pin header | Desktop use, servers, cameras, robotics, and demanding projects | Use the model's recommended USB-C supply; high-current peripherals may need separate power |
| Pi Zero family | Lower performance and very small form factor | Model-dependent | Compact USB, video, and wireless options vary by version | Header may be unpopulated or require soldering | Portable sensors, lightweight automation, and embedded projects | Lower consumption, but supply quality and cable voltage drop still matter |
| Pi 4-class boards | Multi-core processor suitable for desktop and server tasks | Multiple memory configurations | USB, dual micro-HDMI, Ethernet, Wi-Fi, Bluetooth, and GPIO | 40-pin header | Learning Linux, media, programming, and network services | Use a suitable USB-C supply and allow ventilation |
| Compute Module family | Module-based versions of Pi technology | Varies by module | Requires a compatible carrier board | Carrier-board dependent | Custom products and embedded systems | Carrier-board design determines power and connectors |
Choose a current full-size board for a first course unless size, power, or a particular connector is more important. Check the exact model documentation before buying a power supply, case, camera cable, display cable, or accessory.
Board interfaces
- USB: connects keyboards, mice, storage, hubs, wireless adapters, and other peripherals.
- HDMI: connects a monitor or television. The connector type varies by board.
- Power: modern boards commonly use USB-C; older boards may use another connector.
- microSD: stores the operating system, programs, and data on most standard boards.
- Ethernet and Wi-Fi: provide local-network and internet access. Bluetooth is also available on many models.
- Camera and display connectors: attach compatible ribbon-cable modules. Connector size and cable orientation matter.
- GPIO: the general-purpose input/output header connects the computer to switches, LEDs, sensors, displays, and control circuits.
Typical uses include learning programming and Linux, home automation, media playback, network services, robotics, data logging, camera projects, and electronics experiments.
For a board-port reference, see Raspberry Pi board fundamentals and what a Raspberry Pi is.
2. Equipment and safe setup
| Item | Required or optional | Purpose | Compatibility notes | Common alternatives |
|---|---|---|---|---|
| Raspberry Pi board | Required | Computer for the course | Confirm model-specific power, display, and camera connectors | Another compatible Pi model |
| Compatible power supply and cable | Required | Stable electrical power | Use the recommended voltage and current rating for the board | Official or reputable equivalent |
| microSD card | Required for most boards | Stores Raspberry Pi OS | Use a reliable, suitably rated card | Board-supported boot storage |
| Display, keyboard, and mouse | Optional but useful initially | Local setup and graphical work | Match HDMI connector and USB requirements | SSH from another computer |
| Ethernet cable or Wi-Fi | Optional individually; networking is highly useful | Updates and remote access | Set the correct WLAN country for Wi-Fi | Ethernet instead of Wi-Fi |
| Breadboard and jumper wires | Optional | Temporary circuits without soldering | Verify breadboard rail and row connections | Prototype board and soldered wires |
| LEDs, resistors, buttons, sensors, buzzer | Optional | Physical-computing exercises | Use components compatible with 3.3 V logic | Equivalent low-voltage parts |
| Multimeter | Optional but recommended | Measure voltage, resistance, continuity, and sometimes current | Learn the measurement mode before probing a powered circuit | Bench meter |
A suitable power supply prevents low-voltage warnings, crashes, corrupted storage, and unexpected resets. Poor cables can also cause voltage drop. High-current motors, servos, relays, USB devices, and LED strips may require an externally powered circuit or powered USB hub. Share ground between the Pi and an externally powered signal circuit only when the circuit design requires it and the voltage levels are safe.
Protect against static electricity by touching a grounded object before handling the board, holding it by its edges, and avoiding unnecessary contact with connector contacts. Inspect every connection for shorts, reversed polarity, loose jumper wires, and misplaced breadboard rows.
3. Installing and configuring Raspberry Pi OS
Raspberry Pi OS is a Linux distribution designed for Raspberry Pi hardware. A desktop installation includes a graphical interface and common applications. A Lite installation uses fewer resources and is suitable for headless servers, remote administration, and dedicated projects.
- Install Raspberry Pi Imager on another computer.
- Insert a reliable microSD card into the card reader.
- Select the Raspberry Pi model, Raspberry Pi OS edition, and storage card.
- Use the customization options to set a username, strong password, hostname, locale, keyboard layout, time zone, WLAN country, and optional Wi-Fi credentials.
- Write the image and safely eject the card.
- Insert it into the Pi, connect the display and input devices if using them, connect the network, and apply power.
- Complete the first-boot prompts and confirm that the desktop, terminal, network, and storage operate normally.
Use the operating-system installation lesson, the setup lesson, and system configuration guidance when checking model-specific options.
First updates
sudo apt update
sudo apt full-upgrade
python3 --version
uname -aAPT is the package manager used by Raspberry Pi OS to install and update system software. apt update refreshes package information; apt full-upgrade installs available updates and handles required dependency changes. Review prompts before accepting changes, and avoid interrupting an upgrade.
Enable only the interfaces that your project needs. Use sudo raspi-config or the current Raspberry Pi OS configuration tools to enable SSH, I2C, SPI, serial, camera, or remote desktop support. Set the correct locale, time zone, keyboard layout, and WLAN country. A wrong country setting can prevent wireless operation.
4. Raspberry Pi OS and Linux basics
The graphical desktop provides windows, menus, a file manager, a terminal, and application launchers. The terminal, also called a command line or shell session, accepts commands as text. A command commonly has a program name followed by options and arguments.
| Command | Purpose | Example use | Caution or note |
|---|---|---|---|
pwd | Print the current directory | pwd | Useful before file operations |
ls -la | List files, including hidden entries | ls -la | Check names and permissions carefully |
cd | Change directory | cd projects | Paths are case-sensitive |
mkdir | Create a directory | mkdir pi-course | Do not overwrite an existing project accidentally |
cp | Copy files or directories | cp app.py backup.py | Check the destination before copying |
mv | Move or rename | mv old.py new.py | Can replace a destination in some situations |
rm | Delete a file | rm test.txt | Usually does not use a recycle bin; verify the path |
cat | Print file contents | cat README.txt | Large files may fill the terminal |
nano | Edit a text file | nano app.py | Use the displayed keyboard shortcuts to save and exit |
sudo apt install | Install a system package | sudo apt install git | Administrative commands can change the system |
man | Read command documentation | man ls | Press q to quit many help viewers |
Linux files have an owner, a group, and permission bits for reading, writing, and executing. Use sudo only when administrative privileges are required. Avoid running programs or scripts as administrator unless you understand why it is necessary.
Practice with a project directory:
mkdir -p ~/pi-course/files
cd ~/pi-course/files
echo "first note" > note.txt
cat note.txt
cp note.txt copy.txt
mv copy.txt renamed.txt
ls -laUse terminal guidance, command examples, file management, and directory management for additional practice.
5. Networking, SSH, and remote desktops
Ethernet usually provides the simplest initial network connection. Wi-Fi is convenient but depends on credentials, signal strength, the WLAN country setting, and the access point configuration. A hostname is a human-readable device name. An IP address identifies the device on a local network.
hostname
hostname -I
ip addressSSH, or Secure Shell, provides an encrypted terminal session from another computer. Enable it only when needed, use a strong password or key-based authentication, and keep the operating system updated.
ssh <username>@<hostname>.local
ssh <username>@<ip_address>Use a remote desktop option when you need graphical applications. Remote desktop is more demanding than SSH and should be protected with strong credentials and limited network exposure. Do not expose SSH or a remote desktop service directly to the public internet without a carefully designed security setup.
Both devices must normally be on the same local network. If hostname discovery fails, find the current address on the Pi or router and connect by IP address. Check Ethernet or Wi-Fi status, credentials, signal strength, firewall rules, and network isolation. See remote access, SSH setup, finding an IP address, and network connection steps.
6. Python programming
Python is an interpreted programming language well suited to Raspberry Pi projects. You can run it interactively with python3 or save a program in a file ending in .py.
python3
>>> print("Hello, Raspberry Pi")
>>> 2 + 3
>>> exit()mkdir -p ~/pi-course/python
cd ~/pi-course/python
nano hello.py
python3 hello.pyA beginner program uses variables, data types, operators, input, output, conditions, loops, and functions:
name = input("Your name: ")
count = 3
for number in range(count):
print("Hello", name, number + 1)
def status(value):
if value > 20:
return "high"
return "normal"
print(status(18))Important built-in structures include strings for text, lists for ordered collections, dictionaries for key-value data, and files for persistent information.
reading = {"temperature": 21.5, "unit": "C"}
values = [20.1, 21.5, 21.2]
with open("readings.txt", "w", encoding="utf-8") as file:
for value in values:
file.write(f"{value}\n")Use a Python virtual environment to keep project dependencies separate:
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install <package_name>
python3 app.py
deactivatepip installs Python packages, while APT installs system packages. Prefer the method recommended by the package documentation and avoid mixing environments without understanding which interpreter is running.
When Python fails, read the complete traceback. It identifies the exception type and usually points to the failing line. Check indentation, spelling, variable values, file paths, package installation, and the selected interpreter. Add temporary print statements, reduce the program to a small test, and change one thing at a time.
7. GPIO and physical computing
GPIO means General-Purpose Input/Output. A pin configured as a digital output can be driven low or high. A digital input reads a low or high state. Raspberry Pi GPIO uses 3.3 V logic. GPIO pins are not power supplies for motors or other high-current loads.
Two numbering conventions are common: physical pin numbering counts positions on the header, while BCM numbering names the GPIO controller signals. Select one convention in your library and use it consistently. Confusing the two can connect a circuit to the wrong pin.
| Physical pin | BCM GPIO number | Typical function | Power or ground designation | Safety notes |
|---|---|---|---|---|
| 1 | — | 3.3 V rail | 3.3 V power | Do not use as a general signal pin |
| 2 | — | 5 V rail | 5 V power | Never connect this directly to a GPIO input |
| 6 | — | Ground | GND | Use as the circuit reference |
| 11 | 17 | General GPIO | Signal | Configure safely before use |
| 13 | 27 | General GPIO | Signal | Check alternate functions before assigning |
| 3 | 2 | I2C SDA | Signal | Also has an alternate bus function |
| 5 | 3 | I2C SCL | Signal | Also has an alternate bus function |
| 19 | 10 | SPI MOSI | Signal | Use only with compatible voltage levels |
| 21 | 9 | SPI MISO | Signal | Check device direction and wiring |
| 23 | 11 | SPI SCLK | Signal | Bus timing is device-dependent |
Pin assignments can vary in function, but the power and ground positions above are standard for the common 40-pin layout. Always verify the exact board pinout before wiring.
LED output
An LED is a diode, so polarity matters. Connect a GPIO output through a current-limiting resistor to the LED, then connect the LED to ground or the supply according to the chosen logic. The resistor limits current and protects both the LED and GPIO.
Ohm's law is V = I × R. A simple resistor estimate is R = (VGPIO - VLED) / I. For example, with approximately 3.3 V, a 2.0 V LED drop, and a target of 0.005 A, the result is 260 ohms; choose a standard value such as 330 ohms for a conservative beginner circuit.
# Example structure; use the GPIO library supported by your Raspberry Pi OS image.
from time import sleep
# Configure the chosen GPIO output before driving it.
# Set the output high and low in a try/finally block.
try:
while True:
# led.on()
sleep(1)
# led.off()
sleep(1)
finally:
# Release or reset GPIO resources here.
passUse a supported GPIO library appropriate to your installed Raspberry Pi OS environment. The exact API can differ between libraries and releases, so follow the library's current documentation rather than copying pin setup blindly.
Buttons, pull resistors, and debouncing
A button input must never be left electrically undefined. A pull-up resistor biases the input high until the switch connects it to ground. A pull-down resistor biases it low until the switch connects it to a positive logic supply. Many GPIO libraries can enable suitable internal pulls.
Mechanical buttons can bounce: one physical press may produce several rapid electrical transitions. Use software debouncing by ignoring changes for a short interval, or use an appropriate hardware debounce circuit. Test the input state before adding event callbacks or complex output logic.
Always release GPIO resources when the program exits, including when interrupted. Reset outputs to a safe state in a cleanup block such as try/finally.
8. Electronics and circuits
A breadboard contains groups of electrically connected holes, commonly short rows on each side of a center gap. Power rails may run along the edges, but their continuity and polarity should be checked because different boards vary. Integrated circuits often straddle the center gap.
Voltage is electrical potential difference, current is the flow of charge, and resistance opposes current. Ground (GND) is the reference point shared by compatible parts. A circuit needs a complete path from its source, through its components, and back to ground or the source return.
- LEDs require correct polarity and a current-limiting resistor.
- Push buttons are switches and need a pull-up or pull-down arrangement.
- Potentiometers provide a variable voltage, but their output is analog.
- Buzzers vary: an active buzzer may sound when powered, while a passive buzzer usually needs a changing signal such as PWM.
- Relays, servos, and motors require driver transistors, motor-driver boards, flyback protection where applicable, and suitable external power.
- Check polarity, operating voltage, current, and logic-level requirements in every component's documentation.
A digital signal has discrete states such as low and high. An analog signal can take a continuous range of values. Most Raspberry Pi boards do not include general-purpose analog inputs, so a potentiometer or analog sensor normally requires an external ADC, or analog-to-digital converter. An ADC communicates with the Pi through an interface such as SPI or I2C.
Read circuit diagrams by identifying the supply, ground, signal direction, component values, and connection junctions. Use a multimeter to check continuity with power disconnected and voltage with the correct measurement mode when powered.
9. Sensors, actuators, and peripherals
| Interface | Typical devices | Pins used | Strengths | Limitations |
|---|---|---|---|---|
| GPIO digital | Buttons, switches, simple motion sensors, LEDs | One or more signal pins plus power and ground | Simple and direct | Only discrete states; limited current |
| I2C | Environmental sensors, RTCs, small displays, ADCs | SDA, SCL, power, ground | Multiple addressed devices share two signal lines | Addresses, pull-ups, speed, and voltage must be compatible |
| SPI | ADCs, displays, memory, fast sensors | SCLK, MOSI, MISO, chip select, power, ground | Fast and explicit device selection | Uses more wires and chip-select management |
| UART | GPS modules, console devices, serial controllers | TX, RX, power, ground | Simple point-to-point serial communication | Baud rate, voltage, and device configuration must match |
| PWM | LED brightness, passive buzzers, servo control | A compatible output signal and ground | Controls duty cycle and timing | Not a substitute for a power driver |
Common sensors measure temperature, humidity, light, motion, distance, or a switch state. An actuator changes the environment: examples include LEDs, buzzers, relays, servos, and motors. Test power and ground first, then communication wiring, then a minimal library example. Device-specific libraries and addresses must be checked in the component documentation.
Camera and displays
A compatible camera module uses a board-specific camera connector and cable orientation. Enable the required camera support, then test a still image before adding video, storage, motion detection, or networking. A camera utility should handle missing devices, unwritable paths, and insufficient storage.
HDMI displays are convenient for the desktop. Small I2C displays reduce wiring complexity but require the correct address, driver, font, and library. Use a terminal output first when diagnosing a display project so that sensor and program logic can be tested independently.
10. Project development workflow
- Define the input, processing, and output. For example, a temperature sensor is the input, a threshold decision is the processing, and an LED or log is the output.
- List voltage, current, connector, library, and power requirements.
- Draw the wiring and label GPIO numbering, power, ground, and component values.
- Test the Pi and each component separately.
- Write a small Python test for one sensor or actuator.
- Combine components gradually and add validation for missing or invalid readings.
- Handle errors, use meaningful messages, and log unattended operation.
- Save the project in a clear folder with a README, wiring notes, dependency list, and startup instructions.
- Introduce version control with Git so changes can be reviewed and earlier working versions restored.
A useful project structure is:
weather-monitor/
README.md
app.py
sensor.py
requirements.txt
config.example.ini
wiring.txt
logs/Do not combine hardware until each part works. This makes a wrong pin, bad cable, incompatible voltage, or missing package much easier to locate.
11. Automation and services
cron runs commands on a schedule. Use crontab -e to edit a user's schedule. Cron jobs should use absolute paths and redirect output to a known log.
crontab -e
# Example pattern: run every five minutes and append output
*/5 * * * * /home/<username>/weather-monitor/.venv/bin/python /home/<username>/weather-monitor/app.py >> /home/<username>/weather-monitor/logs/app.log 2>&1systemd manages long-running services. It is generally preferable to cron when a program must start at boot, restart after failure, wait for networking, run under a specific user, or provide clear status and logs. Test the program manually first, use least-privilege permissions, and confirm that paths and environment variables work outside an interactive terminal.
Network-connected automation needs strong credentials, regular updates, limited open ports, safe handling of secrets, and protection against unsafe physical actions. Log timestamps, input values, errors, and important state changes, but do not log passwords or private keys.
12. Troubleshooting and maintenance
| Symptom | Likely causes | Checks | Resolution |
|---|---|---|---|
| Pi does not boot | Bad image, corrupted microSD, poor power, loose card, or display issue | Check indicators, cables, card seating, and power | Rewrite Raspberry Pi OS, try known-good storage and power, and inspect boot diagnostics |
| Low-voltage warning or resets | Undersized supply, poor cable, or excessive peripheral load | Check supply rating, cable, and connected devices | Use a compatible supply, replace the cable, or power high-current devices separately |
| No display | Wrong cable, input, connector, resolution, or mistaken boot diagnosis | Try a supported display and cable; test another screen | Verify the model's HDMI connector and display configuration |
| Keyboard or mouse fails | Loose connection, insufficient power, hub issue, or incompatible device | Try another USB port or a powered hub | Reconnect, reduce peripheral load, or use remote access |
| Wi-Fi fails | Wrong credentials or country, weak signal, or unsupported network | Check settings, date/time, signal, and Ethernet | Correct configuration, move closer, or test Ethernet |
| SSH refused or host unavailable | SSH disabled, wrong address, different networks, or firewall isolation | Enable SSH, check hostname -I, and verify the local network | Use the correct hostname or IP address and secure the service |
| LED is dark or unpredictable | Reversed polarity, wrong numbering, missing ground, loose wire, or resistor error | Compare wiring and code with the pin reference; run a one-pin test | Correct polarity, numbering, ground, and resistor placement |
| Button gives multiple presses | Bounce, floating input, or incorrect pull configuration | Check pull-up or pull-down wiring and event timing | Add a pull resistor and software or hardware debouncing |
| Python import fails | Missing package, wrong environment, spelling, or system dependency | Read the traceback and check the active interpreter | Install using the appropriate package method and verify the import name |
| I2C or SPI device missing | Interface disabled, wiring, address, voltage, or library problem | Enable the bus, check power and signals, and scan where appropriate | Correct wiring or address and use safe compatible voltage levels |
Maintain the system by applying updates deliberately, keeping backups of code and configuration, exporting important data, and testing restored copies. A second microSD image or documented rebuild procedure is useful. If a board becomes hot, smells unusual, shows physical damage, or behaves incorrectly after a wiring mistake, disconnect power and stop testing it until the cause is understood.
13. Guided course projects
Initial setup exercise
Write Raspberry Pi OS with Raspberry Pi Imager, complete first-boot settings, connect to Ethernet or Wi-Fi, run the update commands, record the hostname and IP address, and verify that the terminal and desktop work.
Terminal and Python exercise
Create ~/pi-course/python, make a hello.py file, run it from the terminal, modify its output, and save a copy. Then add a function, a list of values, and a file-writing step.
LED and button projects
Build the LED circuit with a resistor and a shared ground. Confirm the pin convention in code. Add a button using an internal pull-up or pull-down, debounce the input, and change the LED state only after verifying the button's idle and pressed readings.
Traffic light
Use three output pins and separate functions such as set_red(), set_green(), and set_yellow(). Add delays, repeat the sequence, and use cleanup code to switch all outputs to a safe state.
Sensor monitor
Choose a compatible temperature, light, motion, distance, or humidity sensor. Test its interface, validate readings, print clear units, and append timestamped values to a file. An analog sensor requires an ADC.
I2C peripheral
Enable I2C, connect the device's power, ground, SDA, and SCL lines, detect its address, install the documented library, and show a reading on a small display or in the terminal. Diagnose wiring and voltage before changing application code.
Camera utility
Connect a supported camera module, enable the required camera interface, capture one still image, and then add a timestamped filename or short video. Check available storage and permissions.
Remote administration and startup
Enable SSH, connect from another computer, transfer a script with a secure file-transfer method, and run it remotely. After manual testing, schedule a periodic task with cron or create a systemd service that starts at boot and writes diagnostic output to a log.
Capstone
Design a documented application with at least one sensor input, program logic, one actuator or display output, and optional network reporting. Include a wiring diagram, a parts list, installation commands, a dependency file, error handling, safe shutdown behavior, and a troubleshooting section.
Exam-relevant notes
- Raspberry Pi OS is Linux-based; APT manages system packages and pip manages Python packages in the appropriate environment.
- GPIO physical pin numbers and BCM GPIO numbers are different conventions.
- GPIO logic is 3.3 V. A 5 V signal can damage a GPIO input.
- An LED needs a current-limiting resistor and correct polarity.
- A button input needs a defined pull-up or pull-down state and may need debouncing.
- Most Raspberry Pi boards need an external ADC for analog measurements.
- I2C uses addressed shared lines; SPI uses clock, data lines, and chip-select signals.
- SSH provides secure command-line access; remote desktop provides graphical access but requires more resources and careful security.
- Use cleanup code for GPIO and safe power practices for motors, servos, relays, and other high-current devices.
- Use systemd for reliable long-running startup services and cron for straightforward schedules.