Guide to Raspberry Pi Pinout: Utilizing the GPIO s on the Raspberry Pi

Introduction to Guide to Raspberry Pi Pinout:

Welcome to the comprehensive guide on Raspberry Pi Pinout. The Raspberry Pi’s General Purpose Input/Output (GPIO) pins play a pivotal role in extending the functionality of this powerful single-board computer. This guide aims to provide a detailed exploration of the Raspberry Pi pinout, unraveling the capabilities and configurations of each pin, including essential interfaces such as I2C, SPI, PWM, UART, and more. Whether you’re a beginner exploring the world of Raspberry Pi or an experienced enthusiast seeking to leverage its GPIO features, this guide is your go-to resource for understanding and utilizing the full potential of Raspberry Pi pinouts.

The Raspberry Pi 4 Model B, along with the latest iterations, features a dual row of 40 GPIOs (General Purpose Input/Output Pins), facilitating connections with electronic components such as LEDs and sensors. Specific pins serve distinct functions, including power supply, I2C, SPI, UART communication protocols, and PWM. This guide delves into the Raspberry Pi GPIOs, examining their roles and functionalities.

Gpio

Presenting the Raspberry Pi General Purpose Input/Output Pins (GPIOs).

The Raspberry Pi 4 Model B board is equipped with a dual row of 40 GPIO pins, maintaining consistency with the layout of the Pi 3 Model B and B+, Pi 2 Model B and B+, and Pi 1 Model B+. However, it differs from the layout of the Pi 1 Model A and B, featuring only the initial 26 pins.

Guide to Raspberry Pi Pinout: Utilizing the GPIO s on the Raspberry Pi image 24

Explore the Raspberry Pi Pinout (click on the image for a larger view).

A GPIO pin can be referenced in various ways: by its name (referred to as GPIO numbering or Broadcom numbering) or by its associated physical pin number (indicating the pin’s actual position on the header). For instance, GPIO 18 is linked to pin 12.

Guide to Raspberry Pi Pinout

The table below illustrates the Raspberry Pi pinout, presenting GPIOs, their associated physical pin numbers, Broadcom numbering, and respective 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)

Please be aware that the Raspberry Pi 1 Model B Rev. 1, being the inaugural Raspberry Pi board, possesses a slightly distinct pinout compared to all subsequent models. This pinout is not applicable to that specific board.

Interface for Raspberry Pi Peripherals

The Raspberry Pi GPIOs offer the following options for peripheral interfaces:

  • 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 lacks an analog-to-digital converter (ADC) interface for reading analog sensors. Yet, you can employ an external ADC, such as the MCP3008, to interpret analog signals alongside the Raspberry Pi.

Note: Raspberry Pi GPIOs are compatible with voltages up to 3.3V. Connecting higher voltages may cause permanent damage to your Raspberry Pi.

Power Supply Pins on Raspberry Pi

The Raspberry Pi is equipped with two 3.3V pins (located at pins 1 and 17) and two 5V pins (at pins 2 and 4). Additionally, there are eight GND pins, specifically at pins 6, 9, 14, 20, 25, 30, 34, and 39.

Digital Inputs and Outputs on the Raspberry Pi

Among the 40 GPIO pins on the Raspberry Pi, 11 serve as power or GND pins. Furthermore, two pins (27 and 28) are reserved for I2C communication with an EEPROM (find more information about this). This leaves us with 16 GPIOs available for connecting peripherals, configurable as either inputs or outputs. Additionally, some of them support specific communication protocols.

I2C Pins on Raspberry Pi

I²C, or Inter-Integrated Circuit, is a synchronous, multi-master, multi-slave communication protocol facilitating communication with other microcontroller devices, sensors, or displays. Multiple I2C devices can be connected to the same pins, provided they have unique I2C addresses.

On the Raspberry Pi, the I2C pins are as follows:

  • SDA: GPIO 2
  • SCL: GPIO 3

To utilize I2C, it’s necessary to enable the I2C communication interface beforehand.

SPI Pins on Raspberry Pi

SPI, short for Serial Peripheral Interface, is a synchronous serial data protocol employed by microcontrollers for communication with one or more peripherals. This protocol enables the connection of multiple peripherals to the same bus interface, provided each is linked to a distinct chip select pin.

Your Raspberry Pi board can communicate with various devices, such as a sensor, another Raspberry Pi, or a different microcontroller board, utilizing the SPI protocol. The designated Raspberry Pi SPI pins are as follows:

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

Serial (UART) Pins on Raspberry Pi

The UART pins facilitate serial communication. On the Raspberry Pi, the Serial (UART) pins are designated as follows:

Raspberry Pi PWM Pins

PWM, or Pulse Width Modulation, is employed for motor control, establishing different levels of LED brightness, determining RGB LED colors, and various other applications.

The Raspberry Pi is equipped with 4 hardware PWM pins: GPIO 12, GPIO 13, GPIO 18, GPIO 19.

Software PWM can be implemented on all pins.

Explore how to generate PWM signals using the Raspberry Pi:

Raspberry Pi: PWM Outputs with Python (Fading LED)

ADC Pins on Raspberry Pi

The Raspberry Pi lacks dedicated ADC pins, meaning it does not feature an integrated analog-to-digital converter. To read analog signals, an external analog-to-digital converter, such as the MCP3008 chip, is required.

Reading analog signals proves useful for interpreting varying voltage levels from components like potentiometers or sensors.

Explore the tutorial on reading analog inputs with the Raspberry Pi:

Raspberry Pi: Read Analog Inputs with Python (MCP3008)

One-Wire Pins on Raspberry Pi

All GPIOs on the Raspberry Pi can accommodate one-wire, with GPIO4 being the default setting.

PCM Pins on Raspberry Pi

The Raspberry Pi is equipped with PCM (Pulse-Code Modulation) pins dedicated to digital audio output. These constitute the PCM pins:

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

I2C Electrically Erasable Programmable Read-Only Memory (EEPROM)

Pins 27 and 28 (GPIO 0 and GPIO 1) are designated for connecting an HAT ID EEPROM. Utilize these pins exclusively when employing an I2C ID EEPROM. If not using an I2C EEPROM, leave them unconnected.

Conclusion

As we conclude, it’s evident that the Raspberry Pi offers a versatile range of GPIO pins, each serving specific functions for interfacing with various peripherals and enabling diverse applications. Whether it’s I2C, SPI, PWM, UART, or PCM, understanding the capabilities and configurations of these GPIO pins is crucial for effective project implementation. Additionally, considerations like power supply, analog-to-digital conversion, and reserved pins for specific functionalities further enhance the utility of the Raspberry Pi GPIOs. This exploration of GPIO features equips users with the knowledge needed to harness the full potential of the Raspberry Pi in their projects.