The standard Raspberry Pi GPIO pinout consists of 40 pins: 26 general-purpose I/O (GPIO) pins, 8 ground pins, 4 power pins (two 5V, two 3.3V), and 2 dedicated ID EEPROM pins. All standard GPIO pins operate at 3.3V logic, meaning any signal exceeding 3.3V will permanently damage the silicon. Below is the definitive physical and functional mapping for the 40-pin header used on the Pi 3, Pi 4, Pi 5, and Zero 2 W.

The Standard 40-Pin Raspberry Pi GPIO Pinout Table

The table below maps the physical pin numbers (1-40) to the Broadcom (BCM) GPIO numbers used in Python/C code, alongside their primary and alternate hardware functions. Physical pins are numbered sequentially down the left side (odd numbers) and down the right side (even numbers), starting from the corner closest to the USB-C power connector.

Pin BCM Function / Notes Pin BCM Function / Notes
1-3.3V Power (Max 50mA draw)2-5V Power (Fused to input)
32GPIO 2 (I2C1 SDA, 1.8k pull-up)4-5V Power
53GPIO 3 (I2C1 SCL, 1.8k pull-up)6-Ground
74GPIO 4 (GPCLK0)814GPIO 14 (UART0 TX)
9-Ground1015GPIO 15 (UART0 RX)
1117GPIO 171218GPIO 18 (PWM0)
1327GPIO 2714-Ground
1522GPIO 221623GPIO 23
17-3.3V Power1824GPIO 24
1910GPIO 10 (SPI0 MOSI)20-Ground
219GPIO 9 (SPI0 MISO)2225GPIO 25
2311GPIO 11 (SPI0 SCLK)248GPIO 8 (SPI0 CE0)
25-Ground267GPIO 7 (SPI0 CE1)
270GPIO 0 (I2C0 SDA / ID_SD)281GPIO 1 (I2C0 SCL / ID_SC)
295GPIO 530-Ground
316GPIO 63212GPIO 12 (PWM0)
3313GPIO 13 (PWM1)34-Ground
3519GPIO 19 (SPI1 MISO / PCM FS)3616GPIO 16 (SPI1 CE2)
3726GPIO 263820GPIO 20 (SPI1 MOSI / PCM DIN)
39-Ground4021GPIO 21 (SPI1 SCLK / PCM DOUT)

For interactive visual mapping and library-specific overlays, the community-maintained Pinout.xyz remains the definitive visual companion to this raw data table.

Rows People Get Wrong (And How to Avoid Bricking Your Pi)

When wiring sensors or relays, misinterpreting the silkscreen or BCM numbering leads to immediate hardware failure. Here are the most common pinout traps encountered on the workbench:

  • The 5V vs 3.3V Trap (Pins 1, 2, and 4): Pin 1 outputs 3.3V, while Pins 2 and 4 output 5V. If you accidentally wire a 5V sensor's logic output directly into a 3.3V GPIO pin (or worse, backfeed 5V into the 3.3V rail on Pin 1), you will instantly destroy the Power Management IC (PMIC) or the SoC itself. Always use a logic level shifter (like the TXS0108E) when interfacing 5V Arduino-style components.
  • The ID EEPROM Pins (Pins 27 and 28): BCM GPIO 0 and 1 are reserved for the HAT (Hardware Attached on Top) identification EEPROM. While they can technically be toggled as GPIOs in software, doing so will break HAT auto-configuration. Furthermore, these pins lack the standard 1.8k pull-up resistors found on the primary I2C bus (Pins 3 and 5).
  • Missing Common Ground: When powering a Pi and an external peripheral (like a 12V LED strip via a MOSFET) from separate power supplies, you must connect the Pi's ground (e.g., Pin 6) to the external supply's ground. Without a shared ground reference, the GPIO logic signals will float, causing erratic behavior or phantom triggering.
  • UART Confusion (Pins 8 and 10): GPIO 14 (TX) and GPIO 15 (RX) are often mistakenly used for standard digital I/O. On the Pi 4 and older, these are tied to the primary UART console. If you need to use them for serial communication with a microcontroller, you must disable the serial console in raspi-config first, or the kernel will spam boot logs onto your device's RX line.
Safety Warning: Never hot-swap jumper wires on the power rails (Pins 1, 2, 4) while the Pi is under load. A slipped 5V wire brushing against the metal USB shield or a 3.3V GPIO will cause an immediate short circuit, bypassing the polyfuse and permanently killing the board.

Board Variants: Pi 5, Pico, and Legacy 26-Pin Headers

While the 40-pin layout has been standard since the Raspberry Pi 1 Model B+ (2014), assuming universal compatibility across the entire Pi ecosystem will cause debugging nightmares. Regional and generational standards differ significantly.

Raspberry Pi 5 and the RP1 Southbridge

The Pi 5 retains the physical 40-pin header, but the GPIOs are no longer driven directly by the Broadcom SoC. Instead, they are routed through the custom RP1 southbridge chip. While standard I2C, SPI, and GPIO toggling work identically via the standard Raspberry Pi OS GPIO libraries, low-level timing operations (like bit-banging WS2812B NeoPixels via DMA) behave differently. Additionally, the Pi 5 moves the dedicated debug UART off the main 40-pin header and onto a separate 3-pin J2 connector, freeing up Pins 8 and 10 for general use without kernel conflicts.

Legacy 26-Pin Headers (Pi 1 Rev 1 and Rev 2)

If you are maintaining older industrial equipment or retro-fitting a Pi 1 Model B, be aware of the Rev 1 to Rev 2 silicon swap. On the original 26-pin Rev 1 board, Physical Pin 13 was mapped to BCM GPIO 21. On the Rev 2 board, Physical Pin 13 was remapped to BCM GPIO 27. Similarly, Pins 3 and 5 swapped from BCM 0/1 to BCM 2/3. If your Python script uses BCM numbering rather than physical board numbering, a Rev 1 script will fail silently on a Rev 2 board.

Raspberry Pi Pico

The Pico is a microcontroller, not a single-board computer, and uses a completely different dual 20-pin DIP layout. It operates at 3.3V logic but features 26 multi-function GPIOs with no dedicated 40-pin HAT compatibility. Do not attempt to plug Pi HATs into a Pico breakout board without verifying every single pin mapping.

Safe Interpretation When Pin Markings Are Faded or Missing

On older boards, or boards deployed in harsh industrial environments, the silkscreen pin numbers often wear off or become obscured by flux residue. Here is how to safely identify your pins without guessing.

  1. Locate the Square Pad: Flip the board over or look closely at the copper pads on the top layer. Pin 1 is always the square copper pad. All other pads are circular. Pin 1 is located at the top-left of the header when the board is oriented with the USB/Ethernet ports facing you.
  2. The Multimeter Verification Test: If you cannot see the square pad, use a digital multimeter set to DC Voltage. Power the Pi via its official USB-C supply. Place your black probe on a known ground (the metal shield of the USB port or the HDMI port shell is reliably grounded). Carefully touch the red probe to the two top-most pins of the header. One will read ~3.3V (Pin 1) and the other will read ~5.0V (Pin 2). This definitively establishes your orientation.
  3. Verify Continuity for Grounds: Once Pin 1 is established, set your meter to continuity mode (power off the Pi first). Probe the remaining pins against the USB shield. Pins 6, 9, 14, 20, 25, 30, 34, and 39 should beep, confirming the ground plane layout matches the standard 40-pin specification.

By relying on physical copper geometry and electrical verification rather than faded ink, you eliminate the risk of reverse-polarity wiring and ensure your embedded project survives its first power-on cycle.