logo elektroda
logo elektroda
X
logo elektroda

Raspberry Pi 4 GPIO Pinout Specifications, 40-Pin Header, 3.3V Logic

User question

What are the GPIO pinout specifications for Raspberry Pi 4?

Artificial Intelligence Response

Direct answer to the question

The Raspberry Pi 4 Model B uses the standard 40-pin GPIO header (J8), the same physical layout used on earlier 40-pin Raspberry Pi boards. It exposes:

  • 28 BCM GPIO signals
  • 2 × 5 V pins
  • 2 × 3.3 V pins
  • 8 × GND pins

Key electrical points:

  • GPIO logic level: 3.3 V
  • GPIO pins are not 5 V tolerant
  • Maximum per-pin current: about 16 mA absolute practical limit
  • Recommended design current: keep it lower, typically ≤ 8 mA per pin
  • Total GPIO current budget: commonly treated as about 50 mA across GPIOs

In practice, the Pi 4 pinout is functionally the familiar Raspberry Pi 40-pin layout, with support for:

  • I2C
  • SPI
  • UART
  • PWM
  • PCM/I2S
  • other alternate functions via software configuration

Full 40-pin header pinout

Physical pin Signal Typical/default use Physical pin Signal Typical/default use
1 3V3 3.3 V power 2 5V 5 V power
3 GPIO2 I2C1 SDA 4 5V 5 V power
5 GPIO3 I2C1 SCL 6 GND Ground
7 GPIO4 GPCLK0 / GPIO 8 GPIO14 UART TXD0
9 GND Ground 10 GPIO15 UART RXD0
11 GPIO17 GPIO / alt functions 12 GPIO18 PWM0 / PCM_CLK
13 GPIO27 GPIO / alt functions 14 GND Ground
15 GPIO22 GPIO / alt functions 16 GPIO23 GPIO / alt functions
17 3V3 3.3 V power 18 GPIO24 GPIO / alt functions
19 GPIO10 SPI0 MOSI 20 GND Ground
21 GPIO9 SPI0 MISO 22 GPIO25 GPIO / alt functions
23 GPIO11 SPI0 SCLK 24 GPIO8 SPI0 CE0
25 GND Ground 26 GPIO7 SPI0 CE1
27 GPIO0 ID_SD / HAT EEPROM 28 GPIO1 ID_SC / HAT EEPROM
29 GPIO5 GPIO / alt functions 30 GND Ground
31 GPIO6 GPIO / alt functions 32 GPIO12 PWM0
33 GPIO13 PWM1 34 GND Ground
35 GPIO19 PCM_FS / PWM1 / alt SPI 36 GPIO16 GPIO / alt functions
37 GPIO26 GPIO / alt functions 38 GPIO20 PCM_DIN / alt SPI
39 GND Ground 40 GPIO21 PCM_DOUT / alt SPI

Key points

  • Physical numbering: 1 to 40 on the header
  • BCM numbering: GPIO2, GPIO14, etc.; this is what software usually uses
  • Pins 27 and 28 are usually reserved for HAT EEPROM identification
  • Pins 3 and 5 are the primary I2C bus
  • Pins 8 and 10 are the main UART
  • Pins 19, 21, 23, 24, 26 are the standard SPI0 interface

Detailed problem analysis

The Raspberry Pi 4 GPIO interface is simple mechanically, but electrically it must be treated as a 3.3 V digital interface with limited current capability. This is the most important engineering point.

1. Physical header architecture

The Pi 4 uses a 2 × 20, 0.1-inch pitch header. This is valuable because it maintains compatibility with:

  • existing Raspberry Pi HATs
  • breadboard adapters
  • prior Raspberry Pi 40-pin accessories
  • most software examples written for Pi 2/3/4

Although people often say “40 GPIO pins,” that is not accurate. The header has 40 physical pins, but only 28 are connected to BCM2711 GPIO signals. Of those, GPIO0 and GPIO1 are typically reserved for HAT identification, so in many user projects you effectively treat the board as having 26 freely usable GPIOs.

2. Electrical behavior

3.3 V logic only

All GPIO pins operate at 3.3 V logic levels. This means:

  • output high is approximately 3.3 V
  • output low is approximately 0 V
  • input signals should also remain within the 3.3 V domain

A direct 5 V input to a GPIO can permanently damage the BCM2711 SoC. This is the main failure mode seen in hobby and lab use.

Current capability

