N5JLD dot NET

What I do in my Spare Time

User Tools

Site Tools


electronics:mcu:raspberry_pi

Electronics Reference: Raspberry Pi Hardware & Embedded Electronics

`3.3 V` UNBUFFERED GPIO & POWER MANDATE: All Raspberry Pi models operate strictly at `3.3 V` logic—their GPIO pins are NOT `5.0 V` tolerant and lack heavy external ESD/over-voltage clamping. Applying `5.0 V` directly to any GPIO pin or drawing more than `16 mA` per pin (`50 mA` total) can permanently destroy the Broadcom SoC. Always use a regulated `5.0 V` power supply rated for peak current (`3.0 A – 5.0 A`) and shut down the OS cleanly (`sudo shutdown -h now`) before disconnecting power.

1. Raspberry Pi Model Comparison Matrix

Select the appropriate Raspberry Pi Single-Board Computer (SBC) or microcontroller board based on compute load, power budget, and physical form factor:

Model SoC / Processor RAM Options Power Input Requirement Key Hardware Interfaces Best Embedded & UAS Roles
Raspberry Pi 5 Broadcom `BCM2712` (Quad-Core Cortex-A76 @ `2.4 GHz`) + `RP1` I/O Controller 4 GB / 8 GB LPDDR4X USB-C PD (`5.1 V / 5.0 A` = `25 W`) PCIe 2.0 x1 FFC, dual 4-lane MIPI CSI/DSI, 2× USB 3.0, Gigabit Ethernet (PoE+ capable), RTC header Real-time computer vision, LiDAR point-cloud processing, ROS2 companion computer, AI inference
Raspberry Pi 4 Model B Broadcom `BCM2711` (Quad-Core Cortex-A72 @ `1.8 GHz`) 2 GB / 4 GB / 8 GB LPDDR4 USB-C (`5.1 V / 3.0 A` = `15 W`) 2× USB 3.0, 2× USB 2.0, Gigabit Ethernet, 2-lane MIPI CSI/DSI, dual micro-HDMI MAVLink telemetry bridge, ground control relay, network video recorder, edge gateway
Raspberry Pi Zero 2 W Broadcom `BCM2710A1` (Quad-Core Cortex-A53 @ `1.0 GHz`) 512 MB LPDDR2 Micro-USB (`5.0 V / 2.5 A`) 1× Micro-USB OTG, mini-HDMI, CSI-2 camera connector, Wi-Fi 4 + BLE 4.2 (`65 mm × 30 mm`) Lightweight onboard drone companion computer, ultra-compact telemetry logger
Raspberry Pi Compute Module 4 / 5 (`CM4` / `CM5`) Same as Pi 4 / Pi 5 (in compact SOM form factor) 1 GB – 8+ GB (Optional eMMC flash) `5.0 V` via high-density board-to-board connectors Exposes PCIe, dual CSI/DSI, eMMC (no fragile SD card), industrial temperature options Custom carrier PCBs, ruggedized flight avionics (e.g., Pixhawk/ArduPilot carrier boards)
Raspberry Pi Pico / Pico 2 *(Microcontroller)* `RP2040` (Dual Cortex-M0+) / `RP2350` (Dual Cortex-M33 / RISC-V) 264 KB / 520 KB SRAM `1.8 V – 5.5 V` (VSYS) Programmable I/O (PIO) state machines, 12-bit ADC, UART/SPI/I2C, USB 1.1 (`No Linux OS`) Deterministic real-time motor/servo control, custom protocol bridges, hardware co-processor

2. 40-Pin GPIO Header Architecture & Pinout Rules

All modern Raspberry Pi SBCs share a standardized 40-pin (`2×20`, `0.1“` pitch) GPIO header. Always distinguish between Physical Board Pin Numbers (`1–40`) and Broadcom `BCM` GPIO Numbers (`GPIO 0–27`).

