Raspberry Pi Pinouts: A Comprehensive Guide

Understanding the Raspberry Pi GPIO Header

The Raspberry Pi pinout shows which header pins provide power, ground, general-purpose input/output (GPIO), and interfaces such as I2C, SPI, and UART. This guide covers the standard 40-pin header used by Raspberry Pi 3, 4, 5, and Zero-family computers—not the separate pinout of Raspberry Pi Pico microcontroller boards.

Raspberry Pi Pinout

The 40-pin header provides access to GPIO, I2C, SPI, UART, and power connections for sensors and add-on boards, including HATs (Hardware Attached on Top). Physical pin numbers describe positions 1–40; GPIO numbers identify signals and do not follow that sequence. For example, physical pin 7 is GPIO4. Use the pin-1 marker and the diagram below to orient the board before wiring; GPIO signals use 3.3V logic and must not be connected directly to 5V signals.

Pinout depicts pin 1 in the bottom left corner. Pin 1 is the only pin with a square solder pad, which may only be visible from the underside of your Pi.

How do I control GPIO pins on a Raspberry Pi?

GPIO pins can be controlled from Python to interface with devices and sensors. GPIO Zero is a beginner-friendly option supported by Raspberry Pi OS, including on Raspberry Pi 5 with a compatible backend. The older RPi.GPIO library should not be assumed to work on every model. If GPIO Zero is not installed, run:

sudo apt update
sudo apt install python3-gpiozero

The following Python example configures GPIO4, which is physical pin 7, as an output and holds it HIGH while the script runs:

from gpiozero import DigitalOutputDevice
from signal import pause

output = DigitalOutputDevice(4)
output.on()
pause()

GPIO Zero uses GPIO numbering by default: DigitalOutputDevice(4) refers to GPIO4, not physical pin 4. The on() call sets the output HIGH at 3.3V, and pause() keeps the script running. If you test with an LED, include a current-limiting resistor; do not connect a motor directly to a GPIO pin.

It is important to note that when controlling the GPIO pins, you need to be careful and follow the recommended procedures, as incorrect use can cause damage to the Raspberry Pi or other connected devices. Always refer to the datasheet of the devices you are connecting to the Raspberry Pi to ensure that you are using the correct voltage levels and pin configurations.

Power Pins

The standard 40-pin header has two 5V pins, two 3.3V pins, and eight ground pins. Power rails and GPIO signal pins serve different purposes:

  • 5V: Physical pins 2 and 4 connect to the 5V rail. The available current for external devices depends on the Raspberry Pi model, power supply, and other connected loads; there is no universal 3A allowance per pin.
  • 3.3V: Physical pins 1 and 17 provide the 3.3V rail for suitable low-voltage peripherals. Check the board’s power budget and the peripheral’s current requirements rather than assuming a fixed 50mA limit.
  • GND: Physical pins 6, 9, 14, 20, 25, 30, 34, and 39 provide ground connections. Connect the grounds of the Raspberry Pi and external circuitry when exchanging signals.
  • Supply limits: There is no dedicated “5V STBY” pin on the standard 40-pin header. Do not confuse either power rail with a GPIO signal, and use an appropriate driver or separate supply for loads that exceed the board’s capabilities.

What are the SDA and SCL pins on a Raspberry Pi for? 

  • GPIO2 / SDA1 (physical pin 3): The bidirectional data line for the commonly used I2C1 bus.
  • GPIO3 / SCL1 (physical pin 5): The clock line for the commonly used I2C1 bus.

SDA and SCL are two pins on the Raspberry Pi header that are used for communication with I2C (Inter-Integrated Circuit) devices. SDA stands for Serial Data Line, and it is used for transmitting data between the Raspberry Pi and the I2C device. SCL stands for Serial Clock Line, and it provides the clock signal that synchronizes the communication between the Raspberry Pi and the I2C device.

I2C is a multi-slave serial communication protocol, which means that multiple devices can be connected to the same two lines (SDA and SCL), and each device can be addressed individually. The Raspberry Pi supports I2C communication, which allows for easy interfacing with various I2C devices, such as sensors, displays, and other peripherals.

Enable I2C in the Raspberry Pi configuration before using an I2C peripheral. The common SDA1/SCL1 pair is on physical pins 3 and 5; physical pins 27 and 28 are reserved for HAT identification and should not be treated as the default sensor bus.

SPI Pins

