The Raspberry Pi 4 (and the keyboard-based Pi 400) has the classic 40-pin GPIO header. Compared with the Pi 3, however, its BCM2711 processor offers many more buses on it: besides the default UART, I2C1 and SPI0/1, there are also UART2–5, I2C3–6 and SPI3–6.
The diagram shows all alternate functions of each pin that can be enabled via dtoverlay.
Specifications
- 28 GPIO with 3.3 V logic (GPIO0–27)
- 6× UART (UART0 = PL011, UART1 = mini UART, UART2–5 via overlay)
- I2C1 and I2C3–6, SPI0, SPI1 and SPI3–6
- 2 hardware PWM channels (GPIO12/13 or GPIO18/19), PCM/I2S on GPIO18–21
- power: 2× 5 V and 2× 3.3 V, 8× GND
- the same layout on the Raspberry Pi 400 and Compute Module 4 (via the IO board)
Enable the buses in config.txt, e.g. dtoverlay=uart3, dtoverlay=i2c4 or dtoverlay=spi4-1cs. dtoverlay -h describes all overlays.
The layout common to all models is on the Raspberry Pi GPIO Pinout page, the newer model on the Raspberry Pi 5 GPIO Pinout page.
Pinout and pin table
How to read the diagram: it shows all functions of the BCM2711 chip. Only the default buses (UART on GPIO14/15, I2C1, SPI0/1) apply to all models – UART2–5, I2C3–6 and SPI3–6 exist only on the Pi 4 and 400. On the Pi 5, the same pins have different bus numbers (UART3 on GPIO4/5 is UART2 there). Hover over a pin in the diagram or a table row; use the filter to highlight a bus. You can download the pinout as PNG or SVG.
| Pin | Name | Direction | UART | I2C | SPI | PWM | I2S (PCM) | Note |
|---|---|---|---|---|---|---|---|---|
| 1 | 3V3 | output | 3.3 V output – only for smaller loads (sensors) | |||||
| 2 | 5V | input/output | 5 V directly from the Pi's power supply – can also power the Pi (unprotected) | |||||
| 3 | GPIO2 | input/output | I2C1 SDA / I2C3 SDA | SPI3 MOSI | I2C1 SDA; 1.8 kΩ pull-up on the board | |||
| 4 | 5V | input/output | 5 V directly from the Pi's power supply – can also power the Pi (unprotected) | |||||
| 5 | GPIO3 | input/output | I2C1 SCL / I2C3 SCL | SPI3 SCLK | I2C1 SCL; 1.8 kΩ pull-up on the board. Shorting to GND turns on a powered-off Pi (Pi 4 and earlier; Pi 5 only via button) | |||
| 6 | GND | – | ||||||
| 7 | GPIO4 | input/output | UART3 TX | I2C3 SDA | SPI4 CE0 | GPCLK0; default 1-Wire pin (dtoverlay=w1-gpio) | ||
| 8 | GPIO14 | input/output | UART0 TX / UART1 TX | SPI5 MOSI | UART TX. With Bluetooth enabled, GPIO14/15 carry the mini UART (UART1, dependent on the GPU clock); the full PL011 (UART0) handles Bluetooth. After dtoverlay=disable-bt or miniuart-bt, the PL011 is on the header. Enable the additional UART2–5 via dtoverlay=uart2 to uart5. | |||
| 9 | GND | – | ||||||
| 10 | GPIO15 | input/output | UART0 RX / UART1 RX | SPI5 SCLK | UART RX – serial console | |||
| 11 | GPIO17 | input/output | SPI1 CE1 | |||||
| 12 | GPIO18 | input/output | SPI1 CE0 / SPI6 CE0 | PWM0 | PCM CLK | PWM0; PCM CLK (I2S); SPI1 CE0 | ||
| 13 | GPIO27 | input/output | SPI6 CE1 | JTAG ARM_TMS | ||||
| 14 | GND | – | ||||||
| 15 | GPIO22 | input/output | I2C6 SDA | I2C6 SDA; JTAG ARM_TRST | ||||
| 16 | GPIO23 | input/output | I2C6 SCL | I2C6 SCL; JTAG ARM_RTCK | ||||
| 17 | 3V3 | output | 3.3 V output – only for smaller loads (sensors) | |||||
| 18 | GPIO24 | input/output | SPI3 CE1 | JTAG ARM_TDO | ||||
| 19 | GPIO10 | input/output | I2C5 SDA | SPI0 MOSI | ||||
| 20 | GND | – | ||||||
| 21 | GPIO9 | input/output | UART4 RX | I2C4 SCL | SPI0 MISO | |||
| 22 | GPIO25 | input/output | SPI4 CE1 | JTAG ARM_TCK | ||||
| 23 | GPIO11 | input/output | I2C5 SCL | SPI0 SCLK | ||||
| 24 | GPIO8 | input/output | UART4 TX | I2C4 SDA | SPI0 CE0 | |||
| 25 | GND | – | ||||||
| 26 | GPIO7 | input/output | I2C4 SCL | SPI0 CE1 / SPI4 SCLK | ||||
| 27 | GPIO0 | input/output | UART2 TX | ID_SD / I2C6 SDA | SPI3 CE0 | ID_SD – I2C0 for the HAT EEPROM, otherwise do not use. Alternatively I2C6 SDA, UART2 TX (dtoverlay=uart2) or SPI3 CE0. | ||
| 28 | GPIO1 | input/output | UART2 RX | ID_SC / I2C6 SCL | SPI3 MISO | ID_SC – I2C0 for the HAT EEPROM, otherwise do not use. Alternatively I2C6 SCL, UART2 RX or SPI3 MISO. | ||
| 29 | GPIO5 | input/output | UART3 RX | I2C3 SCL | SPI4 MISO | GPCLK1 | ||
| 30 | GND | – | ||||||
| 31 | GPIO6 | input/output | I2C4 SDA | SPI4 MOSI | GPCLK2 | |||
| 32 | GPIO12 | input/output | UART5 TX | I2C5 SDA | SPI5 CE0 | PWM0 | PWM0 | |
| 33 | GPIO13 | input/output | UART5 RX | I2C5 SCL | SPI5 MISO | PWM1 | PWM1 | |
| 34 | GND | – | ||||||
| 35 | GPIO19 | input/output | SPI1 MISO / SPI6 MISO | PWM1 | PCM FS | PWM1; PCM FS (I2S); SPI1 MISO | ||
| 36 | GPIO16 | input/output | SPI1 CE2 | |||||
| 37 | GPIO26 | input/output | SPI5 CE1 | JTAG ARM_TDI | ||||
| 38 | GPIO20 | input/output | SPI1 MOSI / SPI6 MOSI | PCM DIN | PCM DIN (I2S); SPI1 MOSI | |||
| 39 | GND | – | ||||||
| 40 | GPIO21 | input/output | SPI1 SCLK / SPI6 SCLK | PCM DOUT | PCM DOUT (I2S); SPI1 SCLK |
What to watch out for
- GPIO are not 5V tolerant. 5 V on an input can destroy the Raspberry Pi.
- With Bluetooth enabled, GPIO14/15 carry the mini UART, whose speed depends on the GPU clock. You can get the full PL011 on the header with
dtoverlay=disable-btorminiuart-bt. - Connecting GPIO3 to GND powers on a shut-down Pi 4.
- GPIO2/3 (I2C1) have 1.8 kΩ pull-ups on the board.
- GPIO0/1 (ID_SD/ID_SC) are reserved for the HAT EEPROM.
- A pin can have only one function at a time – choose overlays so that their pins don’t overlap.
Raspberry Pi on chiptron.eu/
Projects and guides on chiptron.eu/:
- Raspberry Pi prices go up – current Pi 4 and Pi 5 prices and availability at retailers
More pinouts
See all pinouts on the Pinouts page.