2.1 Power Pins on the 40-Pin Header

  • `5V` Power Pins (`Pins 2 & 4`): Connected directly to the incoming `5 V` power rail (not regulated down by the Pi). Can either supply `5 V` to external sensors (up to ~`1.0 A – 1.5 A` depending on PSU headroom) OR back-power the Raspberry Pi directly from a high-current BEC/buck converter (bypasses USB-C fuse protection—add an external `3 A – 5 A` fuse if powering via Pins 2/4).
  • `3V3` Power Pins (`Pins 1 & 17`): Output-only regulated `3.3 V` rail (`~500 mA` max on Pi 4/5). Never apply external voltage into a `3V3` pin.
  • `GND` Pins (`Pins 6, 9, 14, 20, 25, 30, 34, 39`): Common ground return paths distributed evenly along the header to minimize loop inductance.

2.2 Reserved & Special-Function GPIO Pins

Physical Pin(s) BCM GPIO Default / Alternate Hardware Function Electronics Design Notes
`Pin 3` & `Pin 5` `GPIO 2 (SDA1)` & `GPIO 3 (SCL1)` Primary Hardware `I2C1` Bus Includes fixed onboard `1.8 kΩ` pull-up resistors to `3.3 V`. Do not add strong external pull-ups; `Pin 5` also wakes the Pi from halt state when pulled `LOW`.
`Pin 8` & `Pin 10` `GPIO 14 (TXD)` & `GPIO 15 (RXD)` Primary Hardware `UART0` Serial Used by Linux serial console by default—disable serial login shell in `raspi-config` before connecting a flight controller (`MAVLink`) or GPS module.
`Pins 19, 21, 23, 24, 26` `GPIO 10 (MOSI), 9 (MISO), 11 (SCLK), 8 (CE0), 7 (CE1)` Hardware `SPI0` Bus High-speed synchronous bus for ADCs (`MCP3008`), CAN controllers (`MCP2515`), and TFT screens.
`Pin 27` & `Pin 28` `GPIO 0 (ID_SD)` & `GPIO 1 (ID_SC)` HAT ID EEPROM (`I2C0`) Reserved exclusively for reading configuration EEPROMs on official Raspberry Pi HAT add-on boards at boot. Leave unconnected in custom circuits.
`Pins 12, 32, 33, 35` `GPIO 18, 12, 13, 19` Hardware `PWM` Channels Use hardware PWM pins for jitter-free servo/ESC control rather than software-timed PWM (Linux multitasking causes jitter on non-PWM pins).

3. Critical Interfacing Rules & Missing Analog Inputs

  • No Built-In Analog-to-Digital Converter (ADC): Unlike Arduino, ESP32, or STM32 boards, Raspberry Pi SBCs (`Pi 4`, `Pi 5`, `Zero 2 W`) have zero analog input pins—all GPIOs are strictly digital (`0 V = LOW`, `3.3 V = HIGH`). To read analog sensors (potentiometers, thermistors, battery voltage dividers), connect an external SPI ADC (`MCP3008`) or I2C ADC (`ADS1115`).
  • Strict `3.3 V` Input Protection:
    • Never connect `5.0 V` UART `TX`, `5.0 V` `HC-SR04` Echo pins, or `5.0 V` I2C devices directly to Raspberry Pi GPIOs.
    • Use a resistor voltage divider (`1.8 kΩ` + `3.3 kΩ`) for unidirectional `5 V → 3.3 V` signals, or a `BSS138` bidirectional MOSFET level shifter for I2C/UART buses.
  • Driving Inductive & High-Current Loads: Always isolate relays, solenoids, DC motors, and high-power LEDs using an optocoupler relay module, N-Channel logic-level MOSFET (`IRLZ44N` / `AO3400`) with a flyback diode (`1N4148` / `1N5819`), or an I2C PWM driver HAT (`PCA9685`).

