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

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:
The following Python example configures GPIO4, which is physical pin 7, as an output and holds it HIGH while the script runs:
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.
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:
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 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.
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.
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.
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.
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.
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.
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!

Learn about STM32 microcontrollers, popular series, USB OTG, SWD, UART, and development tools. Find the right STM32 MCU and kickstart your projects.

Use this ESP32 pinout guide to identify GPIO, ADC, DAC, PWM, I2C, SPI, UART, touch, strapping, and input-only pins on classic ESP32 boards.

Looking for a comprehensive guide to ESP8266 pinout? Check out our article that covers everything you need to know about the ESP8266's pins, including digital, analog, and PWM pins. Perfect for beginners and experts alike, our guide will help you understand the ESP8266's pinout and how to use it in your projects.

The Raspberry Pi Zero 2 W is a small and powerful computer with impressive performance for its size and price. With a quad-core processor, 512MB of RAM, built-in wireless connectivity, and a USB On-The-Go port, it's suitable for many projects, including home automation, media centers, and robotics.

Understanding amps and volts is key to working with electronics. This guide explains their roles, relationship, and practical applications.

The blog post dives into the technical aspects of Multilayer Ceramic Capacitors (MLCCs), highlighting their importance in electronic circuits. It explains the construction of MLCCs, where layers of ceramic material and metal electrodes create a multilayered structure to store electrical energy.

The blog offers an in-depth look at Zener diodes, highlighting their crucial role in voltage regulation and stability in electronic circuits. It covers their basic principles, applications, and the challenges faced in their usage.

Compare ESP32 vs Arduino across performance, Wi-Fi, Bluetooth, memory, power consumption, and use cases. Learn the key differences to choose the right microcontroller for your next project.