RASPBERRY PI 4 PINOUT

In this guide, we explore the Raspberry Pi 4 GPIO Pinout, a crucial aspect of harnessing the full power of this single-board computer. A compact single-board computer that brings desktop-level performance to the world of DIY electronics, IoT, media centers, and industrial automation. Whether you’re building a retro gaming console or a Kubernetes cluster, the Pi 4 Model B offers unmatched versatility at an unbeatable price. In this guide, we’ll dive deep into the Raspberry Pi 4’s GPIO pinout, helping you harness its full potential with clarity and precision.

What is the Raspberry Pi 4 Model B?

System-on-Module (SoM):
At its core, the Raspberry Pi 4 Model B features a Broadcom BCM2711 SoC with a quad-core Cortex-A72 64-bit processor clocked at 1.5 GHz. It comes in three memory configurations (2 GB, 4 GB, and 8 GB LPDDR4 RAM), making it suitable for both lightweight and memory-intensive applications.

Raspberry Pi 4 GPIO Pinout diagram

Connectivity:
The Pi 4 dramatically improves upon its predecessors with enhanced I/O: dual-band 802.11ac Wi-Fi, Bluetooth 5.0, true Gigabit Ethernet, two USB 3.0 ports, two USB 2.0 ports, and dual micro-HDMI outputs (supporting up to 4Kp60). A new USB-C connector supplies stable 5V/3A power.

GPIO Header:
A 40-pin header exposes 26 GPIO’s, multiple power pins, and essential interfaces like I2C, SPI, UART, and PWM. This interface makes the Pi 4 ideal for real-world hardware integration.

Raspberry Pi 4 GPIO Pinout diagram

Designed for Connectivity, Control, and Computation

The Raspberry Pi 4 Model B supports a wide array of features through its 40-pin GPIO header:

  • 26 general-purpose I/O pins
  • 3.3V logic level (do not connect 5V directly to GPIOs!)
  • SPI, I2C, UART, PWM
  • 3.3V and 5V power outputs
  • Multiple ground (GND) connections
  • Support for HAT EEPROM auto-detection
  • ID_SD and ID_SC pins for hardware identification

With this level of flexibility, the Raspberry Pi 4 can connect to virtually any sensor, actuator, or peripheral device.

Raspberry Pi 4 GPIO Pinout diagram

** The Raspberry Pi 4 pinout is available for download at the end of this post in high resolution – for free!

GPIO Power Pins

The GPIO header includes multiple power supply lines. Pins 1 and 17 provide 3.3V, while pins 2 and 4 offer a direct 5V output from the USB-C power source. Ground pins are available at positions 6, 9, 14, 20, 25, 30, 34, and 39. These power rails enable direct powering of sensors, displays, and low-power actuators.

Raspberry Pi 4 GPIO Pinout diagram

General Purpose Input/Output

There are 26 GPIO’s available on the Pi 4. Each GPIO is 3.3V logic and capable of both input and output. Input pins are used for reading sensors or button states, while output pins control LED’s, relays, and other devices. Be aware that GPIO’s are limited to a maximum current draw of ~16 mA per pin and ~50 mA total across all pins.

Raspberry Pi 4 GPIO Pinout diagram

I2C – Inter-Integrated Circuit

The I2C bus allows multiple devices to communicate using only two wires: SDA (data) and SCL (clock). The default I2C1 interface is exposed on GPIO2 (SDA) and GPIO3 (SCL), located at pins 3 and 5 respectively. You’ll often find I2C used for connecting temperature sensors, OLED displays, and real-time clocks.
Note: pull-up resistors are required on the bus lines.

Raspberry Pi 4 GPIO Pinout diagram

SPI – Serial Peripheral Interface

SPI enables fast communication with peripherals using four primary signals: MOSI (Master Out Slave In), MISO (Master In Slave Out), SCLK (clock), and CS (chip select). The Raspberry Pi exposes SPI0 by default with MOSI on GPIO10 (pin 19), MISO on GPIO9 (pin 21), SCLK on GPIO11 (pin 23), and CS lines on GPIO8 (CE0, pin 24) and GPIO7 (CE1, pin 26). Ideal for displays, flash memory, and high-speed ADC’s.

Raspberry Pi 4 GPIO Pinout diagram

