Comprehensive Guide to the Pin Diagram of Raspberry Pi 5: Understanding GPIO Pins and Their Functions

Comprehensive Guide to the Pin Diagram of Raspberry Pi 5: Understanding GPIO Pins and Their Functions

Oct 22, 2024

Raspberry Pi 5 GPIO pin diagram showing physical layout, BCM numbering, power pins, UART, SPI, I2C, and PWM functions

GPIO on Raspberry Pi 5

Raspberry Pi 5 GPIO pins are physical connectors that enable interaction with electronic components like sensors, LEDs, and motors. Understanding the Raspberry Pi GPIO pinout is key to using these connectors effectively.These pins can be programmed to function as either inputs, receiving data from external sources (e.g., sensors), or outputs, sending signals to control external devices (e.g., turning on an LED or activating a motor).

Close-up view of Raspberry Pi 5 GPIO header with 40-pin interface for physical and BCM pin access

Importance

Learning and Experimentation: For educational purposes, learning how to use GPIO pins is fundamental for understanding electronics, programming, and embedded systems, making it a practical tool for STEM education, as demonstrated in our Raspberry Pi Home Automation guide.
Interfacing with Sensors and Actuators: GPIO pins allow the Raspberry Pi to gather input from sensors (e.g., temperature, motion, light) and send commands to actuators (e.g., motors, lights, relays), making it essential for automation, robotics, and IoT applications.
GPIO essentially allows the Raspberry Pi to function as an embedded system, bridging the gap between software and hardware—making it ideal for Raspberry Pi 5 projects and hands-on GPIO tutorials.

Types of GPIO Pins on Raspberry Pi 5

The Raspberry Pi 5 pin diagram reveals a familiar 40-pin layout, continuing the legacy of providing versatile GPIO pins, which allow it to interact with various electronic components. Similar to previous models, the Raspberry Pi 5 uses a 40-pin GPIO header, but with improvements in performance and functionality.

Numbering: Two Schemes Used on Raspberry Pi GPIO Pins

Understanding GPIO pin numbering is essential when working with Raspberry Pi GPIO pins. The Raspberry Pi supports two schemes—BCM vs physical pin layout—each serving different purposes,that can be used to refer to the pins:

Physical Pin Numbering (Board Numbering)
The physical pin numbering refers to the actual location of the pins on the 40-pin header of the Raspberry Pi, counting sequentially from Pin 1 (top left) to Pin 40 (bottom right). This numbering scheme is based purely on the physical layout of the pins.
- Example:
  - Pin 1: 3.3V Power
  - Pin 2: 5V Power
  - Pin 6: Ground (GND)
  - Pin 7: GPIO 4
Physical numbering is useful for wiring components when you’re following a visual guide or schematic, as it reflects the physical position of the pins on the header, which is especially helpful for beginners as shown in our Raspberry Pi OS setup and configuration guide.

BCM (Broadcom SOC Channel) Numbering
BCM numbering refers to the Broadcom chip-specific GPIO numbers assigned to each pin based on the Raspberry Pi's internal SOC (System on Chip). These GPIO numbers correspond to the actual functional channels on the Broadcom processor.
- Example:
  - BCM GPIO 2: Pin 3 (used for I2C SDA).
  - BCM GPIO 3: Pin 5 (used for I2C SCL).
  - BCM GPIO 18: Pin 12 (used for PWM).
BCM numbering is typically used in software when writing scripts or programs in languages like Python (with libraries like `RPi.GPIO` or `gpiozero`). The Raspberry Pi’s internal code and libraries recognize pins by their BCM numbers rather than their physical layout — a method clearly outlined in the official GPIO usage guide.
The two numbering schemes exist to address different needs:
- Physical Pin Numbering: This is simple and intuitive when physically wiring components.
- BCM Numbering: This is more precise for programming, as it reflects the actual hardware configuration and functions tied to specific GPIO channels.
Example to Compare:
  - Pin 3 (Physical): Corresponds to GPIO 2 in BCM numbering.
  - Pin 5 (Physical): Corresponds to GPIO 3 in BCM numbering.

Power Pins
These pins supply power to external devices or circuits connected to the Raspberry Pi.
● 5V Pins (Pin 2 and Pin 4): Provide 5V directly from the Raspberry Pi’s power supply, useful for powering components like relays or higher-power devices.
● 3.3V Pins (Pin 1 and Pin 17): Deliver a regulated 3.3V, suitable for lower-power devices such as sensors.
● Ground (GND) Pins: These pins are essential for completing electrical circuits with external components and are clearly labeled in any Raspberry Pi GPIO guide.

Standard GPIO Pins
● Digital Input/Output: These GPIO functions allow pins to be programmed as either input or output, depending on the task. They can read signals from external devices (input) or send signals to control them (output).
● Example Use: We can read the state of a button (input) or control an LED (output).
GPIO pins on the Raspberry Pi 5 include pins like GPIO 2, GPIO 3, etc., and can be referred to by their BCM numbers or physical pin numbers.

UART Pins (Universal Asynchronous Receiver-Transmitter)
These pins are used for serial communication with other devices like microcontrollers or even other Raspberry Pi boards.
● TXD (Transmit): Pin 8 (BCM GPIO 14).
● RXD (Receive): Pin 10 (BCM GPIO 15).
Ideal for communication between the Raspberry Pi and another device using a serial protocol, such as a GPS module or a wireless communication chip, which are common examples featured in a Raspberry Pi GPIO tutorial.

