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.

PhysBCMFunctionNotes / Warnings
1-3.3V PowerMax draw ~50mA. Do not use for motors.
2-5V PowerTied directly to USB power input.
32GPIO2 (SDA1)I2C Data. Has 1.8kΩ pull-up to 3.3V.
4-5V PowerTied directly to USB power input.
53GPIO3 (SCL1)I2C Clock. Has 1.8kΩ pull-up to 3.3V.
6-GroundSystem GND.
74GPIO4Default 1-Wire data pin (DS18B20).
814GPIO14 (TXD)UART Transmit. (See mini-UART warning below).
9-GroundSystem GND.
1015GPIO15 (RXD)UART Receive. (See mini-UART warning below).
1117GPIO17General purpose digital I/O.
1218GPIO18 (PWM0)Hardware PWM channel 0.
1327GPIO27General purpose digital I/O.
14-GroundSystem GND.
1522GPIO22General purpose digital I/O.
1623GPIO23General purpose digital I/O.
17-3.3V PowerMax draw ~50mA.
1824GPIO24General purpose digital I/O.
1910GPIO10 (MOSI)SPI Master Out Slave In.
20-GroundSystem GND.
219GPIO9 (MISO)SPI Master In Slave Out.
2225GPIO25General purpose digital I/O.
2311GPIO11 (SCLK)SPI Clock.
248GPIO8 (CE0)SPI Chip Select 0.
25-GroundSystem GND.
267GPIO7 (CE1)SPI Chip Select 1.
270ID_SDHAT EEPROM I2C Data. Reserved.
281ID_SCHAT EEPROM I2C Clock. Reserved.
295GPIO5General purpose digital I/O.
30-GroundSystem GND.
316GPIO6General purpose digital I/O.
3212GPIO12 (PWM0)Hardware PWM channel 0 (alt pin).
3313GPIO13 (PWM1)Hardware PWM channel 1.
34-GroundSystem GND.
3519GPIO19General purpose digital I/O.
3616GPIO16General purpose digital I/O.
3726GPIO26General purpose digital I/O.
3820GPIO20General purpose digital I/O.
39-GroundSystem GND.
4021GPIO21General 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 5V vs 3.3V Trap: Pins 2 and 4 output 5V, but the BCM2837 SoC logic levels are strictly 3.3V. If you connect a 5V sensor output (like an HC-SR04 ultrasonic echo pin) directly to Pin 8 (GPIO14) or any other BCM pin, you will fry the SoC's input clamping diodes. Always use a voltage divider (e.g., 2kΩ and 3.3kΩ resistors) or a logic level shifter when reading 5V signals.

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.

ApplicationIEC 60446 (EU/Global)US NEC (North America)Old UK (Pre-2004)
DC Sensor Power (+V)BrownRedRed / Yellow
DC Sensor GND (0V)BlueBlackBlack / Blue
DC Sensor SignalBlackWhite or YellowWhite
AC Mains Line (Hot)BrownBlack (or Red)Red
AC Mains NeutralBlueWhite (or Grey)Black
AC Mains Earth (Ground)Green/Yellow StripeBare, Green, or Green/YellowGreen

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:

  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.
  2. 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.
  3. 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.
Bench Tip: Before applying power to a salvaged or faded Pi, use a multimeter in continuity mode. Place one probe on the metal shield of the USB port (which is tied to system GND) and probe the header pins. Pins 6, 9, 14, 20, 25, 30, 34, and 39 will beep. This confirms your GND orientation before you risk shorting the 5V rail.

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 TypeProtocol RequiredConcrete Pin Pick (Physical)Why This Pick?
Analog Sensor (e.g., MQ-2 Gas, LDR)SPI (via ADC)19, 21, 23, 24Pi has no native ADC. You must use an MCP3008 chip on the hardware SPI0 bus.
Multiple Low-Speed Sensors (e.g., BME280, OLED)I2C3, 5Hardware I2C1 bus. Allows daisy-chaining up to 127 devices on just two wires.
High-Speed Display (e.g., ILI9341 TFT)SPI19, 21, 23, 24, 26Hardware SPI0 supports clock speeds up to 125MHz, required for smooth display rendering.
GPS or Serial ConsoleUART8, 10Physical UART pins. Remember to configure enable_uart=1 in config.txt for the mini-UART.
DC Motor or ServoPWM12, 33Hardware PWM channels. Pin 12 (GPIO18) and Pin 33 (GPIO13) provide stable, jitter-free pulse widths.
1-Wire Temp Sensor (DS18B20)1-Wire7Physical 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.