Skip to content
Home
Raspberry Pi Guide: Projects, GPIO, and Linux Setup

Raspberry Pi Guide: Projects, GPIO, and Linux Setup

Embedded Systems Embedded Systems 9 min read 1711 words Intermediate ExcellentWiki Editorial Team

What Is Raspberry Pi?

Raspberry Pi is a series of single-board computers (SBCs) developed by the Raspberry Pi Foundation in Cambridge, England, with the original mission of promoting computer science education in schools. Unlike microcontrollers that run a single program with deterministic timing, a Raspberry Pi runs a full Linux operating system, features gigabytes of RAM, and supports USB, HDMI, Wi-Fi, Bluetooth, and Gigabit Ethernet. The Pi 5, released in late 2023, uses the BCM2712 system-on-chip with a quad-core Cortex-A76 running at 2.4 GHz, delivering 2–3 times the CPU performance of the Pi 4 according to the Foundation’s benchmarks. The VideoCore VII GPU supports dual 4K display output at 60 Hz, and the PCIe 2.0 x1 interface enables NVMe SSD connectivity for dramatically improved storage performance.

Model Comparison

The Raspberry Pi 5 features the BCM2712 SoC with quad Cortex-A76 cores at 2.4 GHz, 4–8 GB LPDDR4X RAM, PCIe 2.0 x1, USB 3.0, dual HDMI 4Kp60, and a 40 nm GPIO header. It is the best choice for desktop replacement, media centers, and compute-intensive projects. The Pi 4 Model B uses the BCM2711 with quad Cortex-A72 cores at 1.8 GHz, 1–8 GB RAM, and dual HDMI 4Kp30, and remains widely supported and cost-effective for most projects at lower prices. The Pi Zero 2 W packages a quad Cortex-A53 at 1 GHz with 512 MB RAM in a compact, low-power $15 form factor suitable for embedded projects where size and power matter more than peak performance.

The Raspberry Pi Pico and Pico W use the RP2040 microcontroller with dual Cortex-M0+ cores at 133 MHz, 264 KB RAM, and no MMU. These are microcontroller boards, not SBCs, suitable for real-time control tasks with microsecond timing requirements. The Pico W adds Wi-Fi connectivity. Many projects combine a Pi SBC for high-level processing with a Pico for real-time I/O control.

Setting Up Raspberry Pi OS

Use the Raspberry Pi Imager tool (available for Windows, macOS, and Linux) to write Raspberry Pi OS to a microSD card. The Imager provides an advanced configuration menu accessed by pressing Ctrl-Shift-X that enables headless setup: you can pre-configure SSH authentication with a username and password or public key, set Wi-Fi credentials including country code, configure the hostname, and set the locale and timezone. After writing the image, insert the SD card into the Pi, apply USB-C power (5 V, 3 A for Pi 4, 5 A for Pi 5), wait for boot, and SSH from another computer using ssh pi@raspberrypi.local or the configured hostname. Change the default password using passwd immediately for security.

GPIO Programming

The 40-pin GPIO header provides a mix of general-purpose digital I/O pins and dedicated interfaces for I2C, SPI, UART, PWM, and I2S audio. The RPi.GPIO Python library is the simplest way to control GPIO pins for beginners, but it runs in user space and has limitations for timing-critical applications. The pigpio library provides hardware-timed PWM and accurate timing using the Pi’s DMA hardware. For production applications, the Linux kernel GPIO subsystem accessed through the libgpiod library or sysfs interface provides proper driver integration with interrupt handling and device tree integration.

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
while True:
    GPIO.output(18, GPIO.HIGH)
    time.sleep(1)
    GPIO.output(18, GPIO.LOW)
    time.sleep(1)

Project Ideas

Home automation with Home Assistant provides a centralized web dashboard for controlling lights, sensors, and appliances through GPIO-connected relays, Z-Wave USB dongles, and Zigbee coordinators. A media center running Kodi or OSMC turns the Pi into a 4K-capable streaming device that plays local media files, streams from Netflix and YouTube, and runs retro gaming emulators. Pi-hole provides network-wide ad blocking at the DNS level, blocking tracking and advertising domains for every device on the network with no client configuration required. Retro gaming emulators such as RetroPie or RecalBox run classic console games up to PlayStation 1 quality using the Pi’s GPU for hardware-accelerated rendering.

Pi vs Arduino

Raspberry Pi runs a full operating system with multitasking, virtual memory, and networking. Arduino runs a single program with deterministic microsecond interrupt response. Choose the Pi for applications that need networking such as web servers and API clients, complex computation such as image processing and machine learning, databases such as SQLite or InfluxDB for data logging, and graphical user interfaces via HDMI or touchscreens. Choose Arduino for real-time control loops where timing must be predictable to within microseconds, ultra-low-power battery operation measured in microamps, high-volume products sensitive to cost per unit, and applications where boot time must be under one second.

Interfacing with Peripherals

I2C connects sensors such as the BME280 temperature, humidity, and pressure sensor or the MPU6050 6-axis IMU using only two wires plus power. The Linux kernel’s I2C device driver provides access through /dev/i2c-N device nodes. The smbus2 Python library and the i2c-tools command-line utilities simplify development and debugging. SPI enables high-speed communication with displays such as the ILI9341 TFT at 40 MHz, ADC chips such as the MCP3008 for analog sensor input, and RFID reader modules. UART connects GPS modules for location tracking, serial console terminals for debugging, Bluetooth modules, and LoRa radio transceivers. Each serial protocol uses dedicated pins on the GPIO header as documented in the BCM2712 peripheral specification, but can also be bit-banged on any GPIO pin for additional interfaces.

Performance Tuning

For CPU-intensive workloads, the Pi 5 can be overclocked to 3.0 GHz with adequate cooling — a heatsink with an active fan is mandatory for sustained loads at this speed. The Pi 4 can typically reach 2.0 GHz. Replace the microSD card with an SSD connected via USB 3.0 (Pi 4) or the PCIe 2.0 x1 M.2 slot (Pi 5) for dramatically improved I/O performance — random read speeds improve from approximately 10 MB/s on a good SD card to 300+ MB/s on an SSD. Disable Bluetooth and Wi-Fi in /boot/config.txt when not needed to free CPU cycles and reduce power consumption. Use a RAM disk for frequent file I/O to extend SD card lifespan and improve throughput.

Networking Capabilities

Raspberry Pi can serve multiple network roles. As a Wi-Fi access point using hostapd and dnsmasq, it creates a standalone wireless network for IoT devices in areas without existing infrastructure. As a VPN server using WireGuard for performance or OpenVPN for compatibility, it provides secure remote access to home or office networks. As a network file server using Samba for Windows compatibility or NFS for Linux clients, it provides centralized storage. As a DNS sinkhole with Pi-hole, it blocks advertisements at the network level. The Pi 4 and Pi 5 include dual-band 802.11ac Wi-Fi with Bluetooth 5.0 and true Gigabit Ethernet on a dedicated bus (unlike the Pi 3 where Ethernet shared bandwidth with USB).

Frequently Asked Questions

How do I connect a Raspberry Pi to a microcontroller? Use I2C, SPI, or UART between the Pi’s GPIO header and the microcontroller. The Pi acts as the master, and the microcontroller acts as a slave. This is a common architecture where the Pi handles networking and user interface while the microcontroller manages real-time sensor and actuator control.

What storage should I use for reliable long-term operation? For industrial applications that must run 24/7 for years, use an SSD connected via USB 3.0 or the Pi 5’s PCIe NVMe slot instead of a microSD card. SD cards have limited write endurance and can fail unexpectedly under continuous logging workloads.

How do I ensure my Pi project survives power loss? Use a UPS HAT with automatic shutdown that signals the Pi over GPIO when battery backup is active, giving the OS time to shut down cleanly. Alternatively, use a read-only root filesystem and log data to a remote server to prevent filesystem corruption.

Can Raspberry Pi run real-time applications? The standard Linux kernel is not deterministic enough for hard real-time. Use the PREEMPT_RT kernel patch for soft real-time with bounded latency around 100 microseconds. For hard real-time requirements below 10 microseconds, offload real-time tasks to a connected microcontroller such as the Raspberry Pi Pico.

How do I make my Raspberry Pi project battery-powered? Use a UPS HAT with 18650 Li-ion batteries for portable operation, or a high-quality 5 V power bank with 2.4 A output. The Pi 5 draws up to 5 W at peak load, requiring a minimum 3 A power supply. The Pi Zero 2 W draws approximately 0.8 W, making it suitable for battery-powered sensor nodes.

What is the best way to learn GPIO programming? Start with RPi.GPIO and the GPIO Zero Python library, which provides a higher-level interface with LED, Button, and Sensor classes. Build a project with an LED, then a button input with debouncing, then an I2C sensor such as the BME280.

Can I use Raspberry Pi in industrial applications? Yes, with the Compute Module 4 or 5 mounted on a custom carrier board. Industrial-rated cases with DIN rail mounting and extended temperature range modules (−40 to +85 °C) are available for harsh environments.

Related: Embedded Linux Guide | IoT Devices Guide

Frequently Asked Questions

What is the minimum system requirement for raspberry pi?

System requirements vary by implementation. Most modern solutions require at least 4GB of RAM, a multi-core processor, and a stable internet connection. For specific applications, refer to the vendor documentation. Hardware requirements typically increase with scale — enterprise deployments need significantly more resources than personal or small business setups.

How does this compare to alternative approaches?

Every technology choice involves trade-offs. Some prioritize ease of use over customization, while others offer maximum control at the cost of complexity. Evaluating your specific needs, technical expertise, and growth plans helps determine the right fit. Many organizations use a combination of approaches to balance competing priorities.

What security considerations should I be aware of?

Security should be considered from the start, not as an afterthought. Keep all software updated, use strong authentication, encrypt sensitive data, and follow the principle of least privilege. Regular security audits and staying informed about emerging threats are essential practices for maintaining a secure deployment.

How do I troubleshoot common issues?

Start by isolating the problem: check logs, verify configurations, and test components individually. Common issues include network connectivity problems, permission errors, and version incompatibilities. Systematic troubleshooting — changing one variable at a time — helps identify root causes efficiently. Online communities and documentation are valuable resources when you encounter unfamiliar problems.

Section: Embedded Systems 1711 words 9 min read Intermediate 756 articles in section Report inaccuracy Back to top