I2C Pins (Inter-Integrated Circuit)
The I2C protocol on Raspberry Pi 5 GPIO is used for communication with multiple low-speed devices over two shared lines.
● SDA (Data Line): Pin 3 (BCM GPIO 2).
● SCL (Clock Line): Pin 5 (BCM GPIO 3).
Frequently used to connect the Raspberry Pi to sensors like temperature, humidity, or pressure sensors.

SPI Pins (Serial Peripheral Interface)
The Raspberry Pi GPIO pinout includes several SPI pins, which support high-speed communication with displays, sensors, and SD cards.
● MOSI (Master Out Slave In): Pin 19 (BCM GPIO 10).
● MISO (Master In Slave Out): Pin 21 (BCM GPIO 9).
● SCLK (Serial Clock): Pin 23 (BCM GPIO 11).
● CE0 (Chip Enable 0): Pin 24 (BCM GPIO 8).
● CE1 (Chip Enable 1): Pin 26 (BCM GPIO 7).
Commonly used for high-speed data communication with devices like TFT displays or high-speed sensors.

PWM Pins (Pulse Width Modulation)
Pulse Width Modulation (PWM) is a technique used to control the speed of motors or dim LEDs by varying the duty cycle of the signal — a fundamental method explained in the Raspberry Pi documentation on PWM.
● PWM0: Pin 12 (BCM GPIO 18).
● PWM1: Pin 33 (BCM GPIO 13).
These pins are often used to control motor speed, LED brightness, or servos—showcasing the versatility of GPIO functions in robotics.

EEPROM Identification Pin
● ID_SD (Data): Pin 27 (BCM GPIO 0).
● ID_SC (Clock): Pin 28 (BCM GPIO 1).
Among Raspberry Pi 5 GPIO pins, the EEPROM ID pins help identify add-on boards, allowing the Raspberry Pi to automatically configure settings when an accessory board is attached.

Pinout Diagrams on Raspberry Pi 5

To get an overview of the Raspberry Pi GPIO pin layout directly from your Raspberry Pi, we can use the built-in pinout command. This is a simple command-line tool that displays a visual representation of the GPIO pins, their numbers, and functions.
Any Raspberry Pi GPIO guide or Raspberry Pi 5 pin diagram resource will recommend running the following command for onboard reference.
pinout

Raspberry Pi 5 GPIO pinout chart with J8 header, power pins, communication interfaces, and color-coded pin groups including SPI, I2C, UART, and PWM
Terminal-based pinout diagram of Raspberry Pi 5 showing GPIO layout, board specs, and color-coded power and signal pins

We can visit https://pinout.xyz/ and get more information about specific GPIOs.

Safety Precautions When Using GPIO Pins on the Raspberry Pi

GPIO safety starts with avoiding dangerous voltage mismatches. For instance, avoid connecting 5V to 3.3V GPIO pins.
The Raspberry Pi operates with a 3.3V logic level. Connecting a 5V signal to any of the GPIO pins can easily fry the internal circuits of the Raspberry Pi.
Always check the voltage level of the devices or sensors we connect. If needed, use a level shifter to convert 5V signals to 3.3V.
√ Limit Current Through GPIO Pins
The GPIO pins can only handle a limited amount of current (typically around 16mA per pin, with a total limit of 50mA across all GPIO pins).
Always use current-limiting resistors (e.g., 220Ω to 1kΩ) when connecting LEDs or other components to prevent drawing too much current, which could permanently damage the GPIO pins.
√ Beware of Short Circuits
A short circuit occurs when the current takes an unintended path, often bypassing the load (e.g., a resistor or sensor). This can cause excessive current to flow, leading to heat buildup and potential hardware damage — a risk also discussed in our Best Raspberry Pi Music Player Guide with real‑world Raspberry Pi wiring examples.
√ Use Ground Properly
Every circuit needs a common ground (GND) to complete the circuit. Not connecting components to ground or incorrectly connecting the ground can result in malfunctioning circuits or even damage.
√ Avoid Hot-Swapping Components
Plugging and unplugging components while the Raspberry Pi is powered on (hot‑swapping) can cause electrical surges or spikes, which can damage both the GPIO pins and the components — as many Raspberry Pi experts recommend powering down before making or breaking connections.
√ Use a Voltage Divider or Logic Level Converter
When interfacing with devices that operate at higher voltages (e.g., 5V or 12V), we must ensure the Raspberry Pi’s 3.3V GPIO pins aren't exposed to higher voltage.
√ Avoid Drawing Too Much Power from the Raspberry Pi
Why: The Raspberry Pi’s power supply has limits, and drawing too much power from the 5V or 3.3V pins can cause instability, reboots, or damage to the board.

Conclusion

Mastering Raspberry Pi 5 GPIO is essential for project success. With a reliable Raspberry Pi GPIO guide and familiarity with GPIO functions, users can unlock powerful capabilities in automation and IoT. With the proper knowledge of GPIO pin types, numbering systems, and safety precautions, users can confidently connect a wide range of components and expand their Raspberry Pi’s functionality. Whether you're working with sensors, actuators, or communication protocols like UART, I2C, or SPI, mastering GPIO will unlock countless possibilities for automation, IoT, and robotics applications. Always prioritize safety to protect both your Raspberry Pi and the external devices you connect."
This summary reinforces the importance of understanding the GPIO pin diagram while encouraging further exploration.
This summary reinforces the importance of understanding the GPIO pin diagram while encouraging further exploration — for example, by consulting the official Raspberry Pi GPIO documentation.

Raspberry Pi Default Password Guide: New Setup, Changes, and Security Tips Back to News Raspberry Pi Operation System: Complete Guide to Versions, Features, and Setup