Opens in a new tab

Raspberry Pi 4 GPIO Pinout

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.

Raspberry Pi 4 – GPIO pinout (40 pins, BCM2711)Raspberry Pi 4 – GPIO pinout (40 pins, BCM2711)chiptron.eu · CC BY 4.0Raspberry Pi is a trademark of Raspberry Pi Ltd. 1 3V3 ← 3.3 V output – only for smaller loads (sensors) 3 GPIO2 I2C1 SDA / I2C3 SDA SPI3 MOSI 5 GPIO3 I2C1 SCL / I2C3 SCL SPI3 SCLK 7 GPIO4 I2C3 SDA UART3 TX SPI4 CE0 GPCLK0 9 GND 11 GPIO17 SPI1 CE1 13 GPIO27 SPI6 CE1 15 GPIO22 I2C6 SDA 17 3V3 ← 19 GPIO10 I2C5 SDA SPI0 MOSI 21 GPIO9 I2C4 SCL UART4 RX SPI0 MISO 23 GPIO11 I2C5 SCL SPI0 SCLK 25 GND 27 GPIO0 ID_SD / I2C6 SDA UART2 TX SPI3 CE0 29 GPIO5 I2C3 SCL UART3 RX SPI4 MISO GPCLK1 31 GPIO6 I2C4 SDA SPI4 MOSI GPCLK2 33 GPIO13 I2C5 SCL UART5 RX PWM1 SPI5 MISO 35 GPIO19 PWM1 PCM FS SPI1 MISO / SPI6 MISO 37 GPIO26 SPI5 CE1 39 GND 2 5V ↔ 5 V directly from the Pi's power supply – can also power the Pi (unprotected) 4 5V ↔ 6 GND 8 GPIO14 UART0 TX / UART1 TX SPI5 MOSI 10 GPIO15 UART0 RX / UART1 RX SPI5 SCLK 12 GPIO18 PWM0 PCM CLK SPI1 CE0 / SPI6 CE0 14 GND 16 GPIO23 I2C6 SCL 18 GPIO24 SPI3 CE1 20 GND 22 GPIO25 SPI4 CE1 24 GPIO8 I2C4 SDA UART4 TX SPI0 CE0 26 GPIO7 I2C4 SCL SPI0 CE1 / SPI4 SCLK 28 GPIO1 ID_SC / I2C6 SCL UART2 RX SPI3 MISO 30 GND 32 GPIO12 I2C5 SDA UART5 TX PWM0 SPI5 CE0 34 GND 36 GPIO16 SPI1 CE2 38 GPIO20 PCM DIN SPI1 MOSI / SPI6 MOSI GPCLK0 40 GPIO21 PCM DOUT SPI1 SCLK / SPI6 SCLK GPCLK1 GPIO UART I2C SPI PWM I2S (PCM) Power Ground (GND)
Download:PNGSVG
Pin table – Raspberry Pi 4 (GPIO)
PinNameDirectionUARTI2CSPIPWMI2S (PCM)Note
13V3output3.3 V output – only for smaller loads (sensors)
25Vinput/output5 V directly from the Pi's power supply – can also power the Pi (unprotected)
3GPIO2input/outputI2C1 SDA / I2C3 SDASPI3 MOSII2C1 SDA; 1.8 kΩ pull-up on the board
45Vinput/output5 V directly from the Pi's power supply – can also power the Pi (unprotected)
5GPIO3input/outputI2C1 SCL / I2C3 SCLSPI3 SCLKI2C1 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)
6GND–
7GPIO4input/outputUART3 TXI2C3 SDASPI4 CE0GPCLK0; default 1-Wire pin (dtoverlay=w1-gpio)
8GPIO14input/outputUART0 TX / UART1 TXSPI5 MOSIUART 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.
9GND–
10GPIO15input/outputUART0 RX / UART1 RXSPI5 SCLKUART RX – serial console
11GPIO17input/outputSPI1 CE1
12GPIO18input/outputSPI1 CE0 / SPI6 CE0PWM0PCM CLKPWM0; PCM CLK (I2S); SPI1 CE0
13GPIO27input/outputSPI6 CE1JTAG ARM_TMS
14GND–
15GPIO22input/outputI2C6 SDAI2C6 SDA; JTAG ARM_TRST
16GPIO23input/outputI2C6 SCLI2C6 SCL; JTAG ARM_RTCK
173V3output3.3 V output – only for smaller loads (sensors)
18GPIO24input/outputSPI3 CE1JTAG ARM_TDO
19GPIO10input/outputI2C5 SDASPI0 MOSI
20GND–
21GPIO9input/outputUART4 RXI2C4 SCLSPI0 MISO
22GPIO25input/outputSPI4 CE1JTAG ARM_TCK
23GPIO11input/outputI2C5 SCLSPI0 SCLK
24GPIO8input/outputUART4 TXI2C4 SDASPI0 CE0
25GND–
26GPIO7input/outputI2C4 SCLSPI0 CE1 / SPI4 SCLK
27GPIO0input/outputUART2 TXID_SD / I2C6 SDASPI3 CE0ID_SD – I2C0 for the HAT EEPROM, otherwise do not use. Alternatively I2C6 SDA, UART2 TX (dtoverlay=uart2) or SPI3 CE0.
28GPIO1input/outputUART2 RXID_SC / I2C6 SCLSPI3 MISOID_SC – I2C0 for the HAT EEPROM, otherwise do not use. Alternatively I2C6 SCL, UART2 RX or SPI3 MISO.
29GPIO5input/outputUART3 RXI2C3 SCLSPI4 MISOGPCLK1
30GND–
31GPIO6input/outputI2C4 SDASPI4 MOSIGPCLK2
32GPIO12input/outputUART5 TXI2C5 SDASPI5 CE0PWM0PWM0
33GPIO13input/outputUART5 RXI2C5 SCLSPI5 MISOPWM1PWM1
34GND–
35GPIO19input/outputSPI1 MISO / SPI6 MISOPWM1PCM FSPWM1; PCM FS (I2S); SPI1 MISO
36GPIO16input/outputSPI1 CE2
37GPIO26input/outputSPI5 CE1JTAG ARM_TDI
38GPIO20input/outputSPI1 MOSI / SPI6 MOSIPCM DINPCM DIN (I2S); SPI1 MOSI
39GND–
40GPIO21input/outputSPI1 SCLK / SPI6 SCLKPCM DOUTPCM 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-bt or miniuart-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/:

More pinouts

See all pinouts on the Pinouts page.

Related Articles