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.
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.
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.
Function | Name | Pin no. | Pin no. | Name | Function |
DC power | 3.3 V | 1 | 2 | 5 V | DC power |
I2C (SDA) | GPIO 2 | 3 | 4 | 5 V | DC power |
I2C (SCL) | GPIO 3 | 5 | 6 | GND | |
GPCLK0 | GPIO 4 | 7 | 8 | GPIO 14 | UART (TXD0) |
GND | 9 | 10 | GPIO 15 | UART (RXD0) | |
GPIO 17 | 11 | 12 | GPIO 18 | PCM CLK (I2S) | |
GPIO 27 | 13 | 14 | GND | ||
GPIO 22 | 15 | 16 | GPIO 23 | ||
DC power | 3.3 V | 17 | 18 | GPIO 24 | |
SPI (MOSI) | GPIO 10 | 19 | 20 | GND | |
SPI (MISO) | GPIO 9 | 21 | 22 | GPIO 25 | |
SPI (CLK) | GPIO 11 | 23 | 24 | GPIO 8 | SPI (CE0) |
GND | 25 | 26 | GPIO 7 | SPI (CE1) | |
I2C EEPROM | GPIO 0 | 27 | 28 | GPIO 1 | I2C EEPROM |
GPIO 5 | 29 | 30 | GND | ||
GPIO 6 | 31 | 32 | GPIO 12 | PWM0 | |
PWM1 | GPIO 13 | 33 | 34 | GND | |
PCM FS (I2S) | GPIO 19 | 35 | 36 | GPIO 16 | |
GPIO 26 | 37 | 38 | GPIO 20 | PCM DIN (I2S) | |
GND | 39 | 40 | GPIO 21 | PCM 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.