Popup

Wait! Don’t Go Yet! 👋

Become a Member Today and Unlock Access to All eBooks! 😍

Thousands of eBooks at your fingertips. Read, learn, and grow anytime, anywhere ✨

Raspberry Pi Pinout Guide: How to use the Raspberry Pi GPIOs?

The Raspberry Pi 4 Model B and most recent versions of the Raspberry Pi have a double row of 40 GPIOs (General Purpose Input/Output Pins) that allow you to connect electronic components like LEDs and sensors. Some pins have specific functions like providing power, I2C, SPI, and UART communication protocols, or PWM. In this guide, we’ll take a look at the Raspberry Pi GPIOs and their functions.

Introducing the Raspberry Pi GPIOs

The Raspberry Pi 4 Model B board has a double row of 40 GPIO pins. This layout is the same for the Pi 3 Model B and B+, Pi 2 Model B and B+, and Pi 1 Model B+, but slightly different from the Pi 1 Model A and B, which only have the first 26 pins. 

Raspberry Pi Pinout Reference Guide

There are several ways to refer to a GPIO pin: its name (which is known as GPIO numbering or Broadcom numbering) or its corresponding pin physical number (which corresponds to the pin’s physical location on the header). For example, GPIO 18 corresponds to pin 12.

Raspberry Pi Pinout Guide

The following table shows the Raspberry Pi pinout, it shows all GPIOs, their corresponding physical pin numbers, their Broadcom numbering, and corresponding features.

FunctionNamePin no.Pin no.NameFunction
DC power3.3 V125 VDC power
I2C (SDA)GPIO 2345 VDC power
I2C (SCL)GPIO 356GND
GPCLK0GPIO 478GPIO 14UART (TXD0)
GND910GPIO 15UART (RXD0)
GPIO 171112GPIO 18PCM CLK (I2S)
GPIO 271314GND
GPIO 221516GPIO 23
DC power3.3 V1718GPIO 24
SPI (MOSI)GPIO 101920GND
SPI (MISO)GPIO 92122GPIO 25
SPI (CLK)GPIO 112324GPIO 8SPI (CE0)
GND2526GPIO 7SPI (CE1)
I2C EEPROMGPIO 02728GPIO 1I2C EEPROM
GPIO 52930GND
GPIO 63132GPIO 12PWM0
PWM1GPIO 133334GND
PCM FS (I2S)GPIO 193536GPIO 16
GPIO 263738GPIO 20PCM DIN (I2S)
GND3940GPIO 21PCM Dout (I2S)

Top 6

Raspberry Pi eBooks

From Zero to Professional

Raspberry Pi Projects

Note: the Raspberry Pi 1 Model B Rev. 1 was the very first Raspberry Pi board released and has a slightly different pinout from all the other boards. This pinout doesn’t apply to that board.

Raspberry Pi Peripherals Interface

The Raspberry Pi GPIOs provide the following peripheral interface options:

  • 3.3V (on 2 pins)
  • 5V (on 2 pins)
  • Ground (on 8 pins)
  • General purpose input and output
  • PWM (pulse width modulation)
  • I2C
  • PCM
  • SPI
  • Serial (UART)

The Raspberry Pi doesn’t have an analog-to-digital converter (ADC) interface to read analog sensors. However, you can use an external analog-to-digital converter like the MCP3008 to read analog signals with the Raspberry Pi.

Raspberry Pi Power Pins

The Raspberry Pi comes with two 3.3V pins (pins number 1 and 17) and two 5V pins (pins 2 and 4).

Additionally, there are eight GND pins (pins number: 6, 9, 14, 20, 25, 30, 34, and 39).

Raspberry Pi Digital Inputs and Outputs

Out of the 40 Raspberry Pi GPIOs, 11 are power or GND pins. Besides that, there are two reserved pins (pins 27 and 28) for I2C communication with an EEPROM (learn more about this). So, this left us with 16 GPIOs that you can use to connect peripherals. These GPIOs can be used either as inputs or outputs. Additionally, some of them support specific communication protocols.

