The ESP32-WROOM-32 (specifically the ubiquitous 38-pin DevKit V1 variant) features 38 physical header pins, but only 33 are exposed GPIOs, and not all are safe for general-purpose I/O. Below is the complete hardware reference, followed by the critical boot-strapping rules and external wiring standards you need when connecting this microcontroller to real-world sensors and mains-voltage relays.

The ESP32-WROOM-32 Pinout Master Reference

This table maps the physical header pins (1-38) on the standard 38-pin DOIT DevKit V1 breakout board to the internal ESP32-WROOM-32 silicon GPIOs. Use this as your primary bench reference. Note that the ESP32 operates strictly at 3.3V logic; the 5V/VIN pin is for power input only and does not step down to 5V logic output.

Pin # GPIO / Label Primary Functions Safe for Output? Boot / Strapping Notes
1GNDGroundN/ACommon return path
23V33.3V Power OutputN/AMax draw ~500mA depending on regulator
3ENChip EnableNoMust be HIGH to run, LOW to sleep/reset
4GPIO 36 (VP)ADC1_CH0, RTCNo (Input Only)No internal pull-up/down
5GPIO 39 (VN)ADC1_CH3, RTCNo (Input Only)No internal pull-up/down
6GPIO 34ADC1_CH6, RTCNo (Input Only)No internal pull-up/down
7GPIO 35ADC1_CH7, RTCNo (Input Only)No internal pull-up/down
8GPIO 32ADC1_CH4, Touch9, XTALYesSafe for general I/O
9GPIO 33ADC1_CH5, Touch8, XTALYesSafe for general I/O
10GPIO 25DAC1, ADC2_CH8, RTCYesAudio DAC output capable
11GPIO 26DAC2, ADC2_CH9, RTCYesAudio DAC output capable
12GPIO 27ADC2_CH7, Touch7YesSafe for general I/O
13GPIO 14ADC2_CH6, Touch6, MTMSYesOutputs PWM during boot
14GPIO 12ADC2_CH5, Touch5, MTDIYesCRITICAL: Must be LOW at boot
15GNDGroundN/ACommon return path
16GPIO 13ADC2_CH4, Touch4, MTCKYesSafe for general I/O
17GPIO 9SPI Flash (HD)NoReserved for internal SPI flash
18GPIO 10SPI Flash (WP)NoReserved for internal SPI flash
19GPIO 11SPI Flash (CS)NoReserved for internal SPI flash
20VIN / 5V5V Power InputN/ADo not use as 5V logic output
21GPIO 6SPI Flash (CLK)NoReserved for internal SPI flash
22GPIO 7SPI Flash (SD0)NoReserved for internal SPI flash
23GPIO 8SPI Flash (SD1)NoReserved for internal SPI flash
24GPIO 15ADC2_CH3, Touch3, MTDOYesOutputs PWM/debug during boot
25GPIO 2ADC2_CH2, Touch2, RTCYesConnected to onboard LED; must be LOW/Float at boot
26GPIO 0ADC2_CH1, Touch1, RTCYesCRITICAL: Must be HIGH for normal boot
27GPIO 4ADC2_CH0, Touch0, RTCYesSafe for general I/O
28GPIO 16UART2 RX, RTCYesSafe for general I/O
29GPIO 17UART2 TX, RTCYesSafe for general I/O
30GPIO 5VSPICLK, RTCYesOutputs PWM during boot
31GPIO 18VSPI MOSIYesStandard SPI data out
32GPIO 19VSPI MISOYesStandard SPI data in
33GNDGroundN/ACommon return path
34GPIO 21I2C SDA, RTCYesDefault hardware I2C data line
35GPIO 3UART0 RXYes (Input mostly)Serial debug RX; HIGH at boot
36GPIO 1UART0 TXYesSerial debug TX; outputs boot log
37GPIO 22I2C SCL, RTCYesDefault hardware I2C clock line
38GPIO 23VSPI MOSI (Alt)YesOften used for secondary SPI

Strapping Pins, 5V Tolerance, and Rows People Get Wrong

The Espressif ESP32 Datasheet explicitly defines several pins as "strapping pins." These pins are sampled by the silicon during the power-on reset phase to determine the boot mode and flash voltage. If you wire these pins to external components that pull them to the wrong state during boot, the ESP32 will either enter download mode or fail to boot entirely.

WARNING: 5V Tolerance Myth
The ESP32-WROOM-32 is not 5V tolerant on any GPIO pin. The absolute maximum voltage on any I/O pin is 3.6V. Feeding a 5V signal from an Arduino Uno or a 5V sensor directly into GPIO 13 or GPIO 36 will permanently damage the RTC domain or cause immediate brownouts. Always use a logic level shifter (like the TXS0108E) or a simple voltage divider (1kΩ / 2kΩ) for 5V signals.

