Raspberry Pi — Novice-to-Pro Developer Guide

Technology: raspberry-pi · Category: tooling · Last reviewed: 2026-10-20

Source: https://tech-stack.codeamanilabs.org/guide/raspberry-pi

Insight:

A Raspberry Pi is a full Linux computer the size of a credit card with a 40-pin GPIO header bolted to the side — so the same board both serves web apps and toggles real-world pins. Three rules decide everything: (1) the GPIO pins are 3.3V only — feed them 5V and you fry the SoC; (2) gpiozero speaks BCM numbering, never the physical pin position (BCM17 ≠ physical pin 17); (3) RAM is now the expensive part — after the 2026 memory-price rises a 16 GB Pi 5 lists at $305 while a 1 GB one is $45, so buy only the RAM the workload needs. Flash Raspberry Pi OS (Debian 13 "Trixie") with Imager, bake in an SSH public key before first boot, harden it like any server, and reach it through Raspberry Pi Connect or a tailnet — never an open port.

██████╗  █████╗ ███████╗██████╗ ██████╗ ███████╗██████╗ ██████╗ ██╗   ██╗    ██████╗ ██╗
██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝    ██╔══██╗██║
██████╔╝███████║███████╗██████╔╝██████╔╝█████╗  ██████╔╝██████╔╝ ╚████╔╝     ██████╔╝██║
██╔══██╗██╔══██║╚════██║██╔═══╝ ██╔══██╗██╔══╝  ██╔══██╗██╔══██╗  ╚██╔╝      ██╔═══╝ ██║
██║  ██║██║  ██║███████║██║     ██████╔╝███████╗██║  ██║██║  ██║   ██║       ██║     ██║
╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝     ╚═════╝ ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝       ╚═╝     ╚═╝

Raspberry Pi — Novice-to-Pro Developer Guide

Focus: A complete path from "I just bought a Pi" to shipping production edge workloads — hardware models and current prices, headless OS setup, security hardening, remote access, the 40-pin GPIO header and its 3.3V rule, the Python physical-computing stack (gpiozero, picamera2, lgpio), Node/TypeScript on the Pi, running local LLMs (Ollama, llama.cpp, AI HAT+ 2), experiments to run with Claude Code, and how the Pi compares to Arduino, ESP32, Jetson, and the Pi's own Pico microcontroller. Grounded in raspberrypi.com/documentation, the Raspberry Pi OS release notes, gpiozero.readthedocs.io and docs.ollama.com; reviewed 2026-10-20.

The Raspberry Pi is the rare device that is approachable on day one and still in your rack five years later. The trick is to learn it in the right order: get a headless, hardened Linux box running first (no monitor, no keyboard), then reach for the soldering iron. The interactive learn module above this page is a live 40-pin GPIO pinout explorer — start there to build intuition for the header, then use this reference.

Table of Contents

  1. What a Raspberry Pi actually is
  2. Pick the right board (and what it costs now)
  3. Headless OS setup (the right way)
  4. First-boot configuration
  5. Security hardening
  6. Remote access options
  7. The 40-pin GPIO header
  8. Physical computing with gpiozero
  9. The camera & other interfaces (I2C/SPI/UART)
  10. Node.js & TypeScript on the Pi
  11. Local LLMs and edge AI
  12. Hardware components shopping list
  13. Build ideas — novice to pro
  14. Experiments with Claude Code
  15. Raspberry Pi Pico (the microcontroller)
  16. Comparable tech stacks
  17. codeAmani notes

Official Documentation

Resource URL
Documentation hub https://www.raspberrypi.com/documentation/
Getting started (Imager + headless) https://www.raspberrypi.com/documentation/computers/getting-started.html
Raspberry Pi OS (updates, Python, venvs) https://www.raspberrypi.com/documentation/computers/os.html
Remote access (SSH, VNC, Connect, SCP, rsync) https://www.raspberrypi.com/documentation/computers/remote-access.html
Raspberry Pi Connect https://www.raspberrypi.com/documentation/services/connect.html
Computers / hardware reference + GPIO https://www.raspberrypi.com/documentation/computers/raspberry-pi.html
AI software (Hailo stack) https://www.raspberrypi.com/documentation/computers/ai.html
AI HATs https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html
OS release notes (kernel, changes) https://downloads.raspberrypi.com/raspios_lite_arm64/release_notes.txt
gpiozero (Python) https://gpiozero.readthedocs.io/en/stable/
picamera2 manual https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf
Datasheets https://datasheets.raspberrypi.com/
Ollama on Linux (arm64) https://docs.ollama.com/linux
Interactive pinout (community) https://pinout.xyz/

Current versions at a glance (verified 2026-10-20):

