The Raspberry Pi 3 Model B uses a standardized 40-pin GPIO header. Pin 1 is the 3.3V power pin located closest to the SD card slot, while Pin 2 is 5V. Unlike microcontrollers with native analog-to-digital converters, the Pi 3B outputs strictly digital 3.3V logic. Feeding 5V into any GPIO pin (other than the dedicated 5V power pins) will permanently destroy the BCM2837 SoC. Below is the complete reference map, followed by the exact peripheral wiring standards and decision paths you need to wire your bench safely.
The Complete Raspberry Pi 3 Model B Pinout Diagram
This table maps the physical header pins to the Broadcom (BCM) GPIO numbers used in Python/C code. The physical pin numbering (1-40) is what you count on the board; the BCM numbering is what you type into your scripts.
| Phys | BCM | Function | Notes / Warnings |
|---|---|---|---|
| 1 | - | 3.3V Power | Max draw ~50mA. Do not use for motors. |
| 2 | - | 5V Power | Tied directly to USB power input. |
| 3 | 2 | GPIO2 (SDA1) | I2C Data. Has 1.8kΩ pull-up to 3.3V. |
| 4 | - | 5V Power | Tied directly to USB power input. |
| 5 | 3 | GPIO3 (SCL1) | I2C Clock. Has 1.8kΩ pull-up to 3.3V. |
| 6 | - | Ground | System GND. |
| 7 | 4 | GPIO4 | Default 1-Wire data pin (DS18B20). |
| 8 | 14 | GPIO14 (TXD) | UART Transmit. (See mini-UART warning below). |
| 9 | - | Ground | System GND. |
| 10 | 15 | GPIO15 (RXD) | UART Receive. (See mini-UART warning below). |
| 11 | 17 | GPIO17 | General purpose digital I/O. |
| 12 | 18 | GPIO18 (PWM0) | Hardware PWM channel 0. |
| 13 | 27 | GPIO27 | General purpose digital I/O. |
| 14 | - | Ground | System GND. |
| 15 | 22 | GPIO22 | General purpose digital I/O. |
| 16 | 23 | GPIO23 | General purpose digital I/O. |
| 17 | - | 3.3V Power | Max draw ~50mA. |
| 18 | 24 | GPIO24 | General purpose digital I/O. |
| 19 | 10 | GPIO10 (MOSI) | SPI Master Out Slave In. |
| 20 | - | Ground | System GND. |
| 21 | 9 | GPIO9 (MISO) | SPI Master In Slave Out. |
| 22 | 25 | GPIO25 | General purpose digital I/O. |
| 23 | 11 | GPIO11 (SCLK) | SPI Clock. |
| 24 | 8 | GPIO8 (CE0) | SPI Chip Select 0. |
| 25 | - | Ground | System GND. |
| 26 | 7 | GPIO7 (CE1) | SPI Chip Select 1. |
| 27 | 0 | ID_SD | HAT EEPROM I2C Data. Reserved. |
| 28 | 1 | ID_SC | HAT EEPROM I2C Clock. Reserved. |
| 29 | 5 | GPIO5 | General purpose digital I/O. |
| 30 | - | Ground | System GND. |
| 31 | 6 | GPIO6 | General purpose digital I/O. |
| 32 | 12 | GPIO12 (PWM0) | Hardware PWM channel 0 (alt pin). |
| 33 | 13 | GPIO13 (PWM1) | Hardware PWM channel 1. |
| 34 | - | Ground | System GND. |
| 35 | 19 | GPIO19 | General purpose digital I/O. |
| 36 | 16 | GPIO16 | General purpose digital I/O. |
| 37 | 26 | GPIO26 | General purpose digital I/O. |
| 38 | 20 | GPIO20 | General purpose digital I/O. |
| 39 | - | Ground | System GND. |
| 40 | 21 | GPIO21 | General purpose digital I/O. |
Rows People Get Wrong (And How to Avoid Bricking Your Pi)
Even experienced makers burn out their Pi 3B boards by misinterpreting three specific areas of this pinout. Here is what the datasheet actually means in practice.
The Pi 3B UART Bluetooth Gotcha
On the Pi 1 and 2, the hardware UART (/dev/ttyAMA0) was mapped to physical pins 8 and 10. On the Pi 3 Model B, the hardware UART was rerouted to drive the onboard Bluetooth module. Pins 8 and 10 now default to the "mini-UART" (/dev/ttyS0). The mini-UART baud rate is tied to the core clock frequency, meaning CPU throttling will corrupt your serial data. The fix: Add enable_uart=1 to your /boot/config.txt to stabilize the mini-UART, or disable Bluetooth entirely to reclaim the hardware UART for the GPIO pins.
The ID EEPROM Pins (27 and 28)
Physical pins 27 and 28 (BCM 0 and 1) are reserved for probing Raspberry Pi HAT identification EEPROMs. They have 3.3V pull-ups and are polled during boot. If you wire a standard I2C sensor here, the boot-time polling can conflict with your sensor, causing boot hangs or I2C bus lockups. Leave them empty unless you are designing a custom HAT.
Peripheral Wiring Standards: IEC, NEC, and Old UK Color Codes
While the Pi's GPIO header is universal, the sensors, relays, and industrial peripherals you wire to it are not. When connecting external modules—especially those bridging DC logic to AC mains via relays—you must follow your region's wiring color codes to prevent lethal faults or equipment damage. Below is the decision matrix for peripheral wiring based on IEC 60446, US NEC (NFPA 70), and legacy UK standards.
| Application | IEC 60446 (EU/Global) | US NEC (North America) | Old UK (Pre-2004) |
|---|---|---|---|
| DC Sensor Power (+V) | Brown | Red | Red / Yellow |
| DC Sensor GND (0V) | Blue | Black | Black / Blue |
| DC Sensor Signal | Black | White or Yellow | White |
| AC Mains Line (Hot) | Brown | Black (or Red) | Red |
| AC Mains Neutral | Blue | White (or Grey) | Black |
| AC Mains Earth (Ground) | Green/Yellow Stripe | Bare, Green, or Green/Yellow | Green |
Which standard applies to you? If you are wiring a 24V industrial PNP sensor to a Pi optocoupler HAT, use the IEC DC row (Brown/Blue/Black). If you are wiring the AC load side of a Pi-controlled mechanical relay in a US home, you must use the US NEC row (Black/White/Bare). Never mix IEC DC colors with US AC colors on the same terminal block; the brown/blue IEC DC wires look dangerously similar to US/IEC AC mains wires.
Safe Interpretation When Pin Markings Are Faded or Missing
Pi 3B boards subjected to high heat or flux residue often lose their silkscreen pin numbers. If you cannot read the board markings, do not guess. Use these three physical landmarks to definitively identify Pin 1:
- The Square Pad Rule: Flip the Pi over. Look at the solder joints for the 40-pin header on the underside of the PCB. Pin 1 is the only joint with a square copper pad. All other pins (2 through 40) have perfectly round pads.
- The SD Card Proximity: Pin 1 is always the corner pin closest to the micro-SD card slot and the USB/Ethernet ports. Pin 2 is directly adjacent to it on the outer edge.
- The Shroud Triangle: If your Pi has a black plastic GPIO shroud or a HAT attached, look at the plastic molding. There is a small, embossed triangle pointing to the Pin 1 corner.
GPIO Assignment Decision Tree
Stop guessing which pins to use for your sensors. Use this decision path to select the exact physical pins and protocol for your peripheral. This terminates the "it depends" loop and gives you a concrete wiring target.
| Peripheral Type | Protocol Required | Concrete Pin Pick (Physical) | Why This Pick? |
|---|---|---|---|
| Analog Sensor (e.g., MQ-2 Gas, LDR) | SPI (via ADC) | 19, 21, 23, 24 | Pi has no native ADC. You must use an MCP3008 chip on the hardware SPI0 bus. |
| Multiple Low-Speed Sensors (e.g., BME280, OLED) | I2C | 3, 5 | Hardware I2C1 bus. Allows daisy-chaining up to 127 devices on just two wires. |
| High-Speed Display (e.g., ILI9341 TFT) | SPI | 19, 21, 23, 24, 26 | Hardware SPI0 supports clock speeds up to 125MHz, required for smooth display rendering. |
| GPS or Serial Console | UART | 8, 10 | Physical UART pins. Remember to configure enable_uart=1 in config.txt for the mini-UART. |
| DC Motor or Servo | PWM | 12, 33 | Hardware PWM channels. Pin 12 (GPIO18) and Pin 33 (GPIO13) provide stable, jitter-free pulse widths. |
| 1-Wire Temp Sensor (DS18B20) | 1-Wire | 7 | Physical Pin 7 (GPIO4) is the default kernel overlay pin for the 1-Wire protocol. |
For a comprehensive deep-dive into configuring the Pi 3B's device tree overlays for these specific pins, refer to the official Raspberry Pi hardware documentation. Always verify your physical wiring against the BCM numbers in your Python or C scripts, as mixing up physical and BCM numbering is the most common cause of "GPIO not responding" errors on the bench.