Learn more about digital inputs and outputs with the Raspberry Pi:

Raspberry Pi I2C Pins

I²C means Inter-Integrated Circuit, and it is a synchronous, multi-master, multi-slave communication protocol. It allows you to establish communication with other microcontroller devices, sensors, or displays, for example. You can connect multiple I2C devices to the same pins as long as they have a unique I2C address.

The Raspberry Pi I2C pins are GPIO 2 and GPIO 3:

  • SDA: GPIO 2
  • SCL: GPIO 3

If you want to use I2C, you need to enable the I2C communication interface first.

Raspberry Pi SPI Pins

SPI stands for Serial Peripheral Interface, and it is a synchronous serial data protocol used by microcontrollers to communicate with one or more peripherals. This communication protocol allows you to connect multiple peripherals to the same bus interface, as long as each is connected to a different chip select pin.

For example, your Raspberry Pi board can communicate with a sensor that supports SPI, another Raspberry Pi, or a different microcontroller board. These are the Raspberry Pi SPI pins:

  • MOSI: GPIO 10
  • MISO: GPIO 9
  • CLOCK: GPIO 11
  • CE0 (chip select): GPIO 8
  • CE1 (chip select): GPIO 7

Raspberry Pi Serial (UART) Pins

The UART pins can be used for Serial communication. The Raspberry Pi Serial (UART) pins are:

  • TX: GPIO 14
  • RX: GPIO 15

Raspberry Pi PWM Pins

PWM stands for Pulse Width Modulation, and it is used to control motors, define varying levels of LED brightness, define the color of RGB LEDs, and much more.

The Raspberry Pi has 4 hardware PWM pins: GPIO 12GPIO 13GPIO 18, and GPIO 19.

You can have software PWM on all pins.

Learn how to generate PWM signals with the Raspberry Pi:

Raspberry Pi ADC Pins

The Raspberry Pi doesn’t have any ADC pins—it doesn’t include an analog-to-digital converter. So, you need to convert the analog signal to a digital signal using an analog-to-digital converter like the MCP3008 chip.

Being able to read analog signals is useful to read varying voltage levels from a potentiometer or sensors, for example.

Learn how to read analog signals with the Raspberry Pi with the following tutorial:

Raspberry Pi One-Wire Pins

The Raspberry Pi supports one-wire on all GPIOs, but the default is GPIO4.

Raspberry Pi PCM Pins

The Raspberry Pi comes with PCM (pulse-code Modulation) pins for digital audio output. These are the PCM pins:

  • Din: GPIO 20
  • Dout: GPIO 21
  • FS: GPIO 19
  • CLK: GPIO 18

I2C EEPROM

Pins 27 and 28 (GPIO 0 and GPIO 1) are reserved for connecting a HAT ID EEPROM. Do not use these pins unless you’re using an I2C ID EEPROM. Leave unconnected if you’re not using an I2C EEPROM.

Wrapping Up

We hope you’ve found this guide about the Raspberry Pi GPIOs useful.

One of the easiest ways to control the Raspberry Pi GPIOs is using Python and the gpiozero library. We’ll create some tutorials about how to use the GPIOs soon. So, stay tuned.

You may also like:

You can check all our Raspberry Pi projects on the following link:

Thanks for reading.

Share your love

🚀 Discover the world of electronics and innovation!

✨ Create, program, and experiment with all your creative ideas with ease.

Spotpear

Leave a Reply

Your email address will not be published. Required fields are marked *

Secure Payments
Securing online payments is a shared responsibility, and everyone can contribute.
Free Shipping
You get unlimited free shipping on eligible items with Ebokify, with no minimum spend.
24/7 Support
Sales gifts are helpful tools often used to show appreciation to clients for their purchase.
Gifts & Sales
Our customer care service is offered in the form of 1st or 2nd level support.