Thing Current Notes
Raspberry Pi OS Trixie (Debian 13; Debian point release 13.7), image 2026-10-06 Kernel 6.18.50 (moved off 6.12 in the 2026-06-18 image). Bookworm is the previous release.
System Python 3.13 PEP 668 blocks pip install into system Python — use apt or a venv
Raspberry Pi Imager v2.0.12 (2026-10-08) "Customisation" tab replaces the old ⚙ dialog
gpiozero 2.0.1.post3 Default pin factory lgpio; only lgpio works on the Pi 5
picamera2 0.3.38 (2026-10-12) Prefer sudo apt install python3-picamera2
lgpio (PyPI) 0.2.2.0 aarch64 wheels only up to cp312 — on Trixie use the apt package
rpi-lgpio 0.6 RPi.GPIO-compatible shim on lgpio — for legacy RPi.GPIO code
libgpiod (Debian gpiod) 2.2.1 v2 CLI (gpioget/gpioset/gpioinfo)
OpenSSH (Trixie) 10.0p1 DSA gone; Ed25519 default key type
Ollama 0.40.6 (2026-10-16) Official arm64 Linux build

1. What a Raspberry Pi actually is

A single-board computer (SBC): a complete ARM-based Linux computer — CPU, RAM, USB, HDMI, networking, storage (microSD or NVMe) — on one board, with a 40-pin GPIO header for talking to electronics. That dual nature is the whole point:

flowchart TB
  subgraph PI["Raspberry Pi — one board, two faces"]
    subgraph LINUX["Linux computer"]
      CPU["ARM64 SoC + RAM"]
      NET["Wi-Fi / Ethernet"]
      SD["microSD / NVMe: OS + storage"]
      USB["USB / HDMI / PCIe (Pi 5)"]
    end
    subgraph PHYS["Physical-computing face"]
      GPIO["40-pin GPIO header (3.3V)"]
      CSI["CSI: camera"]
      I2CSPI["I2C · SPI · UART buses"]
    end
  end
  LINUX -->|"same OS drives both"| PHYS
  WORLD["Sensors · motors · LEDs · displays"] --- GPIO
  CLOUD["Your web app · MQTT · cloud"] --- NET
  class GPIO pulse;
  class CPU pulse;

Why it matters: because it's real Linux, everything you already know — ssh, systemd, Docker, Python, Node, cron, nginx — works unchanged. And because it has GPIO, the same box that runs a web app can also read a temperature sensor or drive a relay. It is the cheapest honest "computer + I/O" you can buy.

Microcontroller vs SBC: A Pi runs a full OS and is great at software (servers, ML, networking). A microcontroller (Arduino, ESP32, the Pi Pico) runs one program on bare metal with precise real-time timing and microamp sleep. Many real projects pair them: Pi for brains + network, Pico/Arduino for the twitchy real-time pins. See §15 and §16.


2. Pick the right board (and what it costs now)

The 2026 reality: memory prices drive Pi prices. LPDDR4 costs rose so steeply through 2025–26 that Raspberry Pi raised prices four times (Dec 2025, 2 Feb 2026, Apr 2026, 1 Oct 2026). The 1 GB boards were held flat; everything with more RAM went up — the 16 GB Pi 5 more than doubled. Raspberry Pi's own advice: buy the RAM your workload needs, not headroom.

Board RAM options US list price (Oct 2026) Best for Notes
Pi Pico 2 / Pico 2 W — (RP2350 MCU) — Real-time sensors, battery Not Linux — a microcontroller (§15)
Pi Zero 2 W 512 MB check reseller Tiny always-on jobs, cameras Quad-core, Wi-Fi/BT; header often unpopulated
Pi 4 Model B 1 / 2 / 3 / 4 / 8 GB $35 / $67.50 / $83.75 / ~$100 / ~$165 Home server, NAS, kiosk 3 GB variant added Apr 2026 as a cheaper step
Pi 5 1 / 2 / 4 / 8 / 16 GB $45 / $77.50 / ~$110 / ~$175 / $305 Fast I/O, NVMe, local LLMs, edge AI BCM2712 (4× Cortex-A76 @ 2.4 GHz), PCIe; needs active cooling + 5V/5A PSU
Pi 500 / 500+ 8 / 16 GB $180 unit · $200 kit / from $410 Keyboard-in-a-box desktop (Pi 5-class) 500+ = mechanical keys + internal 256 GB SSD
Pi 400 4 GB $60 Cheapest all-in-one desktop Unaffected by the 2026 rises
Compute Module 4 / 5 up to 8 / 16 GB rose with RAM — check product page Your own carrier board / product CM5 is Pi 5-class (BCM2712)

Prices: 1 GB, 2 GB, 3 GB, Pi 400, Pi 500 and the Pi 5 16 GB are as published on raspberrypi.com product pages / news posts. The "~" figures are computed by adding the announced increases to the original list prices — confirm on the product page before you quote a customer. Approved Resellers honour the published maximum prices; avoid unauthorised sellers with inflated pricing.

