The Raspberry Pi 4B features a 40-pin header mapping to 26 usable Broadcom (BCM) GPIOs, alongside dedicated I2C, SPI, UART, and hardware PWM channels. Physical Pin 1 supplies 3.3V and is located closest to the USB-C power port and SD card slot. When writing Python scripts, always default to BCM numbering unless you are manually wiring a physical harness.

The Complete Raspberry Pi 4B Pinout Table

The table below maps the physical header layout (left and right columns) to the BCM GPIO numbers and primary functions. Use this as your bench reference when wiring sensors or debugging HATs. For a visual overlay, cross-reference with the official Pinout.xyz interactive diagram.

PhysBCMFunctionPhysBCMFunction
1-3.3V Power2-5V Power
32GPIO2 (SDA1)4-5V Power
53GPIO3 (SCL1)6-Ground
74GPIO4 (GPCLK0)814GPIO14 (TXD)
9-Ground1015GPIO15 (RXD)
1117GPIO171218GPIO18 (PWM0)
1327GPIO2714-Ground
1522GPIO221623GPIO23
17-3.3V Power1824GPIO24
1910GPIO10 (MOSI)20-Ground
219GPIO9 (MISO)2225GPIO25
2311GPIO11 (SCLK)248GPIO8 (CE0)
25-Ground267GPIO7 (CE1)
270GPIO0 (ID_SD)281GPIO1 (ID_SC)
295GPIO530-Ground
316GPIO63212GPIO12 (PWM0)
3313GPIO13 (PWM1)34-Ground
3519GPIO19 (MISO1)3616GPIO16 (CE2)
3726GPIO263820GPIO20 (MOSI1)
39-Ground4021GPIO21 (SCLK1)

Rows People Get Wrong (And How They Brick Your Pi)

Misinterpreting the pinout table is the leading cause of dead Raspberry Pi boards on the workbench. Here are the specific rows that cause hardware failures:

The 5V Tolerance Myth: The Pi 4B GPIOs operate strictly at 3.3V logic. Feeding a 5V signal into any BCM GPIO (e.g., from an Arduino Uno or a 5V ultrasonic sensor) will backfeed the SoC and permanently destroy the PMIC or the ARM core. Always use a logic level shifter or a voltage divider for 5V peripherals.
  • Physical Pin 1 vs. BCM 1: Physical Pin 1 outputs 3.3V power. BCM GPIO 1 is actually Physical Pin 28 (ID_SC). If you wire a 5V component to Physical Pin 1 expecting a data line, you will short the 3.3V regulator. Always declare GPIO.setmode(GPIO.BCM) in Python to avoid this confusion.
  • Pins 3 & 5 (I2C SDA/SCL): These pins have hardwired 1.8kΩ pull-up resistors to 3.3V on the Pi PCB. Do not use them for standard digital inputs or open-drain outputs that require 5V pull-ups, as the onboard resistors will fight your external circuit.
  • Pins 27 & 28 (ID_SD / ID_SC): Reserved exclusively for HAT EEPROM identification. Using these for general I/O can cause boot failures if a HAT is attached, as the Pi reads these pins during the early boot sequence to configure the device tree.

Wiring Color Standards: IEC vs. US Conventions

When crimping custom JST-XH harnesses or wiring terminal blocks to the Pi's GPIOs, regional standards dictate your wire colors. Mixing these up leads to reversed polarity and fried sensors.

Wire FunctionIEC 60446 / DIN (EU/Global DC)US Hobbyist / EIA StandardStandard 40-Pin Ribbon
Positive (VCC / 3.3V or 5V)BrownRedRed Stripe (Pin 1)
Negative (Ground)BlueBlackBlack / Dark Grey
Signal / DataBlack or WhiteYellow, White, or OrangeColor-coded per pin

Which standard applies to you? If you are building industrial enclosures or exporting to Europe, strictly adhere to IEC 60446 (Brown/Blue). If you are prototyping with standard Adafruit/SparkFun sensor breakout boards, they almost universally use the US EIA convention (Red/Black/Yellow). Never assume a pre-crimped cable follows IEC; always verify with a multimeter before applying power.

Safe Identification When Markings Are Faded

On older Pi 4B boards, or when the board is mounted in a cramped enclosure, the silkscreen pin numbers wear off or become hidden. Here is how to safely identify your pins without guessing:

The Square Pad Rule: Flip the board over (or look closely at the base of the header). Physical Pin 1 is the only pad that is square. All other 39 pads are perfectly round. Pin 1 is always on the left column when the USB ports are facing toward you.
  1. Find Ground First: Set your multimeter to continuity mode. Probe the metal shield of the USB-C port or any of the four mounting holes (which are tied to ground). Probe the header pins; the ones that beep are your GND pins (Physical 6, 9, 14, 20, 25, 30, 34, 39).
  2. Verify the Rails: Power the Pi via USB-C. Set the meter to DC Voltage. Place the black probe on a confirmed GND pin. Probe Physical Pin 2 (should read 4.9V–5.1V) and Physical Pin 1 (should read 3.28V–3.32V). If Pin 1 reads 0V, your onboard 3.3V polyfuse has tripped or the PMIC is dead.
  3. Identify Pin 1 Orientation: Pin 1 is always the corner pin closest to the SD card slot and the USB-C power jack. Pin 2 is directly across from it on the inner row.

GPIO Selection Decision Tree

Not all GPIOs are created equal. Some have boot-time conflicts, while others are tied to specific hardware controllers. Use this decision matrix to select the exact pin for your next component.

Application NeedRequired FeatureConcrete Pick (BCM)Why This Pin Wins
Servo / Motor ControlHardware PWMBCM 18True hardware PWM0 channel. Zero software jitter compared to software PWM on other pins.
Temperature / OLED SensorI2C BusBCM 2 & 3The primary I2C1 bus with onboard 1.8kΩ pull-ups. No external resistors needed.
RFID / High-Speed DisplaySPI BusBCM 10, 9, 11, 8Primary SPI0 bus. BCM 8 is Chip Enable 0 (CE0), BCM 7 is CE1. Maximum hardware throughput.
GPS Module / ConsoleHardware UARTBCM 14 & 15Primary UART (TX/RX). Note: You must disable the serial console in raspi-config to free these pins.
Limit Switches / ButtonsSafe General I/OBCM 17, 27, 22Completely safe. No boot-strapping conflicts, no default pull-ups/downs that fight external circuits.

Default Recommendation: If you just need a generic digital output to trigger a relay module and have no specific protocol requirements, wire it to BCM 17 (Physical Pin 11). It has no alternate boot functions, no hardware pull-ups, and will not cause the Pi to hang during the boot sequence if held low.