GPIO Pinout Reference
The Zero W uses the same 40-pin GPIO header layout found across the whole modern Raspberry Pi lineup - the Zero, Zero W, Zero 2 W, and the Pi 2/3/4/5 boards all share this exact same physical pinout, so a diagram or HAT built for one generally works on any of them. On the standard Zero W SKU, this header ships unpopulated (no pins pre-soldered) - you'll need to solder your own header, use a Zero WH variant that comes with one pre-soldered, or use press-fit pogo-pin connectors, depending on your project.
The Complete 40-Pin Layout
| Pin | Function | Pin | Function |
|---|---|---|---|
| 1 | 3V3 Power | 2 | 5V Power |
| 3 | GPIO2 (SDA) | 4 | 5V Power |
| 5 | GPIO3 (SCL) | 6 | Ground |
| 7 | GPIO4 (GPCLK0) | 8 | GPIO14 (TXD) |
| 9 | Ground | 10 | GPIO15 (RXD) |
| 11 | GPIO17 | 12 | GPIO18 (PCM_CLK) |
| 13 | GPIO27 | 14 | Ground |
| 15 | GPIO22 | 16 | GPIO23 |
| 17 | 3V3 Power | 18 | GPIO24 |
| 19 | GPIO10 (MOSI) | 20 | Ground |
| 21 | GPIO9 (MISO) | 22 | GPIO25 |
| 23 | GPIO11 (SCLK) | 24 | GPIO8 (CE0) |
| 25 | Ground | 26 | GPIO7 (CE1) |
| 27 | GPIO0 (ID_SD) | 28 | GPIO1 (ID_SC) |
| 29 | GPIO5 | 30 | Ground |
| 31 | GPIO6 | 32 | GPIO12 (PWM0) |
| 33 | GPIO13 (PWM1) | 34 | Ground |
| 35 | GPIO19 (PCM_FS) | 36 | GPIO16 |
| 37 | GPIO26 | 38 | GPIO20 (PCM_DIN) |
| 39 | Ground | 40 | GPIO21 (PCM_DOUT) |
28 usable GPIO signal pins in total, plus power (two 3V3 pins, two 5V pins) and ground pins.
Physical Pin Number vs BCM/GPIO Number
This is one of the most common beginner mix-ups, so it's worth being explicit about it. There are two different numbering systems in play at the same time:
- Physical pin numbering (1-40) - a simple left-to-right, top-to-bottom count of the physical pins on the header, used when you're wiring things up by hand or following a diagram.
- BCM / GPIO numbering - the number the Broadcom chip (and your code) actually refers to
that pin by, e.g. "GPIO17". This is what you'll use in Python code with libraries like
gpiozero.
These two numbers are not the same, and mixing them up is a very common mistake. For example: physical pin 11 corresponds to GPIO17 in code - but physical pin 17 is a 3.3V power pin, not a GPIO at all. Always double check which numbering scheme a diagram or tutorial is using before you wire anything or write code against a pin number.
What the Shared-Function Pins Mean
| Protocol | Pins | Used for |
|---|---|---|
| I2C | Pin 3 (SDA), Pin 5 (SCL) | A simple two-wire bus for talking to sensors and small peripheral chips that support I2C |
| SPI | Pins 19 (MOSI), 21 (MISO), 23 (SCLK), 24 (CE0), 26 (CE1) | A faster bus commonly used for displays, SD cards, and certain sensors |
| UART / Serial | Pin 8 (TXD), Pin 10 (RXD) | Simple serial communication - handy for a console connection or talking to another microcontroller |
| PWM | Pin 32 (PWM0), Pin 33 (PWM1) | Pulse-width modulation - useful for dimming LEDs smoothly or controlling motor/servo speed |