The Direct Answer: Sizing Your Raspberry Pi Power Supply
If you need to know how to power a Raspberry Pi right now, here is the baseline: For a Raspberry Pi 5, use the official 27W USB-C PD power supply (Part # SC111) which delivers 5.1V at 5A. For a Raspberry Pi 4 Model B, use the official 15.3W USB-C supply (5.1V at 3A). If you are building a headless embedded project and need to bypass the USB-C port, inject 5.1V DC directly into the GPIO header at Pin 4 (5V) and Pin 6 (GND), ensuring your wire gauge is 22 AWG or thicker to prevent voltage drop.
Powering these boards seems trivial until you attach peripherals, run heavy compute loads, or route power through long, thin wires. The Pi 5 utilizes a Renesas DA9098 PMIC (Power Management IC) that strictly negotiates USB Power Delivery (PD) profiles. If it doesn't detect a 5A PD-capable brick, it deliberately limits USB peripheral current to 600mA to protect the board. Let's break down exactly how to choose your power route, wire it, and debug it when the inevitable lightning bolt icon appears.
Power Method Decision Tree: Which Route to Take?
Don't just default to a random phone charger. Use this decision matrix to select the exact power architecture for your build. If you are unsure, follow the default recommendation at the bottom.
| Use Case Scenario | Recommended Power Method | Required Hardware / Part Number | Max Peripheral Current |
|---|---|---|---|
| Desktop, Media Center, Standard Server | Official USB-C PD Wall Adapter | Raspberry Pi 27W PSU (SC111) | 1.6A (Pi 5) / 1.2A (Pi 4) |
| Headless Embedded, Custom Enclosure, DIN Rail | GPIO 5V Direct Injection via Buck Converter | Mean Well IRM-10-5 (AC-DC) or DROK 200156 (DC-DC) | Limited by your trace/wire gauge (Typ. 3A-5A) |
| Network Closet, Long Cable Runs (>30ft) | Power over Ethernet (PoE+) | Official PoE+ HAT (802.3at) | ~1.5A (HAT thermal limits apply) |
| Mobile Robot, Field Sensor, Prone to Outages | UPS HAT with LiFePO4 Cells | PiSugar 3 Plus or Waveshare UPS HAT | Varies by HAT (Typ. 2A-3A) |
| Default / Unsure (The Fallback Pick) | Official USB-C PD Wall Adapter | Buy the SC111 (Pi 5) or SC073 (Pi 4) | Guaranteed stable baseline |
Parts List & GPIO Pin Mapping for Embedded Power Injection
When building a permanent embedded node (like an outdoor weather station or a factory-floor MQTT gateway), relying on a USB-C cable and wall wart is a failure point. Cables vibrate loose, and USB connectors suffer from contact resistance. Direct GPIO injection is the industry standard for embedded deployments.
Exact Parts List
- Compute Module: Raspberry Pi 5 (8GB RAM variant) or Pi 4 Model B (4GB).
- Power Source: Mean Well IRM-10-5 (10W, 5V/2A enclosed AC-DC module) or a 12V-to-5V buck converter rated for at least 5A (e.g., DROK 200156).
- Wiring: 22 AWG stranded silicone wire (Red for 5V, Black for GND). Do not use 28 AWG breadboard jumper wires for main power; they will melt or cause severe voltage drop.
- Protection: 5A fast-acting automotive blade fuse (ATO) or a 5x20mm glass fuse holder on the 5V line.
GPIO Power Pin Mapping
The Raspberry Pi GPIO header has multiple 5V and GND pins. They are all tied to the same internal power planes, but using the pins closest to the edge of the board makes physical routing easier in tight enclosures.
| Function | GPIO Pin Name | Physical Pin Number | Notes & Warnings |
|---|---|---|---|
| 5V Power In | 5V | Pin 4 | Directly feeds the 5V rail. Bypasses USB-C PD negotiation. |
| Ground | GND | Pin 6 | Primary ground reference. Tie all peripheral grounds here. |
| 5V Power In (Alt) | 5V | Pin 2 | Electrically identical to Pin 4. Use for redundant feeds. |
| Ground (Alt) | GND | Pin 9 | Electrically identical to Pin 6. |
| 3.3V Output | 3V3 | Pin 1 | NEVER inject power here. Max draw is ~50mA. Feeding 5V here will instantly destroy the SoC. |
According to the Raspberry Pi 5 Datasheet, the board requires an input voltage between 4.75V and 5.25V. If your buck converter outputs exactly 5.0V, but you run 2 feet of 24 AWG wire (which has ~25.67 mΩ/ft), a 3A load will cause a voltage drop of roughly 0.15V. Your Pi will see 4.85V. Always set your bench supply or buck converter to 5.15V at the source to ensure 5.0V arrives at the GPIO header under load.
Clean Shutdown Code: Raspberry Pi 5 GPIO Monitor
When powering a Pi via GPIO or a UPS HAT in a headless setup, you don't have a desktop GUI to click 'Shut Down'. Pulling the power corrupts the SD card. The solution is a physical momentary pushbutton wired to a GPIO pin that triggers a clean OS shutdown.
Target Board: Raspberry Pi 5 (8GB) running Raspberry Pi OS (Bookworm 64-bit).
Hardware Setup: Wire a momentary pushbutton between GPIO 17 (Physical Pin 11) and GND (Physical Pin 9). We will use the internal pull-up resistor, so no external resistors are needed.
#!/usr/bin/env python3
"""
Raspberry Pi Clean Shutdown Monitor
Target: Raspberry Pi 5 (Bookworm OS)
Wiring: Button between GPIO 17 (Pin 11) and GND (Pin 9)
"""
import os
import sys
import time
import logging
# Pin Definitions
SHUTDOWN_PIN = 17 # Physical Pin 11
# Configure Logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('/var/log/pi_shutdown_monitor.log'),
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger('ShutdownMonitor')
def main():
try:
# Import gpiozero locally to catch missing dependencies gracefully
from gpiozero import Button
from signal import pause
except ImportError:
logger.critical('gpiozero not found. Install via: sudo apt install python3-gpiozero')
sys.exit(1)
except Exception as e:
logger.critical(f'Failed to initialize GPIO library: {e}')
sys.exit(1)
try:
# Initialize button with internal pull-up (pull_up=True)
# bounce_time prevents mechanical switch chatter from triggering multiple events
shutdown_btn = Button(SHUTDOWN_PIN, pull_up=True, bounce_time=0.1)
logger.info(f'Shutdown monitor active. Listening on GPIO {SHUTDOWN_PIN}...')
# Wait for button press (pulls pin to GND)
shutdown_btn.wait_for_press()
logger.warning('Button press detected! Initiating clean system shutdown in 3 seconds...')
time.sleep(3) # Brief delay to allow logging to flush and user to release
# Execute shutdown command
os.system('sudo shutdown -h now')
except Exception as e:
logger.error(f'Runtime error in shutdown sequence: {e}')
sys.exit(1)
if __name__ == '__main__':
main()
Deployment: Save this as /opt/shutdown_monitor.py, make it executable (chmod +x), and create a systemd service to run it at boot. This ensures your embedded node can be safely powered down by field technicians without SSH access.
Debugging Power Failures: The 'Under-Voltage' Error
The most common power issue you will face is the dreaded under-voltage warning. On a desktop, this manifests as a lightning bolt icon in the top right corner. On a headless system, you'll find it in the kernel ring buffer.
The Exact Error String:
When you run dmesg | grep -i voltage, you will see this exact string:
[ 14.234567] raspberrypi kernel: Under-voltage detected!
This is not a suggestion; it is a hardware interrupt triggered by the PMIC when the 5V rail drops below ~4.63V. When this happens, the Pi aggressively throttles the CPU clock speed and disables USB current limiting to prevent a total brownout.
The First Three Things to Check (Ranked by Probability)
- Cable Gauge and Length (Voltage Drop): If you are using USB-C, the cable is almost always the culprit. Many cheap USB-C cables are wired for data (28 AWG power lines) and cannot carry 3A+ without dropping half a volt. Fix: Switch to a cable rated for 100W PD (which uses thicker 20 AWG or 22 AWG power conductors) or keep the cable under 3 feet.
- Inadequate PSU Current Limit: Phone chargers often advertise '20W' but achieve it via high voltage (9V or 12V) over USB PD, not 5V. The Pi 5 strictly requires 5V at 5A (27W). If your charger drops to 2A at 5V, the Pi will starve under load. Fix: Check the PSU's output label. It must explicitly state
5V ⎓ 5Aor5V ⎓ 3A(for Pi 4). - Peripheral Backpowering or Inrush: Plugging in a high-inrush device (like an unpowered USB hard drive or a motor controller) can cause a momentary voltage sag that trips the PMIC. Fix: Use a powered USB hub for external drives, or add a 1000µF electrolytic capacitor across the 5V and GND rails near the peripheral to absorb inrush spikes.
Extending and Simplifying Your Power Build
Once your baseline power is stable, you will inevitably need to adapt the build for field conditions or simplify it for mass production.
How to Extend: Adding Telemetry
If you want to monitor the actual voltage reaching the Pi in real-time, you can read the internal PMIC registers via I2C. Install the vcgencmd tool (included in Raspberry Pi OS) and run:
vcgencmd pmic_read_adc EXT5V_V
This returns the exact voltage on the 5V rail (e.g., 5.12V). You can log this value via a cron job to an InfluxDB database to track power degradation over months of field operation.
How to Simplify: The 'No-Code' Hardware Fix
If you are designing a custom PCB or a carrier board for the Compute Module 5 (CM5) and want to eliminate software-based shutdown scripts entirely, use a dedicated hardware supervisor IC like the TI TPS3839 or a physical latching power switch like the Pololu Pushbutton Power Switch (LV). These modules physically cut the ground path when the button is held, but they feature a built-in 5-second delay and an 'OFF' signal pin that you can wire to the Pi's RUN or GPIO pins to trigger a software shutdown before the hardware cuts the power. This reduces your software stack to zero and makes the Pi behave exactly like a consumer appliance.
For 95% of makers and embedded engineers, the decision is simple: buy the official 27W SC111 power supply, use a high-quality USB-C cable, and stop worrying about PMIC throttling. Reserve GPIO injection and UPS HATs for when the enclosure demands it.






