The Raspberry Pi header pinout has remained physically consistent since the Model B+ introduced the 40-pin layout, but mixing up power, ground, and logic pins remains the fastest way to fry a BCM2711 or BCM2712 SoC. This reference gives you the exact pin mapping, physical orientation, and safe wiring practices. Read the table below with Pin 1 (3.3V) at the top-left when the board is oriented with the USB ports facing you and the GPIO header on the top-right.
The Complete 40-Pin Raspberry Pi Header Pinout Table
This table maps the physical pin numbers (1-40) to the Broadcom (BCM) GPIO numbers used in Python/C code. Always use the BCM numbering scheme in your software; physical pin numbers are strictly for hardware wiring.
| Pin | BCM / Function (Left Row) | BCM / Function (Right Row) | Pin |
|---|---|---|---|
| 1 | 3.3V Power | 5V Power | 2 |
| 3 | GPIO 2 (SDA1 / I2C) | 5V Power | 4 |
| 5 | GPIO 3 (SCL1 / I2C) | Ground | 6 |
| 7 | GPIO 4 (GPCLK0) | GPIO 14 (TXD / UART) | 8 |
| 9 | Ground | GPIO 15 (RXD / UART) | 10 |
| 11 | GPIO 17 | GPIO 18 (PWM0 / PCM) | 12 |
| 13 | GPIO 27 | Ground | 14 |
| 15 | GPIO 22 | GPIO 23 | 16 |
| 17 | 3.3V Power | GPIO 24 | 18 |
| 19 | GPIO 10 (MOSI / SPI0) | Ground | 20 |
| 21 | GPIO 9 (MISO / SPI0) | GPIO 25 | 22 |
| 23 | GPIO 11 (SCLK / SPI0) | GPIO 8 (CE0 / SPI0) | 24 |
| 25 | Ground | GPIO 7 (CE1 / SPI0) | 26 |
| 27 | GPIO 0 (ID_SD / I2C ID) | GPIO 1 (ID_SC / I2C ID) | 28 |
| 29 | GPIO 5 | Ground | 30 |
| 31 | GPIO 6 | GPIO 12 (PWM0) | 32 |
| 33 | GPIO 13 (PWM1) | Ground | 34 |
| 35 | GPIO 19 (MISO / SPI1) | GPIO 16 (CE2 / SPI1) | 36 |
| 37 | GPIO 26 | GPIO 20 (MOSI / SPI1) | 38 |
| 39 | Ground | GPIO 21 (SCLK / SPI1) | 40 |
Wire Color Standards & Board Variant Differences
When building custom harnesses or wiring sensors to the Pi, the wire colors you choose matter for troubleshooting. While hobbyist kits use one standard, industrial and international electrical codes dictate different colors. Here is how the standards compare for low-voltage DC GPIO wiring:
| Signal Type | Hobbyist / Adafruit Standard | IEC 60446 (EU/Industrial DC) | Legacy / Old UK Telecom |
|---|---|---|---|
| 3.3V VCC | Red | Brown | Orange |
| 5V VCC | Red (thicker gauge) | Brown (with tracer) | Red |
| Ground (GND) | Black | Blue or Grey | Black |
| I2C SDA | Blue | White/Blue | Green |
| I2C SCL | Yellow | White/Yellow | White |
| UART TX/RX | Green / White | Black / Grey | Yellow / Violet |
For authoritative mapping and software configuration details, always cross-reference the official Raspberry Pi configuration documentation and the community-maintained Pinout.xyz interactive diagram.
The Rows People Get Wrong (and How to Avoid Bricking Your Pi)
Even experienced engineers fry Pi boards by rushing the physical connection. Here are the specific rows and pins that cause the most catastrophic failures on the bench:
1. Pin 1 Orientation (The 'Square Pad' Rule)
When silkscreen fades or you are using a bare compute module breakout, finding Pin 1 is critical. Pin 1 is always the 3.3V rail. Physically, the PCB pad for Pin 1 is square, while all other pads are round. If you plug a 5V line into Pin 1 expecting ground, you will instantly overvoltage the 3.3V LDO regulator and kill the SoC.
2. The 3.3V Current Limit Trap (Pins 1 & 17)
Many makers assume the 3.3V pins can source as much current as the 5V pins. On the Pi 3 and Pi 4, the 3.3V rail is derived from an LDO that maxes out around 50mA to 300mA depending on the board's internal load. If you wire a string of 3.3V LEDs or a high-draw sensor directly to Pin 1, you will cause a brownout. Fix: Use the 5V pins (2 or 4) and a dedicated 3.3V buck converter (like an AMS1117-3.3 module) for loads exceeding 50mA. Note: The Pi 5 upgraded to a dedicated 3.3V SMPS capable of delivering up to 300mA safely, but external high-current loads should still use external regulation.
3. I2C Pull-Up Conflicts (Pins 3 & 5)
Pins 3 (SDA1) and 5 (SCL1) have physical 1.8kΩ pull-up resistors hardwired to the 3.3V rail on the Pi PCB. If you connect a 5V Arduino-style I2C sensor that also has its own pull-ups to 5V, you will back-feed 5V into the Pi's 3.3V GPIO pins through the I2C lines, destroying the BCM chip. Fix: Always use a bidirectional logic level shifter (like a BSS138 or TXS0108E module) when connecting 5V I2C devices.
4. UART Crossing (Pins 8 & 10)
When wiring a serial GPS module or an ESP32 to the Pi's UART, remember that transmit must talk to receive. Pin 8 is TXD (Transmit) and Pin 10 is RXD (Receive). You must wire Pi Pin 8 (TX) to the external device's RX pin, and Pi Pin 10 (RX) to the external device's TX pin.
Frequently Asked Questions About the Raspberry Pi Header Pinout
How do I identify Pin 1 if the silkscreen is missing or faded?
Look at the physical solder pads on the underside of the board or the top-side header plastic. Pin 1 is the only pad that is physically square; pins 2 through 40 are perfectly round. Additionally, if you look closely at the PCB near the header, there is usually a tiny silkscreen arrow or a '1' etched into the copper layer itself, which survives even when the white paint wears off. If using a ribbon cable, the red stripe always denotes Pin 1.
Can I use the 5V pins to power high-current motors directly?
No. While Pins 2 and 4 provide 5V directly from the USB-C power input, the Pi's power path includes a polyfuse (typically rated around 2.5A to 3A total for the whole board). Running motors directly off the GPIO header will cause massive voltage sag, leading to CPU throttling, SD card corruption, and random reboots. For motors, servos, or LED strips drawing more than 500mA, wire the power directly from the power supply's 5V rail to the motor driver, and only use the Pi's GPIO pins for the low-current PWM control signals, ensuring a common ground connection.
Why does my I2C sensor work on an Arduino but fail on the Pi's pins 3 and 5?
This is almost always a voltage or pull-up resistor issue. Arduinos (like the Uno) operate at 5V logic and expect 5V I2C levels. The Raspberry Pi operates strictly at 3.3V logic. If your sensor requires 5V to operate and outputs 5V on the SDA/SCL lines, the Pi's internal protection diodes will clamp the voltage, resulting in corrupted data or a locked bus. You must power the sensor with 3.3V if it supports it, or use a logic level shifter to safely translate the 5V I2C signals down to the Pi's 3.3V threshold.
Are the Raspberry Pi 5 GPIO pins fully compatible with Pi 4 HATs?
Physically and logically, the standard 40-pin header is identical, meaning 99% of Pi 4 HATs will fit and function on a Pi 5. However, the Pi 5 removed the dedicated I2C ID EEPROM bus (Pins 27 and 28) used for automatic HAT configuration. While the HAT will still work, the OS will not auto-load the device tree overlays. You will need to manually add the required dtoverlay lines to your /boot/firmware/config.txt file to enable the HAT's specific hardware features.






