Artificial Intelligence Response
Direct answer to the question
The Raspberry Pi Zero 2 W uses the standard 40-pin Raspberry Pi header. Physically and functionally, it is the same header layout used on most full-size Raspberry Pi boards.
- 40 physical pins total
- 28 BCM GPIO signals exposed
- 26 are normally treated as user GPIO
- 2 pins are usually reserved for HAT EEPROM identification:
- GPIO0 / pin 27
- GPIO1 / pin 28
- Also includes:
- 2 × 5 V pins
- 2 × 3.3 V pins
- 8 × GND pins
Important: the Pi Zero 2 W header is usually not pre-soldered.
Detailed problem analysis
The most useful way to answer this is to show the physical pin number, the BCM GPIO number, and the main default/alternate function.
Full 40-pin GPIO header pinout
| Physical pin |
Signal |
Main function |
| 1 |
3V3 |
3.3 V power |
| 2 |
5V |
5 V power |
| 3 |
GPIO2 |
I2C SDA1 |
| 4 |
5V |
5 V power |
| 5 |
GPIO3 |
I2C SCL1 |
| 6 |
GND |
Ground |
| 7 |
GPIO4 |
GPIO / GPCLK0 |
| 8 |
GPIO14 |
UART TXD |
| 9 |
GND |
Ground |
| 10 |
GPIO15 |
UART RXD |
| 11 |
GPIO17 |
GPIO |
| 12 |
GPIO18 |
PWM / PCM_CLK |
| 13 |
GPIO27 |
GPIO |
| 14 |
GND |
Ground |
| 15 |
GPIO22 |
GPIO |
| 16 |
GPIO23 |
GPIO |
| 17 |
3V3 |
3.3 V power |
| 18 |
GPIO24 |
GPIO |
| 19 |
GPIO10 |
SPI0 MOSI |
| 20 |
GND |
Ground |
| 21 |
GPIO9 |
SPI0 MISO |
| 22 |
GPIO25 |
GPIO |
| 23 |
GPIO11 |
SPI0 SCLK |
| 24 |
GPIO8 |
SPI0 CE0 |
| 25 |
GND |
Ground |
| 26 |
GPIO7 |
SPI0 CE1 |
| 27 |
GPIO0 |
ID_SD, usually reserved |
| 28 |
GPIO1 |
ID_SC, usually reserved |
| 29 |
GPIO5 |
GPIO |
| 30 |
GND |
Ground |
| 31 |
GPIO6 |
GPIO |
| 32 |
GPIO12 |
PWM0 |
| 33 |
GPIO13 |
PWM1 |
| 34 |
GND |
Ground |
| 35 |
GPIO19 |
PWM / PCM_FS |
| 36 |
GPIO16 |
GPIO |
| 37 |
GPIO26 |
GPIO |
| 38 |
GPIO20 |
PCM_DIN |
| 39 |
GND |
Ground |
| 40 |
GPIO21 |
PCM_DOUT |
Functional grouping
Power pins
- 3.3 V: pins 1, 17
- 5 V: pins 2, 4
- Ground: pins 6, 9, 14, 20, 25, 30, 34, 39
Main digital GPIO pins
Commonly used general-purpose pins include:
- GPIO4, 17, 27, 22, 23, 24, 25
- GPIO5, 6, 12, 13, 16, 18, 19, 20, 21, 26
- GPIO7, 8, 9, 10, 11, 14, 15
- GPIO2 and GPIO3 can also be used, though they are commonly dedicated to I2C
I2C
- GPIO2 / pin 3 = SDA1
- GPIO3 / pin 5 = SCL1
These are the standard I2C pins used by many sensors and HATs.
SPI0
- GPIO10 / pin 19 = MOSI
- GPIO9 / pin 21 = MISO
- GPIO11 / pin 23 = SCLK
- GPIO8 / pin 24 = CE0
- GPIO7 / pin 26 = CE1
Useful for ADCs, displays, DACs, and high-speed peripherals.
UART
- GPIO14 / pin 8 = TX
- GPIO15 / pin 10 = RX
Used for serial consoles, GPS modules, microcontrollers, and debug links.
PWM
Hardware PWM is typically available on:
- GPIO12 / pin 32
- GPIO13 / pin 33
- GPIO18 / pin 12
- GPIO19 / pin 35
Useful for dimming LEDs, generating pulse trains, and servo-related work.
PCM / I2S digital audio
- GPIO18 / pin 12 = PCM_CLK
- GPIO19 / pin 35 = PCM_FS
- GPIO20 / pin 38 = PCM_DIN
- GPIO21 / pin 40 = PCM_DOUT
Used for digital audio codecs, DACs, and microphones.
Reserved HAT ID pins
- GPIO0 / pin 27 = ID_SD
- GPIO1 / pin 28 = ID_SC
These are normally reserved for HAT EEPROM identification. You can technically repurpose them in some projects, but for standard designs it is better to leave them alone.
GPIO numbering: physical vs BCM
This is a common source of confusion.
- Physical numbering: the actual pin position on the header, 1 to 40
- BCM numbering: the Broadcom GPIO number used in software
Example:
- Physical pin 11
- BCM pin GPIO17
So if code says GPIO17, that does not mean physical pin 17.
Current information and trends
For practical engineering use, the key fact is that the Pi Zero 2 W uses the same 40-pin GPIO arrangement as the Pi 3/4 family, so most existing Raspberry Pi pinout diagrams, HATs, and expansion boards are compatible at the header level.
Current common practice is:
- Use I2C on pins 3/5 for sensors
- Use SPI on pins 19/21/23/24/26 for ADCs and displays
- Use UART on pins 8/10 for debugging or external controllers
- Use GPIO Zero, RPi.GPIO, or newer Linux GPIO interfaces depending on software stack
- Prefer device-tree-enabled interfaces rather than bit-banged GPIO when reliable timing matters
A practical trend in recent Raspberry Pi software is moving toward more modern GPIO control methods in Linux, rather than relying only on older legacy libraries.
Supporting explanations and details
Electrical rules you must respect
1. GPIO is 3.3 V only
This is the most important rule.
- GPIO pins are not 5 V tolerant
- Applying 5 V directly to a GPIO input can permanently damage the SoC
If you need to connect a 5 V device:
- use a logic level shifter, or
- use a resistor divider for simple one-way signals
2. GPIO current is limited
A Raspberry Pi GPIO pin is for logic signaling, not for powering loads.
Typical design guidance:
- keep current per GPIO modest
- do not drive motors, relays, or power LEDs directly without a transistor or driver stage
3. No built-in ADC
The Pi Zero 2 W cannot directly read analog voltages.
If you need analog input:
- use an external ADC such as MCP3008 over SPI
- or use an I2C ADC module
Practical example
If you want to connect:
- a BME280 sensor: use I2C on pins 3 and 5
- an SPI display: use pins 19, 21, 23, 24, plus a spare GPIO for reset/DC if required
- a USB-to-TTL serial adapter: use pin 8 TX, pin 10 RX, and GND
- a PWM LED dimmer: use pin 12, 32, 33, or 35
Mechanical detail
On the Zero 2 W, the 40-pin footprint is usually present but unsoldered. You need to add:
- a standard 2×20 male header,
- a right-angle header,
- or direct wires,
depending on your enclosure and project constraints.
Ethical and legal aspects
For GPIO use, the main issues are not ethical in the usual sense, but rather safety, reliability, and compliance.
- Avoid unsafe wiring that could create short circuits or overheating
- If interfacing with external power systems, use proper isolation where required
- If your GPIO-connected project controls mains, motors, heaters, or actuators, observe applicable electrical safety regulations
- For products rather than hobby projects, consider EMC, ESD robustness, and regulatory compliance
Practical guidelines
Best practices
- Use BCM numbering consistently in software unless you intentionally choose BOARD numbering
- Double-check pin orientation before powering the board
- Use a common ground between the Pi and external logic
- Add series resistors or buffering where appropriate
- Use transistor or MOSFET drivers for relays, solenoids, motors, and high-current LEDs
- Keep SPI and fast digital lines short if signal integrity matters
- Use pull-ups/pull-downs intentionally; do not leave critical inputs floating
Common mistakes
- Confusing GPIO17 with physical pin 17
- Applying 5 V to a GPIO
- Using pins 27/28 as normal GPIO in HAT-style designs
- Assuming analog input exists on the board
- Powering external loads from GPIO pins
How to verify on the Pi
Useful tools:
pinout for a quick terminal pin map
- GPIO libraries such as
gpiozero or RPi.GPIO
- Linux pin-control tools for advanced inspection
Possible disclaimers or additional notes
- The header layout is standardized, but actual pin function can change by software configuration because many pins are multiplexed.
- Some interfaces such as UART may be affected by OS configuration, serial console settings, or overlays.
- GPIO0 and GPIO1 are not strictly unusable, but they are best treated as reserved unless you have a reason to override standard HAT behavior.
- Available external current from the power rails depends on the total board supply and system load, so it should not be assumed without margin analysis.
Suggestions for further research
If you want to go deeper, the next useful topics are:
- How to use I2C/SPI/UART on the Pi Zero 2 W
- BCM numbering vs BOARD numbering in Python
- How to safely interface 5 V sensors
- Using external ADCs with Raspberry Pi
- Using PWM for motors, LEDs, or servos
- Linux device tree overlays for enabling hardware interfaces
A good next step is to decide what you want to connect:
- sensor
- display
- relay board
- MCU
- serial peripheral
- audio interface
Then the pin choice becomes straightforward.
Brief summary
The Raspberry Pi Zero 2 W has the standard 40-pin Raspberry Pi header.
- 28 GPIO-labeled signals are exposed
- 26 are normally used as general GPIO
- GPIO0 and GPIO1 are usually reserved for HAT ID
- Standard interfaces are available:
- I2C: pins 3, 5
- UART: pins 8, 10
- SPI: pins 19, 21, 23, 24, 26
- PWM: pins 12, 32, 33, 35
- All GPIO uses 3.3 V logic only
If you want, I can also give you:
- a clean GPIO pinout diagram, or
- a “which pins should I use for my project?” table.