flowchart LR
  Q1{"Need a full Linux OS?"}
  Q1 -->|No, just precise pins / battery| PICO["Pico 2 W / ESP32"]
  Q1 -->|Yes| Q2{"Tiny & low-power, or muscle?"}
  Q2 -->|Tiny always-on| ZERO["Pi Zero 2 W"]
  Q2 -->|Server / kiosk| Q3{"How much RAM does the app really use?"}
  Q3 -->|"≤ 1–2 GB (most services)"| PI51["Pi 5 1–2 GB · Pi 4 1–3 GB"]
  Q3 -->|"Local LLM / heavy containers"| PI58["Pi 5 8 GB (16 GB only if proven)"]
  Q3 -->|"LLM but RAM is pricey"| HAT["Pi 5 + AI HAT+ 2 (8 GB on the HAT)"]

Also buy (these are not optional): a quality power supply — the Pi 5 / Pi 500 want 5V at 5A (the official 27 W USB-C PSU); on a 5V/3A supply the Pi 5 limits USB peripherals to 600 mA. The Pi 4 wants 5V/3A. Under-volting causes mysterious crashes. Add a decent A2-rated microSD card (or better, NVMe via an M.2 HAT on the Pi 5) and, for the Pi 5, active cooling.


3. Headless OS setup (the right way)

You do not need a monitor or keyboard. The professional workflow is headless from minute one.

1. Flash with Raspberry Pi Imager (v2.x). Download from raspberrypi.com/software, pick your device, choose Raspberry Pi OS (64-bit) — Lite (no desktop) for servers. Then open the Customisation tab before writing (Imager 2 replaced the old ⚙ "Edit settings" dialog):

flowchart LR
  A["Imager 2.x"] e1@--> B["Device + OS (Lite 64-bit)"]
  B e2@--> C["Customisation:<br/>hostname · locale · user · Wi-Fi<br/>SSH public key · Connect key"]
  C e3@--> D["Write + verify"]
  D e4@--> E["Insert media, power on"]
  E e5@--> F["ssh amani@amani-pi.local"]
  e1@{ animate: true }
  e2@{ animate: true }
  e3@{ animate: true }
  e4@{ animate: true }
  e5@{ animate: true }
  class C glow;

2. Boot and SSH in — no screen required:

# From your laptop (mDNS resolves <hostname>.local — or .lan — on the same network)
ssh amani@amani-pi.local
# or by IP if .local doesn't resolve:
ssh amani@192.168.1.42

# First things first
sudo apt update && sudo apt full-upgrade -y
sudo reboot

If *.local doesn't resolve (some Windows/Android setups), find the IP from your router's DHCP table. On Windows, install Bonjour or just use the IP.

No Imager? On the bootfs partition create an empty file named ssh plus a userconf.txt containing one line, <username>:<encrypted-password> — generate the hash with openssl passwd -6 (on macOS use Homebrew OpenSSL; LibreSSL lacks -6). Imager customisation is still the better path because it can install your public key.


4. First-boot configuration

Know what changed in 2026 images:

raspi-config is the official text UI for system settings; most of it is scriptable:

sudo raspi-config            # interactive: interfaces, locale, hostname, boot, sudo
sudo raspi-config nonint do_i2c 0    # enable I2C non-interactively (0 = enable)
sudo raspi-config nonint do_spi 0    # enable SPI
sudo raspi-config nonint do_ssh 0    # ensure SSH on

Interfaces can also be toggled directly in /boot/firmware/config.txt via device-tree params — useful in provisioning scripts and Ansible:

# /boot/firmware/config.txt  — enable buses at boot
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
# camera autodetect is on by default on current Pi OS:
camera_auto_detect=1
# Sanity checks after enabling
ls /dev/i2c-*          # I2C bus appears
ls /dev/spidev*        # SPI device appears
i2cdetect -y 1         # scan the I2C bus (sudo apt install i2c-tools)
vcgencmd measure_temp  # SoC temperature — watch for throttling
vcgencmd get_throttled # 0x0 = no under-voltage / throttling since boot

5. Security hardening

A Pi on a network is a server. Treat it like one — the defaults are better than they were (no default account, sudo asks for a password) but SSH still accepts passwords until you turn them off. Full SSH depth lives in the remote-access guide; this is the Pi-specific minimum.

