When wiring sensors, displays, or industrial PLCs, misinterpreting a gpio pinout diagram or guessing wire colors is the fastest way to fry a 3.3V logic chip or cause a ground loop. While hobbyist breakout boards rely on informal color conventions, industrial discrete I/O strictly follows regional electrical codes. This reference bridges the gap between benchtop microcontrollers and control panel wiring.

The Universal GPIO Pinout & Wire Color Reference Table

The table below maps standard embedded protocols to their schematic symbols, typical Dupont/harness wire colors, and default pins for the two most common 2026 development boards: the ESP32-WROOM-32 and the Raspberry Pi 4/5. Use this as your primary bench reference.

Function Symbol Hobby Wire Color What It Means in Practice ESP32 Default RPi 4/5 Default
Logic Power VCC / 3V3 Red 3.3V logic high reference. Never feed 5V here. 3V3 Pin Pin 1 (3.3V)
System Ground GND Black Common return path. Must be shared across all devices. GND Pin Pin 6, 9, 14, 20
I2C Data SDA Blue Bidirectional data line. Requires 4.7kΩ pull-ups. GPIO 21 GPIO 2 (Pin 3)
I2C Clock SCL Yellow Clock signal generated by the master device. GPIO 22 GPIO 3 (Pin 5)
SPI Master Out MOSI Green Data from master to slave (COPI in modern naming). GPIO 23 GPIO 10 (Pin 19)
SPI Master In MISO Orange Data from slave to master (CIPO in modern naming). GPIO 19 GPIO 9 (Pin 21)
SPI Clock SCK / SCLK Purple Serial clock. Keep traces short to avoid capacitance. GPIO 18 GPIO 11 (Pin 23)
SPI Chip Select CS / SS White Active-low enable. One unique CS per slave device. GPIO 5 GPIO 8 (Pin 24)
UART Transmit TX Green (Stripe) Sends serial data. Must connect to target's RX. GPIO 1 (TX0) GPIO 14 (Pin 8)
UART Receive RX White (Stripe) Receives serial data. Must connect to target's TX. GPIO 3 (RX0) GPIO 15 (Pin 10)

Regional & Standard Variants: Embedded Harness vs. Industrial I/O

The hobbyist colors above (Red/Black/Blue/Yellow) are informal conventions popularized by companies like Adafruit and SparkFun. However, if your GPIO project scales to an industrial control panel using PLC discrete I/O (which is functionally identical to microcontroller GPIO but at 24VDC), you must follow regional electrical standards for wire colors. Mixing these up causes catastrophic faults.

⚠️ Warning: Mains and 24VDC Control Circuits
When wiring industrial GPIO (optocouplers, relay boards, PLC inputs), always de-energize the panel, verify dead with a CAT III multimeter, and follow local AHJ codes. The guidelines below are NEC/IEC-style references, not legal code.

IEC 60446 (Europe, UK, Australia, International)

Under IEC 60446 (now integrated into IEC 60445), DC control circuits use specific colors to prevent confusion with AC mains:

  • Brown: DC Positive (Ungrounded / +24VDC)
  • Blue: DC Negative (Grounded / 0VDC)
  • Old UK Standard (Pre-2004): You may encounter legacy panels using Red (+) and Black (-). Treat Black as ground, but verify with a meter, as it conflicts with modern IEC AC line colors.

NEC / NFPA 79 (United States, Canada)

In North America, industrial control panels follow NFPA 79 (Electrical Standard for Industrial Machinery). The DC control wiring colors differ from IEC:

  • Black or Red: DC Ungrounded (Positive / +24VDC)
  • White or Blue: DC Grounded (Negative / 0VDC). White is heavily preferred in the US for DC common.
  • Green / Green-Yellow: Protective Earth (PE). Never use this for a DC signal return.

The 'Rows People Get Wrong' & Faded Pinout Recovery

Even with a perfect reference table, embedded engineers routinely make three specific GPIO mistakes. Furthermore, cheap clone boards often ship with faded or entirely missing silkscreen pinout markings.

The 3 Most Common GPIO Pinout Mistakes

  1. UART TX/RX Crossover: People wire TX to TX and RX to RX. Remember: Transmit must connect to Receive. If your serial monitor outputs garbage or nothing, swap the two wires.
  2. ESP32 Strapping Pins: GPIOs 0, 2, 5, 12, and 15 dictate the boot mode. If you wire a sensor that pulls GPIO 12 HIGH or GPIO 0 LOW during power-up, the ESP32 will fail to boot into your sketch and will instead enter the UART bootloader or flash SPI mode. Avoid these pins for external inputs.
  3. Raspberry Pi 5V Tolerance: The RPi GPIO header has two 5V pins (Pin 2, Pin 4) and multiple 3.3V pins. Feeding a 5V logic signal into a 3.3V RPi GPIO (like I2C SDA on GPIO 2) will permanently destroy the BCM SoC. Always use a logic level shifter (like the BSS138 bidirectional module) when interfacing 5V Arduino sensors with a Pi.

Safe Interpretation When Markings are Faded or Missing

When the silkscreen on a cloned ESP32 or custom PCB is unreadable, do not guess. Use this recovery sequence:

  1. Find Ground First: Set your multimeter to continuity mode (beep). Probe the USB connector's metal shield or the outer ring of the DC barrel jack. Probe the header pins until you find the ones that beep. Mark them as GND immediately.
  2. Identify VCC: Power the board via USB. Set the meter to DC Voltage. Probe the remaining pins relative to your known GND. Pins reading a steady 3.3V or 5.0V are your logic/power rails. (Note: On the ESP32, the 5V pin is directly tied to USB VBUS, while 3V3 is the regulator output).
  3. Trace Clock/Data: If you need to find an I2C or SPI pin on an unmarked board, connect a cheap $15 USB logic analyzer (like a Saleae clone) to suspected pins and run a test sketch that blinks an I2C scanner. The analyzer software will visually show which pin is toggling the clock signal.

GPIO Pinout FAQ

What GPIO pinout should I avoid on the ESP32 for input sensors?

Avoid GPIOs 34, 35, 36 (VP), and 39 (VN). These are input-only pins. They lack internal pull-up/pull-down resistors and cannot drive an output HIGH or LOW. If your schematic requires a pin to trigger a relay or light an LED, these pins will fail silently. Additionally, as mentioned above, avoid the strapping pins (0, 2, 12) if your sensor has a default state that could interfere with the boot sequence.

Does the I2C GPIO pinout change between Raspberry Pi and Arduino?

The physical pin numbers change, but the protocol remains identical. On an Arduino Uno, hardware I2C is strictly on A4 (SDA) and A5 (SCL). On a Raspberry Pi 4/5, hardware I2C bus 1 is on GPIO 2 (SDA) and GPIO 3 (SCL). While the Pi does support software bit-banging I2C on other pins, you should always use the dedicated hardware pins for reliable communication with high-speed sensors like the BME280 or MPU6050. For detailed Pi bus mappings, refer to the official Raspberry Pi hardware documentation.

How do I wire a 4-20mA industrial sensor to a microcontroller GPIO?

You cannot wire a 4-20mA loop directly to a 3.3V GPIO pin; it will destroy the microcontroller. You must pass the current loop through a precision shunt resistor (typically 250Ω) to convert it to a 1-5V signal, then pass that voltage through an optocoupler or an isolation amplifier (like the AMC1301) before feeding it into the microcontroller's ADC GPIO pin. Always ensure the ground of the 4-20mA power supply is isolated from the microcontroller's digital GND.