The Raspberry Pi 4 Model B features a 40-pin GPIO header containing 26 usable general-purpose I/O pins, 4 power pins, and 8 ground pins. The most critical specification for any bench setup: the BCM2711 SoC operates on a strict 3.3V logic level. Feeding 5V into any GPIO pin will permanently destroy the processor. Below is the complete physical and BCM mapping, followed by the exact decision paths you need to wire peripherals safely.

The Complete Raspberry Pi 4 B 40-Pin Header Table

This table maps the physical pin number (counting from the corner nearest the SD card) to the Broadcom (BCM) GPIO number used in Python/C code. Read it left-to-right, matching the physical layout of the board.

PinBCMName / FunctionPinBCMName / Function
1-3.3V Power2-5V Power
32GPIO2 (I2C1 SDA)4-5V Power
53GPIO3 (I2C1 SCL)6-Ground
74GPIO4 (GPCLK0)814GPIO14 (UART0 TX)
9-Ground1015GPIO15 (UART0 RX)
1117GPIO171218GPIO18 (PWM0)
1327GPIO2714-Ground
1522GPIO221623GPIO23
17-3.3V Power1824GPIO24
1910GPIO10 (SPI0 MOSI)20-Ground
219GPIO9 (SPI0 MISO)2225GPIO25
2311GPIO11 (SPI0 SCLK)248GPIO8 (SPI0 CE0)
25-Ground267GPIO7 (SPI0 CE1)
270ID_SD (I2C ID)281ID_SC (I2C ID)
295GPIO530-Ground
316GPIO63212GPIO12 (PWM0)
3313GPIO13 (PWM1)34-Ground
3519GPIO19 (SPI1 MISO)3616GPIO16
3726GPIO263820GPIO20 (SPI1 MOSI)
39-Ground4021GPIO21 (SPI1 SCLK)

Source: Pinout.xyz and Raspberry Pi Official Hardware Docs.

Rows People Get Wrong (And How They Fry Their Pi)

When troubleshooting a dead Pi 4 B, the failure almost always traces back to one of these specific pin misinterpretations:

Warning: The 3.3V vs 5V Trap (Pins 1 & 2)
Pin 1 outputs 3.3V (max draw ~50mA total across the rail). Pin 2 outputs 5V (limited only by your USB-C power supply). If you accidentally backfeed 5V into Pin 1, or wire a 5V sensor output directly to a 3.3V GPIO, the BCM2711 silicon will instantly latch up and die. Always use a logic level shifter (like the BSS138 MOSFET bi-directional shifter) when interfacing with 5V Arduino-style sensors.
  • Pins 3 & 5 (I2C1 SDA/SCL): These pins have 1.8kΩ pull-up resistors hardwired to the 3.3V rail on the Pi board itself. If your sensor breakout board also has pull-ups, you will create a parallel resistance that pulls the line too low, causing I2C bus lockups. Furthermore, never connect a 5V I2C device here; the 1.8kΩ pull-ups will feed 5V back into the Pi's 3.3V rail.
  • Pins 27 & 28 (ID_SD / ID_SC): These are reserved exclusively for reading the EEPROM on official Raspberry Pi HATs. They are connected to a separate I2C bus used only during boot. Do not use them for general-purpose I2C sensors.
  • Pins 8 & 10 (UART0 TX/RX): By default, the Pi routes the Linux serial console to these pins. If you connect a GPS module or microcontroller here without disabling the serial console in raspi-config, your device will be flooded with boot logs and kernel panics.

Wiring Color Codes & Logic Standards

While the Raspberry Pi is a global platform, the wiring color codes you use to connect it to the outside world depend on your region's electrical standards and the specific DC conventions of the maker community. Mixing these up on a crowded workbench leads to catastrophic shorts.

Standard / RegionLine / VCCNeutral / GNDEarth / SignalApplication
Maker DC Convention (Global)Red (5V) / Orange (3.3V)Black (GND)Yellow / Blue (Signal)Breadboards, Dupont wires, JST connectors
IEC 60446 (EU/UK Mains)Brown (Line)Blue (Neutral)Green/Yellow (Earth)AC Mains wiring, relay terminal blocks
NEC / US (AC Mains)Black (Hot)White (Neutral)Green/Bare (Ground)AC Mains wiring, relay terminal blocks
Old UK (Pre-2004)Red (Line)Black (Neutral)Green/Yellow (Earth)Legacy AC panels (High confusion risk!)
Bench Tip: Never use IEC Brown/Blue or NEC Black/White wires for low-voltage DC GPIO signals. If a maker uses a black wire for a 5V signal (instead of GND), and you assume it's ground based on maker conventions, you will short the 5V rail. Stick strictly to Red/Orange for VCC, Black for GND, and Yellow/Blue/Green for signals on the DC side of your bench.

Peripheral Decision Tree: Which Pin Do I Actually Use?

Stop guessing which GPIO to assign in your Python script. Use this decision path to select the correct hardware-backed pins for your specific peripheral. This terminates the 'it depends' loop and gives you a concrete wiring target.

Peripheral NeedDecision ConditionConcrete Pick (Physical Pins)BCM GPIOs
I2C Sensor (e.g., BME280)Standard 3.3V logic, addressablePins 3 (SDA) & 5 (SCL)GPIO 2, 3
SPI Display (e.g., ILI9341)High-speed data, requires chip enablePins 19, 21, 23, 24GPIO 10, 9, 11, 8
Hardware PWM (e.g., LED dimming)Needs jitter-free analog simulationPins 12 or 32 (PWM0), Pin 33 (PWM1)GPIO 18, 12, 13
5V Analog Servo MotorPi cannot output 5V analog PWM safelyUse PCA9685 Driver via I2C (Pins 3 & 5)N/A (I2C controlled)
UART GPS Module3.3V logic serial, console disabledPins 8 (TX) & 10 (RX)GPIO 14, 15

Safe Interpretation When Markings Are Faded or Missing

If you are working with a heavily used Pi 4 B where the white silkscreen pin labels have worn off, or you are using a third-party carrier board that obscures the header, do not guess. Follow this physical and software verification sequence:

  1. The Square Pad Rule: Look closely at the solder pads on the underside (or top, if unboxed) of the GPIO header. Physical Pin 1 is the only square solder pad. All other 39 pins are perfectly round. Pin 1 is located at the corner closest to the microSD card slot and furthest from the USB-C power port.
  2. The Silkscreen Triangle: On the top side of the PCB, near the base of the header, there is a small white triangle printed on the silkscreen. The point of this triangle always indicates Pin 1.
  3. Software Verification: If the board is powered and booted into Raspberry Pi OS, open the terminal and type pinout. This built-in command (part of the gpiozero library) will render an ASCII-art diagram of your exact board revision, confirming the BCM-to-Physical mapping without needing to read the board.
  4. Multimeter Continuity Test: With the Pi completely powered off and unplugged, set your multimeter to continuity mode. Probe the metal shielding of the USB ports (which is tied to ground) and test the header pins. The pins that beep are your Ground pins (6, 9, 14, 20, 25, 30, 34, 39). This immediately eliminates 20% of the header from your guessing game.

By strictly adhering to the 3.3V logic limit, respecting the onboard I2C pull-ups, and using standardized DC color codes, you will eliminate the most common hardware failure modes associated with the Raspberry Pi 4 B GPIO header.