Knowing exactly how to power up Raspberry Pi boards is the difference between a stable embedded system and a frustrating loop of random reboots and corrupted SD cards. The direct answer for modern builds: the Raspberry Pi 5 requires a 5V 5A (25W-27W) USB-C Power Delivery (PD) supply, while the Raspberry Pi 4 requires a 5V 3A (15W) USB-C supply. Standard 5V/2A phone chargers will instantly trigger throttling on both boards under any meaningful load.
This guide moves past the basics. We will build a hardware power-monitoring circuit using an I2C sensor, write Python code to catch voltage drops in real-time, and debug the exact kernel errors that occur when your power rail sags.
The Decision Tree: Which Power Method Should You Use?
Before plugging anything in, select your power topology based on your physical deployment. Use this decision matrix to lock in your hardware.
| Deployment Scenario | Power Method | Required Hardware | Verdict |
|---|---|---|---|
| Desktop, Server, or Standard IoT | USB-C PD Wall Adapter | Official 27W USB-C PD Supply (for Pi 5) or 15W (for Pi 4) | DEFAULT PICK. Use this for 95% of builds. |
| Rackmount or Networking Appliance | Power over Ethernet (PoE+) | Pi PoE+ HAT and an 802.3at (PoE+) compliant switch/injector | Choose when running CAT6 is easier than running mains AC to a wall wart. |
| Mobile Robotics or Off-Grid | Battery to GPIO 5V Pins | 2S LiFePO4 pack + 5V 5A step-down buck converter | Choose only when mobility is mandatory. Bypasses USB-C protection circuitry. |
Parts List & Pin Mapping for GPIO Power Monitoring
To prove our power supply is actually delivering clean voltage under load, we will wire an INA219 I2C current/power monitor directly to the Raspberry Pi's 5V GPIO rail. This allows software to read the exact voltage reaching the board, independent of the USB-C PMIC's internal reporting.
Bill of Materials
- Board: Raspberry Pi 5 (8GB variant) or Raspberry Pi 4 Model B
- Power Supply: Official Raspberry Pi 27W USB-C Power Supply (Part: ADA-4045 equivalent)
- Sensor: INA219 I2C Current/Power Monitor Breakout (Adafruit or generic)
- Wiring: 22 AWG silicone jumper wires (female-to-female)
- Software: Raspberry Pi OS (Bookworm or newer, 64-bit)
Pin Mapping Table
The INA219 measures the voltage present on the 5V rail. Wire the sensor to the Pi's 40-pin header as follows:
| INA219 Breakout Pin | Raspberry Pi GPIO Pin | Physical Pin Number | Function |
|---|---|---|---|
| VIN | 5V | Pin 2 or Pin 4 | Power input to sensor & voltage measurement target |
| GND | GND | Pin 6 | Common ground reference |
| SDA | GPIO 2 (SDA1) | Pin 3 | I2C Data line |
| SCL | GPIO 3 (SCL1) | Pin 5 | I2C Clock line |
Step-by-Step: How to Power Up Raspberry Pi via USB-C PD
- Inspect the Cable: Verify your USB-C cable is rated for 5A / 100W. If the cable feels thin or came bundled with a cheap peripheral, discard it for this application.
- Connect Peripherals First: Plug in your HDMI, Ethernet, and USB devices before applying power. The Pi 5 PMIC negotiates its power contract on boot; having the load present ensures it requests the full 5A profile.
- Apply Power: Plug the USB-C connector into the Pi, then plug the AC brick into the wall. The Pi 5's power button LED will pulse orange, then turn green as the bootloader initializes.
- Verify I2C: Once booted, open a terminal and run
sudo i2cdetect -y 1. You should see40in the grid, confirming the INA219 is active on the bus.
Python Code: Monitoring Voltage & Catching Drops
This script targets the Raspberry Pi 5 (8GB) and Raspberry Pi 4 Model B. It reads the INA219 bus voltage register and triggers a console warning if the 5V rail drops below the 4.75V safety threshold.
Prerequisite: Install the Adafruit library via pip3 install adafruit-circuitpython-ina219.
import time
import board
from adafruit_ina219 import ADCResolution, BusVoltageRange, INA219
# Target Board: Raspberry Pi 5 (8GB) / Raspberry Pi 4 Model B
# Sensor: INA219 I2C on hardware I2C bus 1
MIN_SAFE_VOLTAGE = 4.75 # Absolute minimum before PMIC throttles
try:
i2c_bus = board.I2C()
ina219 = INA219(i2c_bus)
except RuntimeError as e:
print(f'Hardware Error: Could not initialize INA219. Check SDA/SCL wiring.\nDetails: {e}')
exit(1)
except ValueError as e:
print(f'Configuration Error: {e}')
exit(1)
# Configure ADC for high-resolution 16V range (plenty of headroom for 5V)
ina219.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S
ina219.bus_voltage_range = BusVoltageRange.RANGE_16V
print('Monitoring 5V rail... Press Ctrl+C to exit.')
try:
while True:
bus_voltage = ina219.bus_voltage
if bus_voltage < MIN_SAFE_VOLTAGE:
print(f'[WARNING] Under-voltage detected! Rail at {bus_voltage:.3f}V')
elif bus_voltage > 5.25:
print(f'[WARNING] Over-voltage! Rail at {bus_voltage:.3f}V')
else:
print(f'[OK] 5V Rail stable at {bus_voltage:.3f}V')
time.sleep(1.0)
except KeyboardInterrupt:
print('\nMonitoring stopped by user.')
except OSError as e:
print(f'I2C Communication Error: {e}. The sensor may have disconnected.')
Troubleshooting: 'Under-voltage detected!' and Boot Failures
If your Pi randomly drops network connections, freezes, or shows a lightning bolt icon on the display, the kernel is logging a specific power fault. The exact error string you will find in dmesg or via vcgencmd get_throttled is:
Under-voltage detected!
Hex code: 0x50005 (or 0x50000 for active under-voltage, 0x50005 indicates it has occurred since boot).
When this error string appears, do not immediately blame the Pi. Execute these first three checks in order:
- Check the USB-C Cable Gauge and Length: Measure the voltage at the wall wart, then at the Pi's USB-C port under load. If the wall outputs 5.1V but the Pi sees 4.6V, your cable is too thin (24 AWG+) or too long (>1 meter). Swap to a 20 AWG, 1-meter cable.
- Verify Power Delivery (PD) Negotiation: The Pi 5 requests 5V at 5A. If your third-party GaN charger only supports 5V/3A and 9V/3A profiles, it will refuse the 5A request and limit the Pi to 3A (15W). Use a USB-C PD multimeter tester inline to verify the brick is actually negotiating the 5V/5A contract.
- Eliminate USB Peripheral Back-powering: Unplug all USB devices (drives, hubs, SDRs). Some unpowered USB hubs back-feed 5V into the Pi's USB ports, confusing the PMIC and causing boot loops. Boot bare, then add devices one by one.
Extending and Simplifying Your Power Build
Once you have a stable baseline, you can adapt the power architecture for specific environmental constraints.
How to Extend the Build
- Add a UPS HAT: For critical logging, stack a LiFePO4 UPS HAT (like the PiJuice or Waveshare UPS HAT). These communicate via I2C to send an ACPI shutdown signal to the Pi before the battery depletes, preventing SD card corruption.
- Automate Logging: Modify the Python script above to write voltage drops to a CSV file or push an MQTT payload to Home Assistant, giving you a historical graph of your power rail's stability over 24 hours.
How to Simplify the Build
- Drop the I2C Sensor: If you don't need real-time Python telemetry, you can rely entirely on the Pi's built-in PMIC telemetry. Simply run
vcgencmd get_throttledvia a cron job. If it returnsthrottled=0x0, your power supply is adequate. - Use PoE for Zero-Cable-Clutter: If your router supports PoE+, buying the official Raspberry Pi PoE+ HAT eliminates the USB-C cable entirely, delivering up to 25W over a single Ethernet cable. This is the cleanest solution for ceiling-mounted cameras or outdoor enclosures.
For 95% of makers and engineers, the decision is simple: buy the Official Raspberry Pi 27W USB-C Power Supply and a high-quality 20 AWG cable. It guarantees the correct PD negotiation, eliminates the variable of third-party charger firmware, and provides the clean 5.1V baseline the Pi 5's power management IC expects. Stop troubleshooting random I2C dropouts and USB disconnects until you have verified your power rail with the exact methods outlined above.