1. Keys only, no root, via a drop-in (Debian's sshd_config includes /etc/ssh/sshd_config.d/*.conf, so you never edit the main file):

# On your laptop — if you didn't paste a key into Imager
ssh-keygen -t ed25519 -C "you@laptop"
ssh-copy-id amani@amani-pi.local

# On the Pi — confirm key login works in a SECOND terminal first, then:
sudo tee /etc/ssh/sshd_config.d/10-hardening.conf >/dev/null <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
AllowUsers amani
EOF
sudo sshd -t && sudo systemctl reload ssh   # validate before reloading

2. Firewall — default-deny inbound (ufw 0.36.2 in Trixie, an nftables front end):

sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp   # SSH from the LAN only
# sudo ufw allow in on tailscale0                              # if you use a tailnet (§6)
sudo ufw enable
sudo ufw status verbose

Allow SSH before ufw enable or you lock yourself out of a headless box. If you only reach the Pi via Raspberry Pi Connect or Tailscale, you can drop the LAN SSH rule entirely — both work outbound-only.

3. Automatic security updates with unattended-upgrades (2.12 in Trixie). Debian's default config covers the Debian security archive; add Raspberry Pi's own archive (its Release file declares Origin: Raspberry Pi Foundation, Codename: trixie) so firmware/kernel fixes land too:

sudo apt install -y unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgrades     # writes /etc/apt/apt.conf.d/20auto-upgrades

sudo tee /etc/apt/apt.conf.d/52raspi-origins >/dev/null <<'EOF'
Unattended-Upgrade::Origins-Pattern {
        "origin=Raspberry Pi Foundation,codename=${distro_codename},label=Raspberry Pi Foundation";
};
// Field nodes: reboot in a quiet window if a kernel update needs it
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:30";
EOF
sudo unattended-upgrade --dry-run --debug 2>&1 | tail -20   # verify the origins match

Automatic updates stay within Trixie. Never let anything dist-upgrade across major releases unattended — reimage instead (§4). Avoid rpi-update (pre-release firmware) on anything in the field.

4. Brute-force protection. OpenSSH 10 (Trixie) has built-in per-source penalties (PerSourcePenalties) that throttle repeat offenders; with password auth off and SSH not exposed to the internet, fail2ban is optional. Add it if SSH must face the internet — but the better answer is not exposing it (§6).

5. Hygiene checklist: unique hostname + user per device · secrets in EnvironmentFiles with chmod 600 (never in the image) · disable services you don't use (systemd-analyze blame, systemctl disable --now <unit>) · rpi-connect shell off if you use Connect only for screen sharing · back up the SD/NVMe image before risky changes.


6. Remote access options

The question is how do I reach a Pi that isn't on my desk — and the answer is almost never "port-forward 22 on the router". Pick by situation; the remote-access guide has the full SSH/tunnel/VPN depth.

Option How it reaches the Pi Best for Cost
SSH on the LAN Direct TCP 22 Same network, dev bench Free
Raspberry Pi Connect Pi connects out to Raspberry Pi's service; browser ↔ Pi is WebRTC peer-to-peer, falling back to a TURN relay Remote shell / screen share from any browser; remote OTA updates for fleets Personal accounts free; Connect for Organisations billed monthly
Tailscale (managed WireGuard mesh) Outbound to coordination server, then P2P WireGuard Reaching many Pis + services by MagicDNS name, identity-gated Free personal tier
WireGuard (self-hosted) UDP to your own VPN endpoint Full control, no third party Free (you run it)
Cloudflare Tunnel Outbound-only cloudflared Publishing an HTTPS service on the Pi (dashboards, Daraja callbacks) Free tier

Raspberry Pi Connect (Bookworm or later; screen sharing needs a Wayland desktop, so Lite images use Connect Lite = remote shell only):

sudo apt update
sudo apt install rpi-connect-lite      # Lite / headless (remote shell only)
# sudo apt install rpi-connect         # desktop images (adds screen sharing)
rpi-connect on
rpi-connect signin                     # prints a connect.raspberrypi.com/verify/... URL
loginctl enable-linger                 # keep Connect running with no one logged in (headless!)
rpi-connect doctor                     # checks STUN/TURN, API reachability

Connect also does remote updates: install rpi-connect-ota, opt in with rpi-connect ota on, then push either script artefacts (built with otamaker, run as root — e.g. package upgrades) or full A/B boot images (built with rpi-image-gen, auto-revert on failure; needs Pi 4+ imaged with an A/B layout on Trixie). That is the first-party answer to "update 50 kiosks behind 50 different routers".

Data-flow note: Connect sessions are end-to-end encrypted (WebRTC/DTLS, fresh keys per session); when P2P fails, encrypted traffic relays via Raspberry Pi's TURN servers in London (Europe/Africa) or California (Americas/Asia/Oceania), and relaying cannot be disabled except by firewalling the TURN hosts. Access is gated by a Raspberry Pi ID — turn on its 2FA. Connect runs as a user service, hence loginctl enable-linger. For devices in PCI or customer-data scope, prefer a tailnet with your own ACLs and keep Connect's remote shell off (rpi-connect shell off).


7. The 40-pin GPIO header

Every current Pi (and the Zero, sometimes unpopulated) exposes a 40-pin header on a 0.1in (2.54 mm) pitch. The single rule that saves your board:

⚠️ GPIO is 3.3V logic, not 5V. The pins source/sink 3.3V and are not 5V-tolerant — putting 5V on a GPIO input can permanently damage the SoC. There are two 5V pins (for powering peripherals) and several 3V3 and GND pins, but every signal pin is 3.3V. Use a level shifter for 5V sensors, or hang them off a Pico instead.

The header is a fixed standard across boards. The layout (physical pin → function):

Pin Function Pin Function
1 3V3 power 2 5V power
3 GPIO2 (I2C SDA) 4 5V power
5 GPIO3 (I2C SCL) 6 GND
7 GPIO4 (GPCLK0) 8 GPIO14 (UART TXD)
9 GND 10 GPIO15 (UART RXD)
11 GPIO17 12 GPIO18 (PCM/PWM)
13 GPIO27 14 GND
15 GPIO22 16 GPIO23
17 3V3 power 18 GPIO24
19 GPIO10 (SPI MOSI) 20 GND
21 GPIO9 (SPI MISO) 22 GPIO25
23 GPIO11 (SPI SCLK) 24 GPIO8 (SPI CE0)
25 GND 26 GPIO7 (SPI CE1)
27 GPIO0 (ID EEPROM) 28 GPIO1 (ID EEPROM)
29 GPIO5 30 GND
31 GPIO6 32 GPIO12 (PWM)
33 GPIO13 (PWM) 34 GND
35 GPIO19 (PCM/SPI1) 36 GPIO16
37 GPIO26 38 GPIO20 (PCM/SPI1)
39 GND 40 GPIO21 (PCM/SPI1)

BCM vs physical numbering — the #1 beginner trap. Software (gpiozero, lgpio, libgpiod line offsets on the main GPIO chip) addresses pins by Broadcom (BCM) GPIO number, not by physical position. LED(17) means BCM17, which sits at physical pin 11 — not physical pin 17 (that's a 3V3 power pin). When in doubt, run pinout on the Pi:

pinout       # ASCII diagram of YOUR board's header (ships with gpiozero)
gpioinfo     # libgpiod v2: every chip and line, with names (sudo apt install gpiod)

8. Physical computing with gpiozero

gpiozero is the official, beginner-friendly Python library — it wraps pins as devices (LED, Button, Servo, DistanceSensor) so you write intent, not register pokes. It's pre-installed on Raspberry Pi OS desktop images; on Lite:

sudo apt install python3-gpiozero      # recommended — pulls python3-lgpio and the `pinout` tool

In a virtual environment, inherit the system packages. Trixie's Python is 3.13 and PyPI's lgpio has no 3.13 aarch64 wheel, so pip install lgpio tries to compile. The documented fix is a venv that can see apt's python3-lgpio / python3-picamera2:

python3 -m venv --system-site-packages ~/myapp/.venv
source ~/myapp/.venv/bin/activate
pip install paho-mqtt                  # your app's own deps go in the venv

Which backend? gpiozero's docs are explicit: "Only lgpio works on the Pi 5." RPi.GPIO (last release 0.7.1, 2022) and pigpio don't support the Pi 5's RP1 I/O chip. rpi-lgpio is an RPi.GPIO-compatible shim on lgpio — use it only to run legacy RPi.GPIO code on a Pi 5, not for new gpiozero code. Raspberry Pi OS Trixie also removed the old "Remote GPIO" option.

Blink an LED (LED on BCM17 = physical pin 11, through a ~330Ω resistor to GND):

from gpiozero import LED
from time import sleep

led = LED(17)            # BCM17 — NOT physical pin 17
while True:
    led.toggle()
    sleep(0.5)

Button toggles LED — event-driven, no polling loop:

from gpiozero import LED, Button
from signal import pause

led = LED(17)
button = Button(2)       # BCM2, with internal pull-up by default

button.when_pressed = led.on
button.when_released = led.off
pause()                  # sleep forever, let callbacks fire

PWM for brightness / motor speed:

from gpiozero import PWMLED
from time import sleep

led = PWMLED(17)
led.value = 0.1          # 10% duty cycle
sleep(1)
led.pulse()              # smooth fade in/out in a background thread
sleep(5)

gpiozero uses BCM numbering and it is not configurable — but you can pass alternate notations that all resolve to BCM: LED(17), LED("GPIO17"), LED("BOARD11") (physical), or LED("J8:11") (header:pin).

Unit-test pin logic on your laptop with the mock pin factory — no hardware, no Pi:

env GPIOZERO_PIN_FACTORY=mock python3 -m pytest tests/
flowchart TB
  APP["Your Python script"] --> GZ["gpiozero (device abstractions)"]
  GZ --> BK{"Pin factory"}
  BK --> LG["lgpio (default; the only one on Pi 5)"]
  BK --> MOCK["mock (laptop unit tests)"]
  LG --> CHIP["/dev/gpiochip* (kernel GPIO char device)"]
  CHIP --> HW["40-pin header"]

9. The camera & other interfaces (I2C/SPI/UART)

Camera (CSI ribbon → picamera2). Modern Pi OS autodetects official camera modules. picamera2 is the supported Python API (the old picamera is deprecated). Install it from apt — it depends on system libcamera:

sudo apt install -y python3-picamera2                            # desktop images
sudo apt install -y python3-picamera2 --no-install-recommends    # Lite OS, no GUI deps
from picamera2 import Picamera2
from time import sleep

picam2 = Picamera2()
picam2.start()
sleep(2)                       # let auto-exposure settle
picam2.capture_file("shot.jpg")
picam2.stop()
rpicam-still -o test.jpg       # CLI capture (formerly libcamera-still)
rpicam-hello -t 5000           # 5s preview to confirm the camera is detected

The three buses, in one breath:

Bus Pins (BCM) Use it for Enable
I2C SDA=2, SCL=3 Many low-speed sensors/displays sharing 2 wires by address dtparam=i2c_arm=on
SPI MOSI=10, MISO=9, SCLK=11, CE0=8 Fast displays, ADCs, SD/flash dtparam=spi=on
UART TXD=14, RXD=15 Serial to a Pico/Arduino/GPS/modem console off, enable_uart=1
i2cdetect -y 1        # find I2C device addresses (e.g. 0x3c for an OLED, 0x76 for BME280)

10. Node.js & TypeScript on the Pi

The Pi is ARM64 Debian, so Node runs natively (install from NodeSource or nvm; keep to an LTS line). The interesting question is GPIO from Node, and the honest 2026 answer is: most Node GPIO packages are stale.

Package Latest Status on Pi 5 / Trixie
onoff 6.0.3 (2022) Uses the deprecated sysfs GPIO interface — avoid for new work
rpio, pigpio (npm) 2.4.2 / 3.3.1 (2022) Pre-Pi 5 register access — does not work with RP1
node-libgpiod 0.6.0 (Jan 2026) Character-device API, but its README targets libgpiod 1.5/1.6; Trixie ships libgpiod 2.2.1 — unverified, test before relying on it

The codeAmani pattern: keep pin I/O in a small Python gpiozero service (the officially supported path) and let Node/TypeScript talk to it over MQTT or a local HTTP socket — or, for one-off reads/writes, call the libgpiod v2 CLI (gpioget/gpioset) with execFile and an argument array (never a shell string, per our security convention). Node's real job on the Pi is the networked app: dashboards, telemetry agents, and talking to a local LLM.

Example — a dependency-free health probe (runs on any Pi with Node ≥ 20; full version with POSTing in examples/pi-health.mts):

import { execFile } from "node:child_process";
import { readFile } from "node:fs/promises";
import { promisify } from "node:util";

const run = promisify(execFile);

export interface PiHealth {
  socTempC: number;
  throttledHex: string;
  underVoltageSinceBoot: boolean;
  throttledSinceBoot: boolean;
}

export async function readPiHealth(): Promise<PiHealth> {
  // millidegrees C, e.g. "48300\n"
  const raw = await readFile("/sys/class/thermal/thermal_zone0/temp", "utf8");
  // args as an array — no shell interpolation
  const { stdout } = await run("vcgencmd", ["get_throttled"]); // "throttled=0x50005\n"
  const hex = stdout.trim().split("=")[1] ?? "0x0";
  const bits = Number.parseInt(hex, 16);
  return {
    socTempC: Number(raw.trim()) / 1000,
    throttledHex: hex,
    underVoltageSinceBoot: (bits & (1 << 16)) !== 0,
    throttledSinceBoot: (bits & (1 << 18)) !== 0,
  };
}

11. Local LLMs and edge AI

Raspberry Pi's own framing: most edge AI/ML belongs on the CPU; accelerators are for the minority of workloads the CPU can't handle. For language models you have three tiers:

Tier Hardware Software What fits Reality check
CPU only Pi 5, 8 GB (16 GB if proven needed) Ollama (official arm64 build) or llama.cpp ~0.6–4B params at 4-bit: qwen3:0.6b/1.7b/4b, gemma3:1b, llama3.2:1b/3b, granite4:1b/3b, gemma4:e2b Usable for short, scoped prompts (classify, extract, summarise a reading). Measure tokens/s on your board and cooling.
AI HAT+ 2 Pi 5 + Hailo-10H, 40 TOPS (INT4), 8 GB on-HAT RAM, $200 sudo apt install dkms hailo-h10-all → hailo-ollama (Ollama-compatible REST API, default port 8000) Hailo-compiled models only: Qwen2/2.5 1.5B, Qwen2.5-Coder 1.5B, Qwen3 1.7B, Llama 3.2 1B, DeepSeek-R1-Distill-Qwen 1.5B, plus VLMs Frees the Pi's own RAM/CPU; model choice is limited to Hailo's GenAI zoo
Vision NPU AI HAT+ (Hailo-8L 13 TOPS / Hailo-8 26 TOPS), legacy AI Kit, AI Camera (Sony IMX500) sudo apt install dkms hailo-all · sudo apt install imx500-all Detection/segmentation/pose — not LLMs (the AI docs: LLMs are AI HAT+ 2 only) Pair a vision NPU with a CPU/cloud LLM for "see → describe"

Third-party option: the Sixfab AI HAT+ (DEEPX DX-M1M, 25 TOPS at ~3 W, 2 GB on-module) runs CNNs, compact VLMs and SLMs — Raspberry Pi's own post measured Qwen3-1.7B at 4.64 tok/s on it (Pi 5 8 GB).

CPU path — Ollama (official installer creates the ollama user + systemd unit; API on http://localhost:11434):

curl -fsSL https://ollama.com/install.sh | sh
ollama pull qwen3:1.7b
ollama run qwen3:1.7b "Classify: 'pump pressure dropped to 0.8 bar' -> ok|warn|fail"

# Expose to the LAN/tailnet only if you must — via a systemd override, then firewall it:
sudo systemctl edit ollama        # [Service] Environment="OLLAMA_HOST=0.0.0.0:11434"

Ollama's API has no authentication. Keep it on 127.0.0.1 and put your app in front of it, or bind it only to the tailscale0 interface and restrict with ufw. Never port-forward it.

llama.cpp is the engine underneath; build it on the Pi (cmake -B build && cmake --build build -j4, releases are tagged bNNNNN — b11755 on 2026-10-20) when you want llama-server's OpenAI-compatible endpoint, GGUF files you control, or tighter memory tuning than Ollama exposes.

AI HAT+ 2 path — hailo-ollama:

sudo apt update && sudo apt full-upgrade -y
sudo apt install dkms
sudo apt install hailo-h10-all
sudo reboot
# Hailo Model Zoo GenAI (v5.4.0) provides the hailo-ollama server:
hailo-ollama &
curl --silent http://localhost:8000/hailo/v1/list
curl --silent http://localhost:8000/api/pull -H 'Content-Type: application/json' \
     -d '{ "model": "qwen2:1.5b", "stream": true }'

Because both servers speak the Ollama /api/chat shape, the same TypeScript client works against either — see examples/ollama-chat.mts:

interface ChatMessage { role: "system" | "user" | "assistant"; content: string }
interface ChatResponse { model: string; message: ChatMessage; done: boolean; eval_count?: number; eval_duration?: number }

export async function chat(baseUrl: string, model: string, messages: ChatMessage[]): Promise<ChatResponse> {
  const res = await fetch(`${baseUrl}/api/chat`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ model, messages, stream: false }),
    signal: AbortSignal.timeout(120_000), // small boards are slow on first load
  });
  if (!res.ok) throw new Error(`chat failed: ${res.status} ${await res.text()}`);
  return (await res.json()) as ChatResponse;
}

