The Raspberry Pi 40-pin header uses three distinct numbering schemes: Physical (1-40), BCM (Broadcom SoC channels), and WiringPi (a deprecated legacy standard). For all modern Python (gpiozero, RPi.GPIO) and C++ projects, BCM numbering is the absolute standard. Below is the complete, data-dense mapping for the 40-pin header found on the Pi 3, Pi 4, Pi 5, and Zero 2 W. Bookmark this table for your bench.

The Complete 40-Pin Raspberry Pi GPIO Pinout Table

Read this table by matching your physical header location to the BCM GPIO number required by your Python scripts. The Pi 5 uses the RP1 I/O controller under the hood, but the software abstraction keeps these BCM numbers identical to the Pi 4.

Physical BCM GPIO WiringPi Function / Power Notes & Hazards
1--3.3V PowerMax 50mA draw. Exceeding this fries the SoC.
2--5V PowerDirect from USB-C input. High current capable.
328SDA1 (I2C)Has 1.8k pull-up to 3.3V. Do not use for 5V inputs.
4--5V Power-
539SCL1 (I2C)Has 1.8k pull-up to 3.3V. Do not use for 5V inputs.
6--Ground-
747GPCLK0General Purpose Clock 0.
81415TXD (UART)Serial console by default. Must disable in raspi-config.
9--Ground-
101516RXD (UART)Serial console by default. Must disable in raspi-config.
11170GPIO 17Standard GPIO.
12181PWM0Hardware PWM capable. Excellent for motor control.
13272GPIO 27Standard GPIO (was GPIO 21 on Rev 1 Pi 1).
14--Ground-
15223GPIO 22Standard GPIO.
16234GPIO 23Standard GPIO.
17--3.3V PowerMax 50mA draw.
18245GPIO 24Standard GPIO.
191012MOSI (SPI0)SPI Master Out Slave In.
20--Ground-
21913MISO (SPI0)SPI Master In Slave Out.
22256GPIO 25Standard GPIO.
231114SCLK (SPI0)SPI Clock.
24810CE0 (SPI0)SPI Chip Select 0.
25--Ground-
26711CE1 (SPI0)SPI Chip Select 1.
270 (ID_SD)-I2C ID EEPROMReserved for HAT identification. Do not use.
281 (ID_SC)-I2C ID EEPROMReserved for HAT identification. Do not use.
29521GPIO 5Standard GPIO.
30--Ground-
31622GPIO 6Standard GPIO.
321226PWM0Hardware PWM capable.
331323PWM1Hardware PWM capable.
34--Ground-
351924PWM1 / SPI1Hardware PWM / SPI1 MISO.
361627GPIO 16Standard GPIO.
372625GPIO 26Standard GPIO.
382028SPI1 MOSISecondary SPI interface.
39--Ground-
402129SPI1 SCLKSecondary SPI interface.

Decoding the Standards: BCM vs. Physical vs. WiringPi

When reading tutorials or datasheets, you will encounter three different naming conventions for the exact same physical pin. Understanding which standard applies to your code is the difference between a working circuit and a silent failure.

  • BCM (Broadcom SOC Channel): This is the modern, universal standard. It maps directly to the Broadcom silicon datasheet (and the RP1 chip on the Pi 5). When you write LED = LED(17) in gpiozero, you are using BCM 17 (Physical Pin 11). Always use BCM for new projects.
  • Physical (Board): This simply counts the pins 1 through 40, starting from the top-left (Pin 1) and zig-zagging down. Use this only when physically wiring a harness or crimping a connector. Never use physical numbering in Python scripts unless you explicitly set GPIO.setmode(GPIO.BOARD) in the legacy RPi.GPIO library.
  • WiringPi: A C-library numbering scheme created by Gordon Henderson. WiringPi was officially deprecated in 2019. You will still see it in older forum posts and legacy C codebases. Ignore it for new designs; the library is no longer maintained and causes conflicts with modern libgpiod implementations.

For comprehensive software-side pin mapping and alternate function multiplexing, refer to the official gpiozero pin factory documentation, which remains the most reliable source for Python-level abstraction.

Rows People Get Wrong: Special Functions and Power Hazards

The 40-pin header is not just a grid of identical I/O lines. Several pins have hardcoded hardware behaviors that will destroy your Pi or cause silent logic errors if misinterpreted.

WARNING: The 3.3V vs 5V Trap (Pins 1 & 2)
Pin 1 outputs 3.3V and is tied directly to the SoC's internal voltage regulator. It can only supply about 50mA. Pin 2 outputs 5V directly from the USB-C power input. If you accidentally wire a 5V sensor's VCC to Pin 1, you will brownout the SoC. Worse, if you wire a 3.3V logic output to Pin 2, you will instantly fry the GPIO pad and potentially kill the board.

The I2C Pull-Up Hazard (Pins 3 and 5)

GPIO 2 (SDA) and GPIO 3 (SCL) are the primary I2C bus pins. On the Pi hardware, these pins have physical 1.8kΩ pull-up resistors hardwired to the 3.3V rail. If you connect a 5V I2C device (like an older Arduino sensor) directly to these pins without a logic level shifter, the 5V device will backfeed current through the Pi's pull-up resistors into the 3.3V rail, pushing the 3.3V line up to ~4V and degrading the SoC over time.

The Hardware PWM Illusion

Many beginners try to run servos or dim LEDs using software PWM on random GPIO pins, resulting in jittery motors and flickering lights. The Pi only has two true hardware PWM channels, which are multiplexed across four physical pins: GPIO 12, 13, 18, and 19. If your project requires precise timing (like driving a PCA9685 alternative or analog audio filtering), you must route your signals to one of these four pins.

UART and the Bluetooth Mux (Pins 8 and 10)

GPIO 14 (TXD) and GPIO 15 (RXD) are the primary UART pins. On the Pi 3, 4, and 5, the hardware UART is routed to the onboard Bluetooth module by default. If you are trying to connect a GPS module or an Arduino via serial, your code will fail silently because the OS is hogging the port. You must disable the serial console in sudo raspi-config and add dtoverlay=disable-bt to your /boot/firmware/config.txt to reclaim these pins for general serial use.

Safe Interpretation When Markings Are Faded or Missing

On older Pi 1 Model B+ boards, early Pi Zeros, or boards that have seen years of flux and heat on a workbench, the white silkscreen numbering next to the header often wears off. Guessing pin locations based on USB port orientation is a reliable way to short 5V to ground.

If your board markings are compromised, use these three verification methods before applying power:

  1. The Pin 1 Physical Indicator: Look closely at the solder pads on the underside of the board, or the metal shroud of the header itself. Pin 1 is always designated by a square solder pad (all other pads are round). Additionally, there is usually a tiny triangle etched into the PCB silkscreen pointing to Pin 1, located near the SD card slot edge.
  2. The Software Verification: If the Pi is already booted and running safely, open the terminal and type pinout. This built-in utility (part of the gpiozero package) prints a color-coded ASCII diagram of your exact board revision's header to the console. Cross-reference this with your physical wire placement.
  3. Use a Breakout Board: For bench prototyping where silkscreen is unreliable, abandon direct header wiring. Use an Adafruit Pi Cobbler or a generic GPIO breakout ribbon. These PCBs feature clearly printed, soldered labels for every BCM and Physical pin, eliminating the need to read faded board markings entirely.

For the definitive hardware-level schematic and official pin multiplexing tables, always cross-reference your specific board revision against the Raspberry Pi Foundation's official GPIO documentation. Never assume a third-party blog's pinout diagram is accurate for the Pi 5, as the underlying RP1 silicon routing has changed, even if the Python abstraction remains identical.