# Raspberry Pi Pinouts: A Comprehensive Guide

Understand the Raspberry Pi 40-pin GPIO header, physical vs. GPIO numbering, power pins, I2C, SPI, UART, and PWM before wiring your project.

Written by [Jharwin Barrozo](https://www.flux.ai/jharwinbarrozo)

Published Sep 2026 - 8 min read

[![A raspberry pi 3B and zero boards laid out together showing graphical GPIO pinout](https://www.flux.ai/p/assets/blogs/raspberry-pi-guide/main.webp)](#)

### 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.

![](https://www.flux.ai/p/assets/blog-content/670d795af08a0e9aaea83ce5_63ed1d36ebf0b1483327a3ed_raspberry-pi-pinout.jpeg)

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:

```bash
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:

```python
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.

[

![3D PCB view of the project](https://www.flux.ai/p/assets/featured_projects/pcb3d_preview/xiao-rp2040-pcb.webp)

](https://www.flux.ai/seeedstudio/seeed-studio-xiao-rp2040?editor=pcb_3d)[Seeed Studio XIAO RP2040](https://www.flux.ai/seeedstudio/seeed-studio-xiao-rp2040?editor=pcb_3d)

### 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.

[

![3D PCB view of the project](https://www.flux.ai/p/assets/featured_projects/pcb3d_preview/pi-macro-keyboard.webp)

](https://www.flux.ai/flux/pico-macro-keyboard)[Pico Macro Keyboard](https://www.flux.ai/flux/pico-macro-keyboard)

### 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.

```python
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](https://www.flux.ai/signup) and bring your ideas to life!

## About the author

[Jharwin Barrozo](https://www.flux.ai/jharwinbarrozo)

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](https://flux.ai/jharwinbarrozo)

Let’s start building

Build your big idea together with Flux. 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.

![Close-up photo of a PCB made with Flux, with an ESP32 module, buttons, and a microSD slot.](https://www.flux.ai/p/assets/blogs/miscellaneous/sidebar-cta-pcb.webp) [Try it Free](https://www.flux.ai/signup)

## More in Component & Platform Guides

[

![A 3d model of arduino uno board](https://www.flux.ai/p/assets/blogs/arduino-getting-started/main.webp)

### Arduino Uno Basics: Beginner's Guide to Getting Started

15 Min Read](https://www.flux.ai/p/blog/arduino-uno-basics-beginners-guide-to-getting-started)[

![ESP32 Board with its pinout label and diagram, each pin label and function on different colors](https://www.flux.ai/p/assets/blogs/esp32-pinout/main.webp)

### ESP32 Pinout Guide: Everything You Need to Know

11 Min Read](https://www.flux.ai/p/blog/esp32-pinout-everything-you-need-to-know)[

![An arduino uno microcontroller board with its sketch code on Arduino IDE being used as background in a monitor.](https://www.flux.ai/p/assets/blogs/arduino-code-guide/main.webp)

### Arduino Code for Beginners: How to Write Your First Sketch

8 Min Read](https://www.flux.ai/p/blog/arduino-code-a-comprehensive-guide-for-beginners)[

![Meet the Arduino Nano R4: Why Is This Tiny Upgrade So Big for Makers?](https://www.flux.ai/p/assets/blogs/arduino-nano-r4/main.webp)

### Meet the Arduino Nano R4: Why Is This Tiny Upgrade So Big for Makers?

6 Min Read](https://www.flux.ai/p/blog/meet-the-arduino-nano-r4-why-is-this-tiny-upgrade-so-big-for-makers)[

![A microcontroller board with the words Arduino Pro Micro on it.](https://www.flux.ai/p/assets/blogs/arduino-pro-micro/main.webp)

### What is Arduino Pro Micro: a Comprehensive Introduction for Novices

5 Min Read](https://www.flux.ai/p/blog/what-is-arduino-pro-micro-a-comprehensive-introduction-for-novices)[

![Schematic diagram of arduino uno board with all of its passive and active components](https://www.flux.ai/p/assets/blogs/arduino-uno-schematic-diagram/main.webp)

### Arduino Uno Schematic Diagram: A Comprehensive Guide

8 Min Read](https://www.flux.ai/p/blog/arduino-uno-schematic-diagram)[

![Side by side comparison of the 3 powerful and most common Arduino microcontroller boards; Arduino Mega 2560, Arduino Uno and Arduino Micro.](https://www.flux.ai/p/assets/blogs/arduino-mega-uno-micro/main.webp)

### Arduino Mega vs. Uno vs. Micro: Key Differences

6 Min Read](https://www.flux.ai/p/blog/what-is-the-real-difference-arduino-mega-vs-micro-vs-uno)[

![Different packages or footprint of famous atmega328p microcontroller with its pinout](https://www.flux.ai/p/assets/blogs/atmega328p-still-top-choice/main.webp)

### Why Atmega328p is Still a Top Choice for Microcontroller Projects in 2023

8 Min Read](https://www.flux.ai/p/blog/why-atmega328p-is-still-a-top-choice-for-microcontroller-projects-in-2023)[

![ESP32 Chip in a dark background: A powerful microcontroller with integrated Wi-Fi and Bluetooth, driving IoT innovation with seamless connectivity.](https://www.flux.ai/p/assets/blogs/esp32-history/main.webp)

### Exploring ESP32: from History to Application

3 Min Read](https://www.flux.ai/p/blog/exploring-esp32-from-history-to-application)[

![3d rendered of an ESP8266 microcontroller board, showing its compact size with the Wi-Fi module, chip antenna, and GPIO pins clearly visible, ideal for embedding wireless internet connectivity into DIY electronics projects.](https://www.flux.ai/p/assets/blogs/everything-about-esp8266/main.webp)

### ESP8266 Pinout Guide: Complete GPIO Reference & IoT Project Tips

10 Min Read](https://www.flux.ai/p/blog/esp8266-pinout-everything-you-need-to-know)[

![Attiny85 chip in two different packages viewed on top, also showing pinout diagram](https://www.flux.ai/p/assets/blogs/attiny85/main.webp)

### Introduction to the ATtiny85 Microcontroller

12 Min Read](https://www.flux.ai/p/blog/introduction-to-the-attiny85-microcontroller)[

![STM32 microcontroller chip overview – Why choose STM32? Discover STM32F4 ARM-based processors, optimized for performance with USB OTG, SWD, and UART support](https://www.flux.ai/p/assets/blogs/stm32-things-you-need-to-know/main.webp)

### STM32: Things You Need to Know

10 Min Read](https://www.flux.ai/p/blog/stm32-things-you-need-to-know)[

![Arduino Nano Guide](https://www.flux.ai/p/assets/blogs/arduino-nano-guide/main.webp)

### Arduino Nano Guide

10 Min Read](https://www.flux.ai/p/blog/arduino-nano-guide)[

![A top view photo of raspberry pi zero 2 w board](https://www.flux.ai/p/assets/blogs/pi-zero-2w/main.webp)

### Raspberry Pi Zero 2 W Review: a Powerful and Affordable Mini Computer

9 Min Read](https://www.flux.ai/p/blog/raspberry-pi-zero-2-w-review-a-powerful-and-affordable-mini-computer)[

![RP2350 A4 Stepping: Why Raspberry Pi Pico’s Latest Upgrade Changes Everything](https://www.flux.ai/p/assets/blogs/rp2350-a4-stepping/main.webp)

### RP2350 A4 Stepping: Why Raspberry Pi Pico’s Latest Upgrade Changes Everything

8 Min Read](https://www.flux.ai/p/blog/rp2350-a4-stepping-why-raspberry-pi-picos-latest-upgrade-changes-everything)[

![Photos of Raspberry Pi Pico 2 PCB board and its predecessor Raspberry Pi Pico boards laid out with a text suggesting their key differences](https://www.flux.ai/p/assets/blogs/pi-pico-vs-pi-pico-2/main.webp)

### Raspberry Pi Pico 2 vs Pico: Key Differences and Upgrades

8 Min Read](https://www.flux.ai/p/blog/whats-new-in-the-raspberry-pi-pico-2-a-showdown-with-the-original-raspberry-pi-pico)[

![Choosing the Right Platform to Build Your Project](https://www.flux.ai/p/assets/blogs/choosing-the-right-microcontroller/main.webp)

### Choosing the Right Platform to Build Your Project

9 Min Read](https://www.flux.ai/p/blog/choosing-the-right-platform-to-build-your-project)[

![Raspberry pi boards and arduino boards laid out side by side.](https://www.flux.ai/p/assets/blogs/arduino-vs-raspberry-pi/main.webp)

### Arduino vs. Raspberry Pi: Key Differences and Which to Choose

8 Min Read](https://www.flux.ai/p/blog/arduino-vs-raspberry-pi-comparison)[

![ESP32 boards and Arduino boards side by side, highlighting the comparison between these popular IoT microcontroller platforms.](https://www.flux.ai/p/assets/blogs/esp32-vs-arduino/main.webp)

### ESP32 vs Arduino: Key Differences & Which to Choose?

8 Min Read](https://www.flux.ai/p/blog/esp32-vs-arduino)[

![arduino board and text suggesting this is all about the arduino map () function](https://www.flux.ai/p/assets/blogs/arduino-map-function/main.webp)

### How to Use the Arduino map() Function: A Complete Guide

4 Min Read](https://www.flux.ai/p/blog/how-to-use-the-arduino-map-function-a-complete-guide)[

![A simplified schematic diagram illustrates how pull-up and pull-down resistors are utilized in microcontroller applications](https://www.flux.ai/p/assets/blogs/pull-up-down-resistors/main.webp)

### Understanding Pull-up and Pull-down Resistors: A Guide for Arduino and Microcontrollers

7 Min Read](https://www.flux.ai/p/blog/understanding-pull-up-and-pull-down-resistors-a-guide-for-arduino-and-microcontrollers)[

![What Is an Open Circuit? Causes, Examples, and Troubleshooting](https://www.flux.ai/p/assets/blogs/what-is-an-open-circuit/main.webp)

### What Is an Open Circuit? Causes, Examples, and Troubleshooting

10 Min Read](https://www.flux.ai/p/blog/what-is-an-open-circuit)

See All (22)

## 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](https://www.flux.ai/signup)

 ![Close-up of a Flux-designed printed circuit board](https://www.flux.ai/p/assets/homepage-v2/mission-visual.webp)
