The Raspberry Pi Zero W uses the standard 40-pin (2x20) GPIO header, identical in layout to the Pi 3 and Pi 4. However, because the Zero W often ships with unpopulated through-holes and shares its UART with the onboard Bluetooth module, wiring it requires specific attention to BCM (Broadcom) numbering and peripheral conflicts. Below is the exact reference data you need to wire sensors, HATs, and custom circuits without frying the BCM2835 SoC.
The Complete Raspberry Pi Zero W 40-Pin Header Table
This table maps the physical pin number (counting from top-left to bottom-right, with the board oriented so the GPIO header is on the right) to the Broadcom (BCM) GPIO number used in Python/C code. Always use the BCM numbering in your software.
| Phys | BCM | Function / Notes | Phys | BCM | Function / Notes |
|---|---|---|---|---|---|
| 1 | - | 3.3V Power (Max 50mA draw) | 2 | - | 5V Power (Input/Output) |
| 3 | 2 | SDA1 (I2C) / 1.8k Pull-up | 4 | - | 5V Power |
| 5 | 3 | SCL1 (I2C) / 1.8k Pull-up | 6 | - | Ground (GND) |
| 7 | 4 | GPIO4 (GPCLK0) | 8 | 14 | TXD0 (UART) / BT Conflict |
| 9 | - | Ground (GND) | 10 | 15 | RXD0 (UART) / BT Conflict |
| 11 | 17 | GPIO17 | 12 | 18 | GPIO18 (PCM_CLK / PWM0) |
| 13 | 27 | GPIO27 | 14 | - | Ground (GND) |
| 15 | 22 | GPIO22 | 16 | 23 | GPIO23 |
| 17 | - | 3.3V Power | 18 | 24 | GPIO24 |
| 19 | 10 | MOSI (SPI0) | 20 | - | Ground (GND) |
| 21 | 9 | MISO (SPI0) | 22 | 25 | GPIO25 |
| 23 | 11 | SCLK (SPI0) | 24 | 8 | CE0 (SPI0 Chip Select) |
| 25 | - | Ground (GND) | 26 | 7 | CE1 (SPI0 Chip Select) |
| 27 | 0 | ID_SD (I2C ID EEPROM) | 28 | 1 | ID_SC (I2C ID EEPROM) |
| 29 | 5 | GPIO5 | 30 | - | Ground (GND) |
| 31 | 6 | GPIO6 | 32 | 12 | GPIO12 (PWM0) |
| 33 | 13 | GPIO13 (PWM1) | 34 | - | Ground (GND) |
| 35 | 19 | MISO (SPI1) / PCM_FS | 36 | 16 | GPIO16 (CE2) |
| 37 | 26 | GPIO26 | 38 | 20 | MOSI (SPI1) / PCM_DIN |
| 39 | - | Ground (GND) | 40 | 21 | SCLK (SPI1) / PCM_DOUT |
Wiring Color Codes & HAT Standards
Unlike mains wiring governed by NEC (US) or IEC 60446 (EU), low-voltage DC logic does not have a legally enforced global color code. However, the Raspberry Pi HAT Design Guide establishes the de facto standard for commercial Pi hardware. If you are building custom harnesses or wiring Dupont cables, follow this hierarchy to prevent catastrophic cross-wiring:
- 5V Power: Red (Universal across Pi HATs, ATX, and USB standards).
- Ground (GND): Black (Universal).
- 3.3V Power: Orange (Pi HAT standard) or Yellow (Telecom/Arduino legacy). Stick to Orange for Pi projects to avoid confusing it with 5V signal lines.
- I2C / SPI Signals: Blue, Green, or White. Avoid Red/Black/Orange for data lines.
Rows People Get Wrong (And How to Fix Them)
Bench experience reveals three specific pinout mistakes that consistently brick Zero W boards or cause silent communication failures.
1. The 5V vs 3.3V Logic Trap (Pins 2 & 3)
The BCM2835 SoC operates strictly at 3.3V logic. Pins 3, 5, 7, 8, etc., are not 5V tolerant. Feeding a 5V signal from an Arduino or an unlevel-shifted sensor into GPIO4 (Pin 7) will destroy the internal clamping diodes and eventually the SoC. If your sensor outputs 5V, you must use a bidirectional logic level converter (like the BSS138-based Adafruit 4-channel shifter) or a simple resistor voltage divider.
2. The I2C Pull-Up Conflict (Pins 3 & 5)
Pins 3 (SDA) and 5 (SCL) have onboard 1.8kΩ pull-up resistors tied to the 3.3V rail. If you connect an I2C sensor breakout that also has 4.7kΩ pull-ups tied to 5V, you create a voltage divider that pulls the Pi's 3.3V I2C lines up toward 5V, risking damage. Fix: Check your sensor's datasheet. If it has onboard pull-ups to 5V, desolate them or cut the trace on the sensor board before wiring to the Pi.
3. The UART / Bluetooth Collision (Pins 8 & 10)
On the Pi Zero W, the primary hardware UART (GPIO 14/15) is routed to the onboard Bluetooth module by default. If you wire a GPS module or serial console to Pins 8 and 10, you will get garbage data. Fix: Add dtoverlay=pi3-miniuart-bt to your /boot/config.txt to force Bluetooth onto the mini-UART and free up the hardware UART for your GPIO pins.
Peripheral Decision Tree: Which Pin Should You Use?
Use this decision path to select the correct pins for your next sensor or actuator. This eliminates guesswork and ensures you use hardware-backed protocols rather than bit-banging.
| Peripheral Type | Decision Condition | Concrete Pin Pick | Required Hardware / Config |
|---|---|---|---|
| I2C Sensor (e.g., BME280) | Sensor has 4 pins (VCC, GND, SDA, SCL) | Pins 3 & 5 | Enable I2C in raspi-config. Ensure sensor is 3.3V logic. |
| SPI Device (e.g., RFID RC522) | High speed, requires MISO/MOSI/SCLK | Pins 19, 21, 23, 24 | Enable SPI in raspi-config. Use Pin 24 for CE0. |
| Hardware PWM (e.g., Servo) | Needs stable, jitter-free pulse width | Pin 12 (GPIO 18) | Use pigpio library for hardware PWM. Do not use RPi.GPIO. |
| Analog Sensor (e.g., LDR, Pot) | Outputs variable voltage (0-3.3V) | Stop. Pi has no ADC. | Buy an ADS1115 (I2C ADC) or MCP3008 (SPI ADC). |
| Serial GPS / UART | Outputs TX/RX serial data | Pins 8 & 10 | Add dtoverlay=pi3-miniuart-bt to config.txt. |
Safe Interpretation When Markings Are Missing
The Raspberry Pi Zero W frequently ships without the 2x20 header soldered on, leaving only bare through-holes. Cloned boards or heavily used boards may also have faded silkscreen. Here is how to safely identify your pins using a digital multimeter (DMM) before applying power.
- Establish Orientation: Hold the board so the GPIO pads are on the right edge, the camera connector is on the top/right, and the mini-HDMI/USB ports are at the bottom. The top-left pad of the 2x20 grid is always Physical Pin 1 (3.3V).
- Find Ground (GND): Set your DMM to continuity mode (the diode/beep setting). Place one probe on the metal shield of the USB power port. Probe the pads on the right-side column (even numbers). Pins 6, 9, 14, 20, 25, 30, 34, and 39 will beep, confirming they are tied to the ground plane.
- Verify the 3.3V Rail: With the board powered off, set the DMM to diode test mode. Place the red probe on Pin 1 and the black probe on a confirmed GND pin. You should read a forward voltage drop (typically 0.3V to 0.6V) across the internal protection diodes. If it reads open (OL), the 3.3V linear regulator or the SoC's internal power ring may be damaged.
- Locate I2C (Pins 3 & 5): With the board powered on and booted to the OS, set the DMM to DC Voltage. Probe the odd pins on the left column. Pins 3 and 5 will read exactly 3.28V-3.32V due to the onboard 1.8kΩ pull-up resistors. Standard GPIO pins configured as inputs will typically float near 0V or 1.5V unless actively pulled.
By relying on physical board landmarks and multimeter verification rather than faded silkscreen, you eliminate the risk of feeding 5V into the 3.3V rail—a mistake that instantly and permanently kills the Zero W. For a visual, interactive map of these pins while coding, keep the community-maintained Pinout.xyz reference bookmarked on your workbench monitor, and consult the official Raspberry Pi GPIO Documentation for software-level overlay configurations.