SPI uses separate data and clock signals, usually with a chip-select connection for each device. The standard SPI0 connections below are identified by both GPIO and physical pin number; its common chip selects are CE0 on GPIO8 (pin 24) and CE1 on GPIO7 (pin 26). Enable SPI before use.

  • MOSI (Master Out Slave In): GPIO10, physical pin 19, sends data from the Raspberry Pi to the SPI device.
  • MISO (Master In Slave Out): GPIO9, physical pin 21, receives data from the SPI device.
  • SCLK (Serial Clock): GPIO11, physical pin 23, provides the clock signal for SPI0.

UART Pins

UART provides serial communication with devices such as GPS modules and microcontrollers. The commonly used header TXD and RXD signals are listed below; the UART assignment and configuration depend on the Raspberry Pi model. Enable the required serial interface and disable the serial login console if it would conflict with your device. Use 3.3V-compatible signals, not direct RS-232 voltage levels.

  • TXD (Transmit Data): GPIO14, physical pin 8, sends serial data to the connected device’s receive pin.
  • RXD (Receive Data): GPIO15, physical pin 10, receives serial data from the connected device’s transmit pin.

What are the PWM pins on a Raspberry Pi? 

PWM (Pulse Width Modulation) is a technique used to control the amount of power delivered to an electrical device by switching it on and off rapidly. On the Raspberry Pi, some of the GPIO pins can be used as PWM pins, allowing you to generate PWM signals and control the power delivered to external devices.

On Raspberry Pi 3 and 4, common hardware-PWM-capable header signals are GPIO12 (physical pin 32), GPIO13 (pin 33), GPIO18 (pin 12), and GPIO19 (pin 35). Some share PWM channels, so they are not all independent outputs. Raspberry Pi 5 uses the RP1 controller; check its supported PWM configuration rather than assuming older register-level code will work.

For basic LED dimming or a low-speed PWM demonstration, GPIO Zero can generate a PWM output. This example requests 50Hz with a 25% duty cycle on GPIO18, physical pin 12. It is not a guarantee of hardware-timed PWM; timing depends on the backend and system load.

from gpiozero import PWMOutputDevice
from signal import pause

pwm = PWMOutputDevice(18, frequency=50)
pwm.value = 0.25
pause()

PWMOutputDevice(18, frequency=50) selects GPIO18 and a requested frequency of 50Hz. Setting value to 0.25 requests a 25% duty cycle; values range from 0.0 to 1.0. Use a suitable driver for higher-current loads and hardware-timed PWM or a dedicated controller when precise timing matters.

It is important to note that the number of PWM pins on the Raspberry Pi is limited, and if you need more PWM outputs, you may need to use an external PWM controller or a multiplexer to expand the number of available PWM pins.

Do all Raspberry Pi have the same pinout?

No. Raspberry Pi computers with the standard 40-pin header share its main power, ground, and GPIO pin assignments, including Zero, Zero W, and Zero 2 W models; some Zero boards ship without the header soldered in. Early Raspberry Pi Model A/B boards used a 26-pin header. Raspberry Pi Pico boards and Compute Modules use different connectors or pinouts. Shared header positions also do not guarantee identical alternate functions, software support, or power budgets.

Are Raspberry Pi 3 and 4 pins the same?

Yes. Raspberry Pi 3 and 4 models with the standard 40-pin header use the same physical pin assignments for power, ground, and GPIO; the header pins are not rearranged on the Pi 4. Check a HAT or peripheral’s mechanical clearance, power needs, and software support before moving it between boards.

The Raspberry Pi pinout diagram is a critical component of the board, as it provides access to the GPIO, I2C, SPI, UART, and power pins. This comprehensive guide has described each of the 40 pins on the Raspberry Pi header, including their functions and usage. Understanding the Raspberry Pi pinout diagram is crucial for electrical engineers, as it allows them to interface with various devices and sensors, and to create innovative projects and applications.

Design Smarter, Not Harder – Build Your PCB with Flux

Whether you’re experimenting with an ATmega328 for your first Arduino project or building a cutting-edge ESP32-based IoT device, designing a custom PCB will take your project to the next level. Flux makes it easy with an intuitive interface, smart design tools, and access to a huge component library. No matter your experience level, Flux helps you create PCBs quickly and efficiently, without the usual headaches.

Get started today—sign up for Flux and bring your ideas to life!

About the author

Jharwin Barrozo

Electronics Engineer at Flux

Jharwin is an electronics engineer mainly focused on satellites. He built his own ground station using Flux to monitor RF activities on the International Space Station. Find him on Flux @jharwinbarrozo

More in Component & Platform Guides

Let’s start building.

Let’s build your idea together. All you need to do is describe what you want to make, or what problem you want to solve. Flux will work with you to make it a reality.

Try it Free
Close-up of a Flux-designed printed circuit board