A GPIO pin is intended to drive logic inputs or very light loads, not power devices.

Practical design rules:

  • Absolute practical upper limit per pin: about 16 mA
  • Better engineering practice: keep below 8 mA per pin
  • Total current across GPIOs: commonly kept around 50 mA maximum

Therefore:

  • LEDs should use resistors and modest current
  • relays, motors, solenoids, and high-power LEDs require
    • a transistor or MOSFET
    • a proper driver IC
    • flyback protection for inductive loads

3. Power pins

The header includes:

  • 5 V on pins 2 and 4
  • 3.3 V on pins 1 and 17
  • GND on pins 6, 9, 14, 20, 25, 30, 34, 39

Important engineering distinction:

  • The 5 V pins are effectively tied to the board’s 5 V input rail
  • The 3.3 V pins come from the onboard 3.3 V regulator

This means the 5 V pins can be used to power some peripherals, but you must account for total system current and supply quality. The 3.3 V rail is more limited and should be used conservatively for external circuitry.

4. Main serial interfaces on the header

I2C

Primary I2C bus:

  • GPIO2: SDA1, pin 3
  • GPIO3: SCL1, pin 5

These are the standard pins for I2C sensors, RTCs, ADCs, DACs, and GPIO expanders.

SPI

Primary SPI bus (SPI0):

  • GPIO10: MOSI, pin 19
  • GPIO9: MISO, pin 21
  • GPIO11: SCLK, pin 23
  • GPIO8: CE0, pin 24
  • GPIO7: CE1, pin 26

This is the preferred interface for fast ADCs, displays, shift registers, and other synchronous peripherals.

UART

Primary UART pins:

  • GPIO14: TXD0, pin 8
  • GPIO15: RXD0, pin 10

Useful for:

  • serial console
  • GPS modules
  • microcontroller communication
  • debug ports

Be aware that UART assignment can vary with software configuration, especially when Bluetooth serial functions are involved.

PWM

Common hardware PWM-capable pins include:

  • GPIO12: pin 32
  • GPIO13: pin 33
  • GPIO18: pin 12
  • GPIO19: pin 35

These are the best choices for:

  • servo timing
  • motor speed control through driver stages
  • dimming LEDs without CPU-timing jitter

5. Special-purpose pins

Pins 27 and 28 correspond to:

  • GPIO0 = ID_SD
  • GPIO1 = ID_SC

These are primarily intended for the HAT ID EEPROM interface. In a general-purpose prototype you can repurpose them, but if you are designing a proper HAT or want guaranteed compatibility, they should be treated as reserved.

6. Numbering conventions

This is a common source of mistakes.

Physical numbering

This refers to the pin’s position on the header:

  • pin 1, pin 2, pin 3, etc.

BCM numbering

This refers to the SoC GPIO name:

  • GPIO2, GPIO17, GPIO18, etc.

Software libraries often use BCM numbering, not physical numbering. Mixing these up is one of the most common wiring/debugging problems.

7. Alternate functions and Pi 4 capability

The Pi 4’s BCM2711 supports much more than simple input/output. A single GPIO can often be configured for different internal peripheral functions:

  • I2C
  • SPI
  • UART
  • PWM
  • PCM/I2S
  • clock outputs
  • additional mapped buses through overlays

From an engineering perspective, the important point is:

  • the header pinout is fixed
  • the electrical role of many GPIOs is software-selectable

So the same physical pin can serve as a plain digital output in one project and as part of a serial bus in another.


Current information and trends

Although the Raspberry Pi 4 is no longer the newest Raspberry Pi generation, its GPIO header remains one of the most widely used embedded Linux I/O interfaces because:

  • it is backward compatible
  • it has a very mature ecosystem of HATs and breakout boards
  • libraries and examples remain abundant
  • the 40-pin format has become a practical de facto standard in the Pi ecosystem

Current practical trends include:

  • using device tree overlays to enable alternate buses
  • using hardware PWM instead of software bit-banging where timing matters
  • using I2C GPIO expanders when many low-speed inputs/outputs are required
  • using level shifters whenever 5 V or mixed-voltage systems are involved
  • checking live configuration on the Pi with the pinout utility, and in lower-level troubleshooting with tools such as raspi-gpio or pinctrl depending on software environment

Supporting explanations and details

Typical pin usage recommendations

