The Raspberry Pi 4 Model B features a 40-pin GPIO header that serves as the physical bridge between your Python or C++ code and the real world. The most critical standard for modern coding is BCM (Broadcom SOC channel) numbering, while Physical (Board) numbering (1-40) is used for hardware wiring. Feeding 5V into a 3.3V logic pin will instantly destroy the SoC. Use this reference to map your hardware safely.

WARNING: Never hot-swap GPIO connections while the Pi is powered. A slipped Dupont wire bridging Pin 2 (5V) and Pin 3 (GPIO 2) will bypass the polyfuse and fry the 3.3V regulator, permanently bricking the board. Always de-energize the Pi via the USB-C power supply before altering jumper wires.

The Complete Raspberry Pi 4 Pinout Reference Table

Below is the definitive 40-pin mapping for the Raspberry Pi 4. This table aligns the physical header layout with the BCM GPIO numbers your code will actually use. Read the 'Notes' column carefully—several pins have hidden hardware behaviors that will cause logic errors if ignored.

PhysBCMName / FunctionNotes & Hardware Hazards
1-3.3V PowerMax draw ~50mA. Do not use for motors.
2-5V PowerDirect from USB-C input. Unregulated.
32GPIO 2 (SDA1 / I2C)Has 1.8k physical pull-up to 3.3V on board.
4-5V PowerDirect from USB-C input.
53GPIO 3 (SCL1 / I2C)Has 1.8k physical pull-up to 3.3V on board.
6-Ground (GND)Common ground for all circuits.
74GPIO 4 (GPCLK0)Standard digital I/O.
814GPIO 14 (TXD / UART)Shared with Bluetooth if not disabled in config.
9-Ground (GND)Common ground.
1015GPIO 15 (RXD / UART)Shared with Bluetooth if not disabled.
1117GPIO 17Standard digital I/O.
1218GPIO 18 (PWM0)Hardware PWM capable. Great for servos/LEDs.
1327GPIO 27Standard digital I/O.
14-Ground (GND)Common ground.
1522GPIO 22Standard digital I/O.
1623GPIO 23Standard digital I/O.
17-3.3V PowerMax draw ~50mA.
1824GPIO 24Standard digital I/O.
1910GPIO 10 (MOSI / SPI)SPI0 Master Out Slave In.
20-Ground (GND)Common ground.
219GPIO 9 (MISO / SPI)SPI0 Master In Slave Out.
2225GPIO 25Standard digital I/O.
2311GPIO 11 (SCLK / SPI)SPI0 Clock.
248GPIO 8 (CE0 / SPI)SPI0 Chip Select 0.
25-Ground (GND)Common ground.
267GPIO 7 (CE1 / SPI)SPI0 Chip Select 1.
270GPIO 0 (ID_SD)Reserved for HAT EEPROM. Do not use.
281GPIO 1 (ID_SC)Reserved for HAT EEPROM. Do not use.
295GPIO 5Standard digital I/O.
30-Ground (GND)Common ground.
316GPIO 6Standard digital I/O.
3212GPIO 12 (PWM0)Hardware PWM capable.
3313GPIO 13 (PWM1)Hardware PWM capable.
34-Ground (GND)Common ground.
3519GPIO 19 (MISO / SPI1)SPI1 MISO (Auxiliary SPI).
3616GPIO 16 (CE2 / SPI1)SPI1 Chip Select 2.
3726GPIO 26Standard digital I/O.
3820GPIO 20 (MOSI / SPI1)SPI1 MOSI.
39-Ground (GND)Common ground.
4021GPIO 21 (SCLK / SPI1)SPI1 Clock.

For interactive visual mapping and HAT (Hardware Attached on Top) compatibility checks, the community-maintained pinout.xyz remains the gold standard reference for Pi hardware.

Navigating GPIO Numbering Standards: BCM vs. Physical vs. WiringPi

Just as mains wiring relies on regional standards (NEC in the US, IEC in Europe), Raspberry Pi GPIO programming relies on software numbering standards. Using the wrong standard in your code is the #1 cause of 'my LED won't blink' support tickets. Here is which standard applies to your environment:

StandardWhere it AppliesExample: Physical Pin 3Verdict
BCM (Broadcom)Python (RPi.GPIO, gpiozero), modern C/C++ libraries, Raspberry Pi OS.BCM 2Use this. The official, future-proof standard.
Physical (BOARD)Hardware wiring diagrams, breadboarding, RPi.GPIO (when explicitly set).Pin 3Use for wiring. Count from the SD card edge.
WiringPiLegacy C/C++ tutorials, old Arduino-ported code.WiringPi 8Avoid. Deprecated as of 2019; fails on Pi 4/5.

How to set the standard in Python:
If you are using the classic RPi.GPIO library, you must declare your numbering scheme in the first few lines of your script, or the library will throw a runtime warning and default to an unpredictable state.

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) # Use Broadcom SOC channel numbers
# GPIO.setup(2, GPIO.OUT) # This targets Physical Pin 3

Modern Python development heavily favors the gpiozero library, which defaults to BCM numbering automatically and handles cleanup gracefully, eliminating the need for manual GPIO.cleanup() calls.

Rows People Get Wrong: Bricked Boards and Fried Pins

When mapping the Raspberry Pi 4 pinout, certain rows in the table above carry hidden hardware traps. I have replaced multiple Pi 4 SoCs because builders assumed all GPIO pins behave identically. Here are the specific rows you must treat with caution:

The Power Trap: Pin 1 vs. Pin 2

Physical Pin 1 outputs 3.3V, while Physical Pin 2 outputs 5V. The Raspberry Pi 4's SoC operates strictly at 3.3V logic. If you are reading a 5V sensor (like an HC-SR04 ultrasonic module), you must use a voltage divider or a logic level shifter. Feeding 5V directly into any BCM GPIO pin will destroy the silicon instantly. The board's polyfuse protects against overcurrent on the 5V rail, but it offers zero protection against overvoltage on the GPIO data lines.

The I2C Pull-Up Reality: Pins 3 and 5

BCM GPIO 2 (SDA) and GPIO 3 (SCL) are the default I2C bus pins. On the Pi 4 PCB, these lines have physical 1.8kΩ pull-up resistors tied to the 3.3V rail. If you attempt to use these pins as standard digital inputs with external buttons, the internal pull-ups will fight your external circuitry, causing ghost readings. Reserve Pins 3 and 5 exclusively for I2C devices (like BME280 sensors or OLED displays).

The UART Bluetooth Conflict: Pins 8 and 10

BCM 14 (TXD) and BCM 15 (RXD) are the primary UART serial pins. However, on the Pi 4, the primary UART is routed to the onboard Bluetooth module by default. If you plug a GPS module or serial console into Pins 8 and 10 and get no data, you must disable the Bluetooth UART mapping in your /boot/config.txt (or /boot/firmware/config.txt in modern Bookworm releases) by adding dtoverlay=disable-bt.

The HAT EEPROM Reserved Pins: 27 and 28

Physical Pins 27 and 28 (BCM 0 and 1) are reserved for the HAT identification EEPROM. The Pi queries these pins on boot to automatically configure GPIO states for official add-on boards. Do not wire external components to these pins, or you risk corrupting the boot sequence or causing I2C address collisions.

Safe Interpretation: Faded Markings and Enclosed Boards

On a bare Pi 4, Pin 1 is usually marked with a silkscreen triangle or a 'P1' label. But what happens when the silkscreen is faded, or the board is mounted inside an aluminum passive-cooling case where only the pin tips are visible?

The Square Pad Rule:
Flip the board over (or look closely at the base of the header pins). Pin 1 is the only pin on the entire 40-pin header that has a square copper solder pad on the PCB. Every other pin (2 through 40) has a perfectly round solder pad. If you are working blind on an enclosed board, use a multimeter in continuity mode: probe the metal shielding of the USB ports (which is grounded) and tap the top row pins until you find a Ground pin (like Pin 6 or 9). From there, you can count backward to Pin 1 based on the standard layout.

Verifying Dead Circuits:
Before writing code to debug a 'dead' GPIO, verify the physical connection. Set your multimeter to DC Voltage. Place the black probe on Pin 6 (GND) and the red probe on Pin 1 or 17. You should read between 3.25V and 3.35V. If you read 0V, your Pi's 3.3V regulator has failed (often due to a previous 5V short), and the board must be replaced. For official hardware specifications and tolerance thresholds, always defer to the Raspberry Pi Foundation's official documentation.