// CPU Ollama:   chat("http://127.0.0.1:11434", "qwen3:1.7b", msgs)
// hailo-ollama: chat("http://127.0.0.1:8000",  "qwen2:1.5b", msgs)

Routing rule (codeAmani AI policy): the on-device model is the offline fallback and the privacy-first classifier, not the brain. Complex reasoning and code generation still route to Claude; structured output to GPT-4o — when the link is up. See §17.


12. Hardware components shopping list

A starter kit that covers 90% of beginner projects:

The cardinal hardware rules: common ground between Pi and any external supply; never source motor/relay current from a GPIO pin; level-shift anything 5V; and double-check polarity before powering on.


13. Build ideas — novice to pro

flowchart LR
  N["NOVICE<br/>blink · button · buzzer<br/>web 'hello' on the LAN"]
  --> I["INTERMEDIATE<br/>weather station (BME280→DB)<br/>Pi-hole · home VPN · NAS<br/>time-lapse camera"]
  --> A["ADVANCED<br/>MQTT sensor mesh<br/>Kiosk / digital signage<br/>Home Assistant hub"]
  --> P["PRO<br/>Offline LLM assistant (AI HAT+ 2)<br/>Fleet with Connect OTA<br/>Product on a Compute Module"]

14. Experiments with Claude Code

