If you haven't seen how the Pi 4 compares to the Pi 5 and Pico first, our Raspberry Pi GPIO Pinout overview covers that ground.
Complete 40-Pin Reference Table
All 40 physical pins, in header order, with their default BCM function:
| Physical pin | Function | Physical pin | Function |
|---|---|---|---|
| 1 | 3.3V power | 2 | 5V power |
| 3 | GPIO2 (SDA, I2C) | 4 | 5V power |
| 5 | GPIO3 (SCL, I2C) | 6 | Ground |
| 7 | GPIO4 | 8 | GPIO14 (TXD, UART) |
| 9 | Ground | 10 | GPIO15 (RXD, UART) |
| 11 | GPIO17 | 12 | GPIO18 (PWM) |
| 13 | GPIO27 | 14 | Ground |
| 15 | GPIO22 | 16 | GPIO23 |
| 17 | 3.3V power | 18 | GPIO24 |
| 19 | GPIO10 (MOSI, SPI) | 20 | Ground |
| 21 | GPIO9 (MISO, SPI) | 22 | GPIO25 |
| 23 | GPIO11 (SCLK, SPI) | 24 | GPIO8 (CE0, SPI) |
| 25 | Ground | 26 | GPIO7 (CE1, SPI) |
| 27 | GPIO0 (ID_SD, reserved) | 28 | GPIO1 (ID_SC, reserved) |
| 29 | GPIO5 | 30 | Ground |
| 31 | GPIO6 | 32 | GPIO12 (PWM) |
| 33 | GPIO13 (PWM) | 34 | Ground |
| 35 | GPIO19 (PWM) | 36 | GPIO16 |
| 37 | GPIO26 | 38 | GPIO20 |
| 39 | Ground | 40 | GPIO21 |
As with every Raspberry Pi board, all GPIO pins run at 3.3V logic and are not 5V tolerant. Use a level shifter for any 5V sensors or devices.
The UART Quirk: Why GPIO14/15 Might Not Do What You Expect
GPIO14 (TXD) and GPIO15 (RXD) are labeled as the UART pins on every pinout diagram, but there's a catch that goes back to the Pi 3B+: the Pi 4 has two UARTs on the BCM2711 — a full-featured hardware UART (PL011) and a simpler "mini UART." By default, the hardware UART is claimed by the onboard Bluetooth module, not the GPIO header. The pins you actually get on GPIO14/15 are connected to the mini UART, which has some limitations (its baud rate is tied to the CPU clock, for instance).
If your project needs the full hardware UART on the header instead — for more reliable, high-speed serial communication — you can disable Bluetooth and reassign the hardware UART to GPIO14/15 via a device tree overlay (typically by enabling dtoverlay=disable-bt in config.txt). This is a common gotcha for anyone doing serial communication with sensors or other microcontrollers.
The BCM2711's Extra SPI and I2C Buses
Most references only mention the "standard" SPI bus (on GPIO7–11) and the two standard I2C buses (GPIO2/3, and the ID EEPROM pair on GPIO0/1). What often gets left out: the Pi 4's BCM2711 chip actually supports more SPI and I2C bus instances than that, accessible through alternate pin functions on GPIO pins that would otherwise be plain general-purpose I/O.
In practice, this means advanced projects that need more than one simultaneous SPI or I2C bus — for example, driving two SPI displays at once, or talking to multiple I2C device trees that would otherwise collide on the same bus — have more headroom on the Pi 4 than older Pi models offered. Enabling these additional buses requires a device tree overlay rather than just wiring up the pins, and the exact pin assignments are documented in Raspberry Pi's official BCM2711 peripherals datasheet.
This is a niche need for most projects — the standard single SPI and I2C bus covers the overwhelming majority of sensors and displays — but it's worth knowing this headroom exists before assuming you need a second Pi or an I2C multiplexer for a multi-bus project.
HAT Compatibility
The Pi 4 uses the same 40-pin, 2×20 header spacing and pin assignments as the Pi 3B+ and the Pi 5, so HATs (Hardware Attached on Top boards) designed for the standard 40-pin form factor are physically and electrically compatible. GPIO0 and GPIO1 (physical pins 27, 28) are specifically reserved so HATs can identify themselves to the Pi via an onboard ID EEPROM — avoid wiring anything else to these two pins if you're using HATs that rely on auto-detection.
Designing a custom HAT or breakout board for the Raspberry Pi 4? Get an instant PCB quote or request PCB assembly from NextPCB.
FAQ
Why doesn't serial communication work on GPIO14/15 on my Raspberry Pi 4?
By default, the Pi 4's full-featured hardware UART is claimed by the onboard Bluetooth module. GPIO14/15 are instead connected to a simpler software-based mini UART. If you need the hardware UART on the header, you can free it up by disabling Bluetooth via a device tree overlay.
Does the Raspberry Pi 4 support more than one SPI or I2C bus?
Yes. Beyond the standard SPI bus (GPIO7–11) and I2C bus (GPIO2/3), the BCM2711 chip supports additional SPI and I2C bus instances through alternate GPIO pin functions, enabled via device tree overlays. Most projects won't need this, but it's available for advanced multi-device setups.
Are Raspberry Pi 4 HATs compatible with the Pi 5?
Yes, physically and electrically. The Pi 4 and Pi 5 share the same 40-pin header layout and pin assignments, so HATs built for one will fit and function on the other.
