Raspberry Pi online course

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 modelProcessing capabilityMemory optionsConnectivityGPIO availabilityBest use casesPower considerations
Current full-size Pi modelsHigh-performance multi-core processorsSeveral memory choices depending on modelUSB, HDMI, Ethernet or Wi-Fi, and modern expansion interfacesUsually a standard 40-pin headerDesktop use, servers, cameras, robotics, and demanding projectsUse the model's recommended USB-C supply; high-current peripherals may need separate power
Pi Zero familyLower performance and very small form factorModel-dependentCompact USB, video, and wireless options vary by versionHeader may be unpopulated or require solderingPortable sensors, lightweight automation, and embedded projectsLower consumption, but supply quality and cable voltage drop still matter
Pi 4-class boardsMulti-core processor suitable for desktop and server tasksMultiple memory configurationsUSB, dual micro-HDMI, Ethernet, Wi-Fi, Bluetooth, and GPIO40-pin headerLearning Linux, media, programming, and network servicesUse a suitable USB-C supply and allow ventilation
Compute Module familyModule-based versions of Pi technologyVaries by moduleRequires a compatible carrier boardCarrier-board dependentCustom products and embedded systemsCarrier-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

ItemRequired or optionalPurposeCompatibility notesCommon alternatives
Raspberry Pi boardRequiredComputer for the courseConfirm model-specific power, display, and camera connectorsAnother compatible Pi model
Compatible power supply and cableRequiredStable electrical powerUse the recommended voltage and current rating for the boardOfficial or reputable equivalent
microSD cardRequired for most boardsStores Raspberry Pi OSUse a reliable, suitably rated cardBoard-supported boot storage
Display, keyboard, and mouseOptional but useful initiallyLocal setup and graphical workMatch HDMI connector and USB requirementsSSH from another computer
Ethernet cable or Wi-FiOptional individually; networking is highly usefulUpdates and remote accessSet the correct WLAN country for Wi-FiEthernet instead of Wi-Fi
Breadboard and jumper wiresOptionalTemporary circuits without solderingVerify breadboard rail and row connectionsPrototype board and soldered wires
LEDs, resistors, buttons, sensors, buzzerOptionalPhysical-computing exercisesUse components compatible with 3.3 V logicEquivalent low-voltage parts
MultimeterOptional but recommendedMeasure voltage, resistance, continuity, and sometimes currentLearn the measurement mode before probing a powered circuitBench 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.

  1. Install Raspberry Pi Imager on another computer.
  2. Insert a reliable microSD card into the card reader.
  3. Select the Raspberry Pi model, Raspberry Pi OS edition, and storage card.
  4. Use the customization options to set a username, strong password, hostname, locale, keyboard layout, time zone, WLAN country, and optional Wi-Fi credentials.
  5. Write the image and safely eject the card.
  6. Insert it into the Pi, connect the display and input devices if using them, connect the network, and apply power.
  7. 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 -a

APT 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.

CommandPurposeExample useCaution or note
pwdPrint the current directorypwdUseful before file operations
ls -laList files, including hidden entriesls -laCheck names and permissions carefully
cdChange directorycd projectsPaths are case-sensitive
mkdirCreate a directorymkdir pi-courseDo not overwrite an existing project accidentally
cpCopy files or directoriescp app.py backup.pyCheck the destination before copying
mvMove or renamemv old.py new.pyCan replace a destination in some situations
rmDelete a filerm test.txtUsually does not use a recycle bin; verify the path
catPrint file contentscat README.txtLarge files may fill the terminal
nanoEdit a text filenano app.pyUse the displayed keyboard shortcuts to save and exit
sudo apt installInstall a system packagesudo apt install gitAdministrative commands can change the system
manRead command documentationman lsPress 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 -la

Use 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 address

SSH, 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.py

A 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
deactivate

pip 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 pinBCM GPIO numberTypical functionPower or ground designationSafety notes
13.3 V rail3.3 V powerDo not use as a general signal pin
25 V rail5 V powerNever connect this directly to a GPIO input
6GroundGNDUse as the circuit reference
1117General GPIOSignalConfigure safely before use
1327General GPIOSignalCheck alternate functions before assigning
32I2C SDASignalAlso has an alternate bus function
53I2C SCLSignalAlso has an alternate bus function
1910SPI MOSISignalUse only with compatible voltage levels
219SPI MISOSignalCheck device direction and wiring
2311SPI SCLKSignalBus 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.
    pass

Use 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

InterfaceTypical devicesPins usedStrengthsLimitations
GPIO digitalButtons, switches, simple motion sensors, LEDsOne or more signal pins plus power and groundSimple and directOnly discrete states; limited current
I2CEnvironmental sensors, RTCs, small displays, ADCsSDA, SCL, power, groundMultiple addressed devices share two signal linesAddresses, pull-ups, speed, and voltage must be compatible
SPIADCs, displays, memory, fast sensorsSCLK, MOSI, MISO, chip select, power, groundFast and explicit device selectionUses more wires and chip-select management
UARTGPS modules, console devices, serial controllersTX, RX, power, groundSimple point-to-point serial communicationBaud rate, voltage, and device configuration must match
PWMLED brightness, passive buzzers, servo controlA compatible output signal and groundControls duty cycle and timingNot 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

  1. 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.
  2. List voltage, current, connector, library, and power requirements.
  3. Draw the wiring and label GPIO numbering, power, ground, and component values.
  4. Test the Pi and each component separately.
  5. Write a small Python test for one sensor or actuator.
  6. Combine components gradually and add validation for missing or invalid readings.
  7. Handle errors, use meaningful messages, and log unattended operation.
  8. Save the project in a clear folder with a README, wiring notes, dependency list, and startup instructions.
  9. 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>&1

systemd 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

SymptomLikely causesChecksResolution
Pi does not bootBad image, corrupted microSD, poor power, loose card, or display issueCheck indicators, cables, card seating, and powerRewrite Raspberry Pi OS, try known-good storage and power, and inspect boot diagnostics
Low-voltage warning or resetsUndersized supply, poor cable, or excessive peripheral loadCheck supply rating, cable, and connected devicesUse a compatible supply, replace the cable, or power high-current devices separately
No displayWrong cable, input, connector, resolution, or mistaken boot diagnosisTry a supported display and cable; test another screenVerify the model's HDMI connector and display configuration
Keyboard or mouse failsLoose connection, insufficient power, hub issue, or incompatible deviceTry another USB port or a powered hubReconnect, reduce peripheral load, or use remote access
Wi-Fi failsWrong credentials or country, weak signal, or unsupported networkCheck settings, date/time, signal, and EthernetCorrect configuration, move closer, or test Ethernet
SSH refused or host unavailableSSH disabled, wrong address, different networks, or firewall isolationEnable SSH, check hostname -I, and verify the local networkUse the correct hostname or IP address and secure the service
LED is dark or unpredictableReversed polarity, wrong numbering, missing ground, loose wire, or resistor errorCompare wiring and code with the pin reference; run a one-pin testCorrect polarity, numbering, ground, and resistor placement
Button gives multiple pressesBounce, floating input, or incorrect pull configurationCheck pull-up or pull-down wiring and event timingAdd a pull resistor and software or hardware debouncing
Python import failsMissing package, wrong environment, spelling, or system dependencyRead the traceback and check the active interpreterInstall using the appropriate package method and verify the import name
I2C or SPI device missingInterface disabled, wiring, address, voltage, or library problemEnable the bus, check power and signals, and scan where appropriateCorrect 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.