Rows People Get Wrong: The Boot-Killers

  • GPIO 12 (MTDI): This is the most common board-bricking mistake. GPIO 12 determines the flash voltage regulator mode. If it is pulled HIGH during boot, the ESP32 switches the internal LDO to 1.8V. Because the WROOM-32 module uses a 3.3V SPI flash chip, the flash will fail to initialize, resulting in an infinite boot loop. Never connect a pull-up resistor or a sensor that defaults HIGH to GPIO 12.
  • GPIO 0: Must be HIGH for normal execution. If pulled LOW at boot, the chip enters UART serial bootloader (flash mode). This is why the "BOOT" button on dev boards connects GPIO 0 to GND.
  • GPIO 2: Must be LOW or floating at boot. It is tied to the onboard blue LED on most dev boards. If you wire an external relay to GPIO 2 and the relay's optocoupler pulls the pin HIGH, the ESP32 will fail to boot.
  • GPIO 34, 35, 36, 39: These are strictly input-only pins. They lack internal pull-up and pull-down resistors. If you configure them as inputs for a button or PIR sensor without an external 10kΩ pull-up/pull-down resistor, your digitalRead() values will float randomly. Furthermore, they are routed through the ADC multiplexer, meaning they can be noisy if read digitally while the ADC is active.

Safe Interpretation When Silkscreen Markings Fade

After a few rounds of rework, flux cleaning, and heat, the white silkscreen text on cheap DevKit V1 clones often rubs off. If you lose the pin labels, use the physical board layout to orient yourself:

  1. Locate the USB Port: Orient the board so the Micro-USB or USB-C port is facing downward.
  2. Identify the Voltage Regulator: The left side (usually) contains the AMS1117-3.3 voltage regulator. The pin closest to the USB port on the right side is typically 5V/VIN. The pin directly across from it on the left side is GND.
  3. The Enable Pin: Counting up from the bottom-right corner (5V), the second or third pin is almost always EN (Enable), followed immediately by GPIO 36 (VP).
  4. Verify with a Multimeter: Power the board via USB. Set your multimeter to DC voltage. Measure from the suspected GND pin to the metal shield of the USB port (which is grounded). It should read 0.00Ω continuity when unpowered, and the suspected 3V3 pin should read exactly 3.25V - 3.35V relative to GND.

External Wiring Standards: IEC vs. NEC for ESP32 Peripherals

While the ESP32 pinout defines the low-voltage DC side of your project, the moment you use the ESP32 to trigger a relay module that switches a 120V or 230V AC load, you cross into regional electrical codes. The wire colors on the load side of your relay must comply with local standards. Additionally, if you are wiring industrial 24V DC sensors (like M12 inductive proximity sensors) to the ESP32 via an optocoupler, those follow a completely different IEC standard.

The following table breaks down which standard applies to your region and what each color means in practice when wiring peripherals to your ESP32-controlled system.

Application / Standard Region Line / Positive (+) Neutral / Negative (-) Earth / Signal
IEC 60446 (AC Mains) EU, UK, AU, Global Brown Blue Green/Yellow Stripe
NEC / NFPA 70 (AC Mains) US, Canada Black (or Red for 2nd phase) White (or Grey) Bare Copper or Green
Old UK Wiring (Pre-2004) Legacy UK Installations Red Black Green/Yellow (or bare)
IEC 60947-5-2 (DC Sensors) Global Industrial (M12/M8) Brown (+V, e.g., 24V) Blue (0V / GND) Black (Signal/Output)

Applying These Standards to ESP32 Projects

1. Mains Relay Wiring (NEC vs IEC): When wiring an ESP32 to a 5V relay module that switches a 120V AC lamp in the US, the black wire from your wall must go to the relay's Common (C) terminal, and the white neutral wire bypasses the relay entirely, going straight to the lamp. In Europe (IEC), the brown wire goes to the relay, and the blue neutral bypasses it. Never switch the neutral line with the relay; always switch the Line/Hot wire to ensure the load is de-energized when off.

2. Industrial DC Sensor Wiring: If you are connecting a 24V NPN/PNP proximity sensor to an ESP32 GPIO (via a voltage divider or optocoupler like the PC817 to step the 24V signal down to 3.3V), use the IEC DC color code. Connect the sensor's Brown wire to the 24V supply, the Blue wire to the supply ground, and the Black wire to your optocoupler input. The White wire (if present on a 4-pin M12 connector) is typically the normally-closed (NC) signal or a configuration input, which is usually left unconnected for basic ESP32 interrupt counting.

3. Standard Jumper Wire Conventions: On the low-voltage DC side (the ESP32 breadboard itself), the maker community universally follows a loose adaptation of the IEC DC standard: Red for 3.3V/5V, Black for GND, and Yellow/Orange/Green for signal lines (I2C, SPI, UART). Sticking to this convention prevents catastrophic reverse-polarity shorts when swapping modules like the BME280 or MPU6050 on the bench.