Claude Code runs on the Pi (it's just ARM64 Linux) or drives it remotely over SSH from your laptop. Both unlock fast hardware iteration: describe the circuit and the behaviour, let Claude write the gpiozero script, run it, read the output, and iterate. For the current install method see the anthropic guide — on a 1–2 GB Pi prefer driving it over SSH from your laptop rather than running the agent locally.

Experiments that play to Claude Code's strengths:

  1. Conversational circuit bring-up. "I wired a BME280 to I2C and an SSD1306 OLED — read temp/humidity every 10 s and show it on the display." Claude writes it; i2cdetect -y 1 confirms addresses; you run and refine.
  2. Hardware-in-the-loop TDD. Claude writes tests against gpiozero's mock pin factory (env GPIOZERO_PIN_FACTORY=mock) so logic is unit-tested on your laptop, then deployed to real pins.
  3. Sensor → cloud pipeline. "Publish each reading to MQTT and also POST to a Next.js API route." Pairs with the webhooks and supabase guides.
  4. Local LLM on the edge. Run qwen3:1.7b under Ollama (or a Hailo model on AI HAT+ 2) and have Claude Code build the glue: an assistant that classifies sensor events offline and syncs when connectivity returns.
  5. Vision on the edge. AI Camera or AI HAT+: Claude scaffolds a picamera2 capture loop feeding a detector, writing events to a DB.
  6. Harden and verify. Ask Claude to audit the box: sshd -T, ufw status verbose, unattended-upgrade --dry-run, systemd-analyze security <unit> — and fix what it finds.

Run Claude Code over SSH for the tightest loop: edit on the laptop, execute on the Pi, watch real sensor output stream back. Pair with chrome-devtools to verify any web UI the Pi serves.


15. Raspberry Pi Pico (the microcontroller)

The Pico is a different animal: a microcontroller board built on the in-house RP2040 (Pico/Pico W) or RP2350 (Pico 2 / Pico 2 W) chip — not a Linux computer. The RP2350 keeps the dual-core, dual-PIO design but adds switchable Arm Cortex-M33 or RISC-V (Hazard3) cores, more SRAM, and secure/signed boot. No OS, no SD card; you flash one program that runs on bare metal. It shines where the Pi is weak: precise real-time timing, microamp sleep, true analog inputs (ADC), and being cheap enough to scatter — and its price isn't hostage to LPDDR4.

flowchart LR
  subgraph SBC["Raspberry Pi (SBC)"]
    OS["Full Linux · network · ML · servers"]
  end
  subgraph MCU["Raspberry Pi Pico (MCU)"]
    BM["Bare-metal · real-time pins · ADC · µA sleep"]
  end
  MCU -->|"UART / I2C / USB / MQTT"| SBC
  SBC -->|"brains + internet"| CLOUD["Cloud / dashboard"]

Two ways to program it:

# MicroPython (drag-and-drop firmware, then this is main.py) — blink the onboard LED
from machine import Pin
from time import sleep
led = Pin("LED", Pin.OUT)
while True:
    led.toggle()
    sleep(0.5)
// C/C++ with the Pico SDK — pico-examples style
#include "pico/stdlib.h"
int main() {
    const uint LED = PICO_DEFAULT_LED_PIN;
    gpio_init(LED); gpio_set_dir(LED, GPIO_OUT);
    while (true) { gpio_put(LED, 1); sleep_ms(250); gpio_put(LED, 0); sleep_ms(250); }
}

Pico W (RP2040) and Pico 2 W (RP2350) add 2.4 GHz Wi-Fi + Bluetooth, so they can publish to MQTT on their own. The classic architecture: Picos at the edge (sensors, real-time control) talking to a Pi hub (network, storage, dashboard).


16. Comparable tech stacks

Platform Type Pick it when
Arduino (Uno/Nano) MCU Dead-simple 5V I/O, huge tutorial base, no networking needed
ESP32 MCU + Wi-Fi/BT Cheap connected sensors; battery IoT (the budget IoT king)
Raspberry Pi Pico 2 / Pico 2 W MCU (RP2350) Real-time control, PIO, MicroPython/C, very cheap
NVIDIA Jetson (Orin Nano) SBC + GPU On-device deep-learning / larger LLMs a Pi 5 + HAT can't keep up with
Hailo / DEEPX / Coral accelerators NPU add-ons Fast, low-power inference added to a Pi
BeagleBone SBC Hard real-time via PRUs, industrial I/O
Orange Pi / Radxa / Banana Pi SBC More specs per dollar; software/community less polished
x86 mini-PCs (N100-class) x86 You need x86 compatibility — and at 2026 Pi 5 8–16 GB prices, often comparable cost
flowchart TB
  Q{"What do you need?"}
  Q -->|"Heavy ML / bigger LLMs"| JET["Jetson · or Pi 5 + AI HAT+ 2"]
  Q -->|"Cheap Wi-Fi sensor"| ESP["ESP32 / Pico 2 W"]
  Q -->|"Real-time, no OS"| PICO["Pico 2 / Arduino"]
  Q -->|"Linux box + GPIO<br/>(the all-rounder)"| RPI["Raspberry Pi"]
  Q -->|"Lots of RAM, no GPIO"| X86["x86 mini-PC"]

The honest summary: the Pi wins on ecosystem — documentation, community answers, first-party tooling (Imager, Connect, OS updates), and "it just works" software. Rivals win on specific axes (price-per-GB in 2026, GPU, battery life, real-time determinism). Most serious builds are hybrids: a Pi for brains + a Pico/ESP32 for the real-time edge.


17. codeAmani notes

Official docs: