The complete guide to Raspberry Pi single-board computers - From beginner projects to advanced applications
Raspberry Pi is a series of small single-board computers developed in the UK to promote teaching of basic computer science in schools and developing countries.
Raspberry Pi has evolved through several generations with increasing capabilities:
| Model | Release Year | Processor | RAM | Key Features | Price |
|---|---|---|---|---|---|
| Pi Zero W | 2017 | 1GHz single-core | 512MB | Miniature size, WiFi/BT | $10 |
| Pi 3 Model B | 2016 | 1.2GHz quad-core | 1GB | First with WiFi/BT | $35 |
| Pi 3 Model B+ | 2018 | 1.4GHz quad-core | 1GB | Faster Ethernet, WiFi | $35 |
| Pi 4 Model B | 2019 | 1.5GHz quad-core | 2GB/4GB/8GB | USB 3.0, dual 4K output | $35-$75 |
| Compute Module 4 | 2020 | 1.5GHz quad-core | 1GB-8GB | Industrial form factor | $25-$90 |
| Pi 400 | 2020 | 1.8GHz quad-core | 4GB | Keyboard integrated | $70 |
The most powerful general-purpose Pi with desktop performance
Ultra-compact board with quad-core performance
Microcontroller board with RP2040 chip
Industrial form factor for embedded applications
The Raspberry Pi 4 represents a significant performance leap over previous models.
| Component | Specification |
|---|---|
| SoC | Broadcom BCM2711 (Cortex-A72) |
| CPU | 4-core 1.5GHz (64-bit) |
| GPU | VideoCore VI (500MHz) |
| Memory | LPDDR4 (2GB/4GB/8GB) |
| Connectivity | 2.4/5GHz WiFi, BT 5.0, Gigabit Ethernet |
| Video Output | 2 × micro-HDMI (4K @ 60fps) |
| USB | 2 × USB 3.0, 2 × USB 2.0 |
# Basic Python script to blink an LED
import RPi.GPIO as GPIO
import time
LED_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
GPIO.output(LED_PIN, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED_PIN, GPIO.LOW)
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
Turn your Pi into a retro gaming console
Using Home Assistant to control smart devices:
# Install Home Assistant
sudo apt update
sudo apt install -y python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
# Create virtual environment
python3 -m venv homeassistant
cd homeassistant
source bin/activate
# Install Home Assistant Core
python3 -m pip install wheel
pip install homeassistant
# Start Home Assistant
hass
Creating a mini supercomputer with multiple Pis:
# On manager node
docker swarm init --advertise-addr <MANAGER_IP>
# On worker nodes
docker swarm join --token <TOKEN> <MANAGER_IP>:2377
# Deploy a service
docker service create --name nginx --replicas 3 -p 80:80 nginx
Using OpenCV and TensorFlow Lite:
# Install dependencies
sudo apt install libatlas-base-dev libopenjp2-7 libtiff5
pip3 install opencv-python numpy tflite-runtime
# Sample object detection code
import cv2
import tflite_runtime.interpreter as tflite
# Load TFLite model
interpreter = tflite.Interpreter(model_path="model.tflite")
interpreter.allocate_tensors()
# Process camera input
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
# Preprocess and run inference
input_data = preprocess(frame)
interpreter.set_tensor(input_index, input_data)
interpreter.invoke()
output_data = interpreter.get_tensor(output_index)
# Draw detections
draw_boxes(frame, output_data)
cv2.imshow('Object Detection', frame)