Use case Preferred pins Notes
I2C sensors Pins 3, 5 Shared bus, easy expansion
SPI display/ADC Pins 19, 21, 23, 24, 26 Higher speed than I2C
Serial debug/GPS Pins 8, 10 UART
PWM output Pins 12, 32, 33, 35 Better timing stability
Simple digital inputs Any free GPIO except reserved pins Use pull-up/down
HAT compatibility Avoid pins 27, 28 Reserved for ID EEPROM

Example: driving an LED

A GPIO pin should not directly dump excessive current into an LED. Use:

  • GPIO output
  • series resistor, typically 330 Ω to 1 kΩ
  • LED to GND or 3.3 V depending on source/sink arrangement

Example: interfacing a 5 V sensor

If a sensor outputs 5 V logic:

  • do not connect it directly to a Pi GPIO
  • use:
    • a resistor divider for one-way digital signals
    • a proper logic-level shifter for bidirectional buses like I2C
    • a transistor or comparator if signal conditioning is needed

Internal pull resistors

GPIO pins support software-configurable pull-up and pull-down resistors. These are useful for:

  • push-buttons
  • open-drain outputs
  • preventing floating inputs

A floating input may randomly read 0 or 1, so enabling internal pulls is standard practice.


Ethical and legal aspects

For GPIO work, the main ethical and legal concerns are really safety and compliance, not policy.

  • Do not connect GPIO directly to mains voltage
  • Use proper isolation when interfacing to industrial, automotive, or hazardous systems
  • If designing commercial HATs or products, follow:
    • electrical safety requirements
    • EMC/EMI good practice
    • connector orientation and HAT EEPROM conventions
  • Protect users and hardware from foreseeable misuse with:
    • current limiting
    • reverse-polarity protection
    • transient suppression
    • isolation where appropriate

Practical guidelines

Best practices

  • Treat every GPIO as 3.3 V only
  • Keep current low
  • Always share a common ground with external logic
  • Use external drivers for loads
  • Reserve GPIO0/GPIO1 if HAT compatibility matters
  • Prefer standard bus pins for I2C/SPI/UART unless you have a reason to remap
  • Verify numbering before wiring: BCM vs physical

Common mistakes

  • Confusing pin 8 with GPIO8
  • Applying 5 V directly to GPIO
  • Forgetting ground reference
  • Driving relays or motors directly from the pin
  • Using pins 27/28 casually in a HAT-based design

How to verify configuration

On the Pi itself, use:

  • pinout for a quick human-readable map
  • lower-level GPIO inspection tools if you need to verify current mode and state

Possible disclaimers or additional notes

  • The physical pinout of the Raspberry Pi 4 is stable and well established.
  • However, software default functions can vary depending on OS configuration, overlays, and serial/Bluetooth settings.
  • Some community references differ on exact threshold voltages or available current from the 3.3 V rail. From an engineering standpoint, you should not design near the limits anyway.
  • If you need guaranteed timing, signal integrity, or current drive, use dedicated interface hardware rather than relying on GPIO directly.

Suggestions for further research

If you want to go beyond the basic pinout, the next useful topics are:

  • BCM2711 alternate-function mapping
  • Device tree overlays
  • Raspberry Pi HAT design guidelines
  • Level shifting techniques for 5 V interfacing
  • Safe GPIO driver design using MOSFETs and transistor arrays
  • I2C bus design, including pull-up sizing and bus capacitance
  • PWM and servo/motor control using hardware timers

A useful practical next step is to decide your target peripheral:

  • LED / button
  • I2C sensor
  • SPI ADC/DAC
  • UART module
  • motor/relay driver

Then choose pins and protection circuitry accordingly.


Brief summary

The Raspberry Pi 4 provides a 40-pin, backwards-compatible GPIO header with 28 BCM GPIO signals, 2 power rails at 5 V, 2 power rails at 3.3 V, and 8 ground pins. The most important specification is that the GPIO interface is 3.3 V only and not 5 V tolerant. Standard bus pins are:

  • I2C: pins 3 and 5
  • UART: pins 8 and 10
  • SPI0: pins 19, 21, 23, 24, 26
  • PWM-capable pins: 12, 32, 33, 35

From an engineering standpoint, use the header as a low-voltage logic interface, not as a power driver. If you want, I can also provide:

  1. a color-coded GPIO diagram,
  2. a BCM-to-physical pin cheat sheet, or
  3. safe wiring examples for LEDs, buttons, I2C modules, relays, or 5 V sensors.

Ask additional question

Wait...(2min)
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.