The Raspberry Pi 40-pin header is a mix of 3.3V power, 5V power, ground, and 3.3V logic GPIOs. Unlike microcontrollers with 5V-tolerant inputs, the Pi’s Broadcom (or RP1 on Pi 5) silicon will permanently fail if subjected to 5V logic. Below is the definitive hardware reference to keep your projects running and your board alive.
The Complete 40-Pin Raspberry Pi GPIO Reference Table
This table maps the physical board pins to the Broadcom (BCM) software channels. Physical pins are numbered 1-40, starting from the top-left (closest to the USB/Ethernet ports on older models, or the power connector on the Pi 4/5) with the odd pins on the left row and even pins on the right.
| Physical Pin | BCM GPIO | Function / Name | Hardware Notes & Warnings |
|---|---|---|---|
| 1 | - | 3.3V Power | Max draw ~50mA. Do not backfeed power here. |
| 2 | - | 5V Power | Direct from USB-C input. Use for high-current sensors. |
| 3 | 2 | SDA1 (I2C) | Has onboard 1.8k pull-up to 3.3V. Do not pull to 5V. |
| 4 | - | 5V Power | Same as Pin 2. |
| 5 | 3 | SCL1 (I2C) | Has onboard 1.8k pull-up to 3.3V. Wake from halt pin. |
| 6 | - | Ground (GND) | Common return path. |
| 7 | 4 | GPIO 4 (GPCLK0) | Standard 3.3V logic. Default 1-Wire bus. |
| 8 | 14 | TXD (UART) | Defaults to serial console. 3.3V logic. |
| 9 | - | Ground (GND) | Common return path. |
| 10 | 15 | RXD (UART) | Defaults to serial console. 3.3V logic. |
| 11 | 17 | GPIO 17 | Standard 3.3V logic. |
| 12 | 18 | GPIO 18 (PWM0) | Hardware PWM capable. Great for motor control. |
| 13 | 27 | GPIO 27 | Standard 3.3V logic. |
| 14 | - | Ground (GND) | Common return path. |
| 15 | 22 | GPIO 22 | Standard 3.3V logic. |
| 16 | 23 | GPIO 23 | Standard 3.3V logic. |
| 17 | - | 3.3V Power | Same as Pin 1. |
| 18 | 24 | GPIO 24 | Standard 3.3V logic. |
| 19 | 10 | MOSI (SPI0) | SPI Master Out Slave In. |
| 20 | - | Ground (GND) | Common return path. |
| 21 | 9 | MISO (SPI0) | SPI Master In Slave Out. |
| 22 | 25 | GPIO 25 | Standard 3.3V logic. |
| 23 | 11 | SCLK (SPI0) | SPI Clock. |
| 24 | 8 | CE0 (SPI0) | SPI Chip Select 0. |
| 25 | - | Ground (GND) | Common return path. |
| 26 | 7 | CE1 (SPI0) | SPI Chip Select 1. |
| 27 | 0 | SDA0 (I2C ID) | Reserved for HAT ID EEPROM. Do not use for general I2C. |
| 28 | 1 | SCL0 (I2C ID) | Reserved for HAT ID EEPROM. Do not use for general I2C. |
| 29 | 5 | GPIO 5 | Standard 3.3V logic. |
| 30 | - | Ground (GND) | Common return path. |
| 31 | 6 | GPIO 6 | Standard 3.3V logic. |
| 32 | 12 | GPIO 12 (PWM0) | Hardware PWM capable. |
| 33 | 13 | GPIO 13 (PWM1) | Hardware PWM capable. |
| 34 | - | Ground (GND) | Common return path. |
| 35 | 19 | GPIO 19 (PWM1) | Hardware PWM capable. |
| 36 | 16 | GPIO 16 | Standard 3.3V logic. |
| 37 | 26 | GPIO 26 | Standard 3.3V logic. |
| 38 | 20 | GPIO 20 | Standard 3.3V logic. |
| 39 | - | Ground (GND) | Common return path. |
| 40 | 21 | GPIO 21 | Standard 3.3V logic. |
Wire Color Conventions: Hobbyist DC vs. Mains Standards (NEC/IEC)
When building embedded systems, you are bridging two entirely different electrical domains: the mains AC power supply and the low-voltage DC logic. The standards governing these two domains do not mix.
Mains Side: NEC, IEC, and Old UK Standards
If you are wiring the AC side of your Pi’s power supply or a relay module switching mains voltage, you must follow regional electrical codes.
- North America (NEC): Black (Line/Hot), White (Neutral), Green or Bare (Earth Ground).
- EU / Modern UK (IEC 60446): Brown (Line), Blue (Neutral), Green/Yellow stripe (Earth Ground).
- Old UK (Pre-2004): Red (Line), Black (Neutral), Green (Earth). Warning: If you are retrofitting a relay into an older UK installation, the black wire is neutral, not line.
Never use mains-colored wires (like green/yellow) for low-voltage DC signals, as it creates a severe shock hazard assumption for anyone troubleshooting the board later.
DC GPIO Side: Hobbyist & Industry Conventions
The 3.3V/5V DC side of the GPIO RPi pinout is not governed by legal code, but violating industry conventions will lead to debugging nightmares. Stick to this palette:
- Red: VCC (3.3V or 5V, depending on the sensor)
- Black: Ground (GND)
- Yellow / Orange / White: Digital Signals / GPIO
- Blue: I2C SDA
- Green: I2C SCL or SPI signals
Rows and Pins People Get Wrong (And How to Avoid Bricking Your Pi)
I’ve replaced enough fried Broadcom chips to know exactly where makers trip up. Here are the most common hardware mistakes when interpreting the pinout.
The Raspberry Pi PCB itself has almost no silkscreen labeling for the 40-pin header. If you are working on a bare board or a custom HAT where markings are worn off, never guess. Locate Pin 1 by finding the square solder pad (all other pads are round). Count from there. Better yet, boot the Pi and run the
pinout command in the terminal (included in the gpiozero library) to pull up an interactive ASCII diagram mapped to your exact board revision.
The 5V vs 3.3V Trap (Pins 1, 2, and 4)
Pin 1 outputs 3.3V. Pins 2 and 4 output 5V. The GPIO data pins (like GPIO 17 on Pin 11) are strictly 3.3V tolerant. If you accidentally wire a 5V sensor's data line to a standard GPIO, or if you plug a 5V power line into a GPIO pin, the internal ESD protection diodes will conduct, overheat, and permanently short the silicon. Always use a multimeter to verify voltage before connecting a new sensor's VCC line.
The I2C Pull-Up Hazard (Pins 3 and 5)
GPIO 2 (SDA) and GPIO 3 (SCL) are fantastic for I2C, but they have 1.8kΩ pull-up resistors physically soldered to the 3.3V rail on the Pi board. If you connect a 5V I2C device that also has pull-ups to 5V, you will backfeed 5V into the Pi's 3.3V rail through those resistors. Use a dedicated I2C level shifter (like the BSS138 MOSFET-based Adafruit 4-channel shifter) when mixing 5V and 3.3V I2C buses.
The UART Console Conflict (Pins 8 and 10)
GPIO 14 (TX) and GPIO 15 (RX) default to the Linux serial console. If you wire a GPS module or microcontroller here and don't disable the serial console in raspi-config, the Pi's boot logs will spam your device, causing erratic behavior or boot loops on the attached peripheral.
Frequently Asked Questions
How do I read the GPIO RPi pinout if the board silkscreen is faded or missing?
Because the Pi lacks extensive silkscreen, rely on physical and software indicators. Physically, Pin 1 is always the square pad on the bottom-left (when the USB ports face you). Software-wise, open a terminal and type pinout. This native command outputs a color-coded ASCII map of your specific board's header, including I2C, SPI, and UART assignments. For official documentation, always cross-reference the Raspberry Pi Official Documentation.
What is the difference between BCM and BOARD numbering in the GPIO RPi pinout?
BOARD numbering refers to the physical pin numbers (1 through 40) printed on the header. BCM numbering refers to the Broadcom SoC channel numbers (e.g., GPIO 17, GPIO 22) used by the silicon internally. When writing Python scripts using RPi.GPIO or gpiozero, you must explicitly declare your mode. I strongly recommend using BCM numbering in your code, as it translates directly to the datasheet and makes troubleshooting with an oscilloscope much easier.
Can I connect 5V Arduino sensors directly to the Raspberry Pi GPIO pins?
No. The Pi's GPIO pins are not 5V tolerant. Connecting a 5V digital output from an Arduino Uno or a 5V ultrasonic sensor directly to a Pi GPIO pin will likely destroy the pin's input buffer. You must use a logic level converter. For simple unidirectional signals, a voltage divider (e.g., 2kΩ and 3.3kΩ resistors) works. For bidirectional protocols like I2C or high-speed SPI, use an active level shifter IC like the TXS0108E or a BSS138 MOSFET breakout board.
Does the Raspberry Pi 5 use the same GPIO RPi pinout as the Pi 4?
Physically, yes. The Pi 5 retains the exact same 40-pin header layout, and the 3.3V/5V/GND pins are identical. However, the Pi 5 uses the custom RP1 southbridge chip instead of the Broadcom SoC for GPIO routing. While the software APIs (like gpiozero) maintain backward compatibility using the same BCM numbers, the underlying hardware registers and some timing characteristics (like bit-banging WS2812B LEDs) have changed. Always ensure your libraries are updated to support the RP1 architecture.






