The Raspberry Pi 40-pin GPIO header operates strictly at 3.3V logic. Pin 1 provides 3.3V power, while Pin 2 provides 5V power. When writing Python code, always use the BCM (Broadcom) numbering scheme; when physically wiring a button or LED without a schematic, use the Physical (Board) pin numbers. Feeding 5V into any BCM-labeled GPIO pin will instantly destroy the SoC (on Pi 4) or the RP1 southbridge chip (on Pi 5).

The 40-Pin Raspi GPIO Pinout Master Table

This table maps the physical header layout (viewed with the USB ports facing you and the header on the top-left). The left column represents the odd pins (closest to the board edge), and the right column represents the even pins.

Phys BCM Function / Name Function / Name BCM Phys
1-3.3V Power5V Power-2
32SDA1 (I2C)5V Power-4
53SCL1 (I2C)Ground-6
74GPCLK0TXD (UART)148
9-GroundRXD (UART)1510
1117GPIO 17Ground-12
1327GPIO 27GPIO 18 (PWM0)1814
1522GPIO 22Ground-16
17-3.3V PowerGPIO 232318
1910MOSI (SPI)Ground-20
219MISO (SPI)GPIO 252522
2311SCLK (SPI)CE0 (SPI)824
25-GroundCE1 (SPI)726
270ID_SD (I2C ID)ID_SC (I2C ID)128
295GPIO 5Ground-30
316GPIO 6GPIO 12 (PWM0)1232
3313GPIO 13 (PWM1)Ground-34
3519MISO (PCM)GPIO 16 (CE2)1636
3726GPIO 26MOSI (PCM)2038
39-GroundGPIO 212140

Numbering Standards and Wire Color Codes

Confusion between numbering schemes and wiring color standards is the leading cause of dead Raspberry Pis on the workbench. Here is how the standards break down.

Software Numbering: BCM vs. Physical vs. Legacy

  • BCM (Broadcom SOC Channel): Maps directly to the internal silicon registers. This is the default and required scheme for modern Python libraries like gpiozero and RPi.GPIO. When a datasheet says "Connect to GPIO 17", it means BCM 17 (Physical Pin 11).
  • Physical (Board): Simply counts the pins 1 through 40. Use this only when physically probing with a multimeter or wiring a blind terminal block.
  • WiringPi: A legacy C-library numbering scheme. It was officially deprecated and archived in 2019. Do not use WiringPi numbering in 2026. If you are porting old C code, rewrite the pin mappings to BCM.

Hardware Wire Color Standards (Custom Harnesses)

When building custom terminal adapters or extending the Pi header to a breadboard, you must follow regional wire color codes for the power rails to prevent catastrophic miswiring. The 3.3V logic lines have no strict legal code, but industry convention dictates Orange.

Rail US (NEC / UL) EU / UK (IEC 60446) Industry Standard (Logic)
5V PowerRed or BlackBrownRed
Ground (GND)White, Green, or BareBlue or Green/YellowBlack
3.3V LogicN/A (Use Orange)N/A (Use Orange)Orange
Signal / DataYellow, Blue, or VioletBlack or GreyYellow / Blue

Rows People Get Wrong (And How to Avoid Fried Boards)

WARNING: The PC Ribbon Cable Trap
Standard 40-pin IDE ribbon cables have a red stripe indicating Pin 1. On legacy PC motherboards, Pin 1 is often Ground. On the Raspberry Pi, Pin 1 is 3.3V. If you accidentally plug a Pi ribbon cable in backwards, you will feed 5V directly into the 3.3V rail and Ground into the 5V rail. This will instantly vaporize the 3.3V voltage regulator and likely kill the SoC. Always verify the red stripe aligns with the square Pin 1 pad on the Pi PCB.

The 5V vs 3.3V Power Trap

Physical Pins 2 and 4 are 5V (fed directly from the USB-C power input). Physical Pins 1 and 17 are 3.3V (fed from the onboard regulator). If you are powering a 5V relay module or a strip of WS2812B LEDs, you must draw power from Pins 2/4 and Pin 6 (GND). However, the data signal to those devices must be level-shifted to 5V, or you must use a 5V-tolerant buffer. The Pi's GPIO pins are strictly 3.3V and are not 5V tolerant (even on the Pi 5's RP1 chip).

Safe Interpretation When Markings are Faded or Missing

If you are working on a heavily used Pi or a clone board where the silkscreen pin numbers have rubbed off, use these physical markers to orient yourself:

  1. The Square Pad: Flip the board over or look closely at the through-hole pads. Pin 1 is the only pad with a square copper ring. All other 39 pins have round rings.
  2. The Silkscreen Triangle: Most official Pi boards have a tiny white triangle printed on the PCB near the top-left corner of the header, pointing directly at Pin 1.
  3. The Multimeter Continuity Test: Set your multimeter to continuity mode. Probe the metal shield of any USB port (this is tied to Ground). Probe the header pins until you find a beep. Cross-reference the physical location of that Ground pin with the master table above to deduce the rest of the layout.

Decision Tree: Pick the Right Pin and Protocol

Use this decision path to select the correct physical pins and BCM channels for your specific hardware interface. This eliminates guesswork and prevents protocol collisions.

If you are wiring... Then use Physical Pins... Which map to BCM... Required Configuration / Notes
An I2C Sensor (e.g., BME280, OLED) 3, 5, 1, 6 2 (SDA), 3 (SCL), 3.3V, GND Enable I2C in raspi-config. Add 4.7kΩ pull-up resistors to 3.3V if the sensor breakout lacks them.
An SPI Display (e.g., ILI9341, ST7789) 19, 21, 23, 24, 26 10 (MOSI), 9 (MISO), 11 (SCLK), 8 (CE0), 7 (CE1) Enable SPI in raspi-config. Use CE0 (Pin 24) for the primary display. Never connect the display's 5V logic out to the Pi's MISO pin.
A UART GPS or Cellular Module 8, 10, 2, 6 14 (TXD), 15 (RXD), 5V, GND Disable serial console in raspi-config but keep serial hardware enabled. Ensure the module's TX goes to Pi's RX (Pin 10).
A Simple Push Button 11, 9 17, GND Use gpiozero.Button(17, pull_up=True) in Python. No external resistor needed; the Pi's internal pull-up handles it.
A 5V Relay or High-Current Load 12, 2, 6 18 (PWM0), 5V, GND Default Safe Pick: Never drive a relay coil directly from a GPIO pin. Use BCM 18 to drive an NPN transistor (e.g., 2N2222) or an optocoupler that switches the 5V relay coil.

Pi 4 vs Pi 5: What Changed on the Header?

For standard GPIO, I2C, SPI, and UART, the Raspberry Pi 5's 40-pin header is functionally identical to the Pi 4. This ensures backward compatibility with existing HATs (Hardware Attached on Top).

However, the Pi 5 routes its GPIO through the new RP1 southbridge chip rather than the main BCM2712 SoC. While the pinout remains the same, the underlying memory addresses for bare-metal C/C++ GPIO manipulation have changed. If you are writing direct register-access code in C, you must update your memory offsets for the RP1. If you are using Python via gpiozero or the official libgpiod C library, the abstraction layer handles this automatically, and your code will run identically on both boards.

Additionally, the Pi 5 adds a dedicated J2 I2C header specifically for an RTC (Real Time Clock) battery and a PCIe connector, but these are separate from the main 40-pin array. Stick to the master table above for all standard sensor and actuator wiring.