4. Power Management, Thermal Control & Storage Reliability

  • Preventing Low-Voltage Throttling (`Under-voltage detected!`):
    • If the `5 V` rail dips below `4.63 V` under CPU/USB load, the Raspberry Pi displays a lightning-bolt warning, throttles CPU clock speed, and drops USB/Wi-Fi peripherals.
    • On Raspberry Pi 5, use an official `27 W` (`5.1 V / 5.0 A`) USB-C PD supply so the bootloader unlocks full `1.6 A` USB peripheral current (standard `3 A` supplies restrict Pi 5 USB ports to `600 mA` total).
  • Active Cooling (Pi 4 & Pi 5): Both the `BCM2711` and `BCM2712` processors throttle at `80°C – 85°C`. Install an active heatsink fan (`PWM` fan header on Pi 5) whenever running continuous computer vision, compilation, or enclosed field deployments.
  • SD Card Corruption Prevention:
    • Sudden power loss while Linux is writing to a microSD card corrupts the `ext4` root filesystem.
    • For field-deployed robotics or drone companion computers, enable Read-Only OverlayFS (`raspi-config → Performance Options → Overlay File System`) or boot from an NVMe SSD via PCIe HAT (Pi 5) / industrial high-endurance `pSLC` microSD cards.

5. Raspberry Pi HAT Standard & Companion Computer Integration

  • HAT (Hardware Attached on Top) Specification: Mechanical add-on boards (`65 mm × 56 mm`) featuring four `M2.5` mounting holes, cutouts for camera/display ribbon cables, and an `ID_EEPROM` (`CAT24C32`) on `Pins 27/28` that automatically loads Linux Device Tree overlays at boot.
  • Drone Companion Computer Wiring (MAVLink over UART):
    • Connect Flight Controller `TELEM1` or `TELEM2` `TX` → Raspberry Pi `Pin 10 (RX / GPIO 15)`, Flight Controller `RX` → Raspberry Pi `Pin 8 (TX / GPIO 14)`, and `GND` → `Pin 6 (GND)`.
    • Never connect the Flight Controller's `5 V` telemetry pin to the Raspberry Pi—power the Pi from its own dedicated `5 V / 3 A–5 A` BEC/buck converter so Pi CPU spikes cannot brown out the flight controller's IMU or barometer.

6. Raspberry Pi Hardware Bring-Up & Troubleshooting Checklist

  1. [ ] Verify `3.3 V` Logic on All GPIO Connections: Confirm no `5.0 V` sensor outputs or unshifted serial lines touch the 40-pin header before applying power.
  2. [ ] Check `5.1 V` Power Supply Current Rating: Measure voltage across `Pin 2 (+5V)` and `Pin 6 (GND)` under load; confirm it stays above `4.85 V`.
  3. [ ] Enable Hardware Interfaces in OS: Run `sudo raspi-config` (or edit `/boot/firmware/config.txt`) to enable `I2C`, `SPI`, and `Serial Port` (with Serial Console disabled when using UART for sensors/MAVLink).
  4. [ ] Verify Device Detection via CLI:
    • Run `i2cdetect -y 1` to confirm I2C sensors appear at their expected hex addresses (`0x68`, `0x76`, etc.).
    • Run `vcgencmd get_throttled`—a return value of `0x0` confirms zero under-voltage or thermal throttling events have occurred since boot.
  5. [ ] Inspect Camera / PCIe FFC Ribbon Cables: Ensure fine-pitch flex cables (`CSI` / `DSI` / `PCIe`) are inserted straight with blue/black stiffener tabs facing the locking latch and fully seated before snapping the clip shut.

Electronics Reference: 1. Diodes & Transistors | 2. Integrated Circuits (ICs) | 3. Communication Buses (UART, SPI & I2C) | 4. Voltage Regulators & Power Supply Design | 5. Operational Amplifiers (Op-Amps) | 6. Sensors & Breakout Modules | 7. PCB Design & Soldering Standards | 8. Arduino & Embedded Prototyping | 9. ESP32 & ESP8266 Microcontrollers | 10. STM32 Microcontrollers | 11. Raspberry Pi Hardware & Embedded Electronics

electronics/mcu/raspberry_pi.txt · Last modified: by Jon