UART – Serial Communication

The Pi’s default UART interface is available on GPIO14 (TX, pin 8) and GPIO15 (RX, pin 10). It supports communication with serial devices like GPS modules, Bluetooth interfaces, and console debugging tools. By default, this UART is used by the Linux terminal; to use it in your project, disable the console through raspi-config.

Raspberry Pi 4 GPIO Pinout diagram

PWM – Pulse Width Modulation

To get the most out of your Raspberry Pi 4 GPIO Pinout, it’s important to understand which pins support hardware features like PWM, SPI, and I2C. PWM enables fine control of power to devices like LED’s or servo’s by modulating the duty cycle of a digital signal. Hardware PWM is available on GPIO12 (pin 32), GPIO13 (pin 33), GPIO18 (pin 12), and GPIO19 (pin 35). Additional software PWM can be implemented on most other GPIO’s using libraries such as RPi.GPIO or pigpio.

EEPROM ID Pins

GPIO0 and GPIO1, found at pins 27 and 28, are reserved for EEPROM identification of HATs (Hardware Attached on Top). These pins use I2C to detect the attached board and should not be used for general-purpose I/O unless you’re designing a custom HAT and know what you’re doing.

Raspberry Pi 4 GPIO pinout overview

PinBCMNameFunction(s)Notes
13.3VPowerConstant 3.3V output
25VPowerDirect 5V from USB-C
32SDA1I2CRequires pull-up resistor
45VPowerDirect 5V from USB-C
53SCL1I2CRequires pull-up resistor
6GNDGround
74GPIO4GPIOGeneral-purpose I/O
814TXD0UART TXSerial transmit
9GNDGround
1015RXD0UART RXSerial receive
1117GPIO17GPIO
1218GPIO18GPIO, PWMHardware PWM
1327GPIO27GPIO
14GNDGround
1522GPIO22GPIO
1623GPIO23GPIO
173.3VPowerConstant 3.3V output
1824GPIO24GPIO
1910MOSISPISPI Master Out
20GNDGround
219MISOSPISPI Master In
2225GPIO25GPIO
2311SCLKSPISPI Clock
248CE0SPI Chip Select 0
25GNDGround
267CE1SPI Chip Select 1
270ID_SDEEPROM I2C DataReserved for HATs
281ID_SCEEPROM I2C ClockReserved for HATs
295GPIO5GPIO
30GNDGround
316GPIO6GPIO
3212GPIO12GPIO, PWMHardware PWM
3313GPIO13GPIO, PWMHardware PWM
34GNDGround
3519GPIO19GPIO, PWM, SPIHardware PWM
3616GPIO16GPIO
3726GPIO26GPIO
3820GPIO20GPIO
39GNDGround
4021GPIO21GPIO

Best Practices and Common Mistakes

Optimize your Raspberry Pi projects by avoiding these common mistakes:

  • Do not apply more than 3.3V to any GPIO pin.
  • Use level shifters when interfacing with 5V logic.
  • Always use resistors for current protection when driving LED’s.
  • Avoid using pins 27 and 28 unless designing a HAT.
  • Clean up GPIO states at the end of your Python scripts.
  • Avoid pulling too much current from 3.3V/5V rails.
  • Debounce mechanical buttons in software or hardware.

How to Program the GPIO

Development Environments:

  • Python (with RPi.GPIOgpiozero, or pigpio)
  • C/C++ with wiringPi or libgpiod
  • Node.js with onoff or pigpio

Basic Python Example (Blink an LED on GPIO17):

from gpiozero import LED
from time import sleep

led = LED(17)

while True:
led.on()
sleep(1)
led.off()
sleep(1)

Run the script with:

python3 blink.py

Be sure to enable GPIO access and run scripts with appropriate permissions (sudo if needed).

Conclusion: Engineered for Innovation

The Raspberry Pi 4 Model B is more than a computer – it’s a launchpad for creativity. With its powerful CPU, flexible GPIO’s, and vast ecosystem, it brings the future of embedded computing to your desktop. Mastering its GPIO layout empowers you to create smart projects that are limited only by your imagination.

Download the ESP32 pinout here in high resolution – for free*!

Free to use under the MIT license — attribution is required.

Scroll to Top