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 |
|---|---|---|---|---|
| 1 | GND | Ground | N/A | Common return path |
| 2 | 3V3 | 3.3V Power Output | N/A | Max draw ~500mA depending on regulator |
| 3 | EN | Chip Enable | No | Must be HIGH to run, LOW to sleep/reset |
| 4 | GPIO 36 (VP) | ADC1_CH0, RTC | No (Input Only) | No internal pull-up/down |
| 5 | GPIO 39 (VN) | ADC1_CH3, RTC | No (Input Only) | No internal pull-up/down |
| 6 | GPIO 34 | ADC1_CH6, RTC | No (Input Only) | No internal pull-up/down |
| 7 | GPIO 35 | ADC1_CH7, RTC | No (Input Only) | No internal pull-up/down |
| 8 | GPIO 32 | ADC1_CH4, Touch9, XTAL | Yes | Safe for general I/O |
| 9 | GPIO 33 | ADC1_CH5, Touch8, XTAL | Yes | Safe for general I/O |
| 10 | GPIO 25 | DAC1, ADC2_CH8, RTC | Yes | Audio DAC output capable |
| 11 | GPIO 26 | DAC2, ADC2_CH9, RTC | Yes | Audio DAC output capable |
| 12 | GPIO 27 | ADC2_CH7, Touch7 | Yes | Safe for general I/O |
| 13 | GPIO 14 | ADC2_CH6, Touch6, MTMS | Yes | Outputs PWM during boot |
| 14 | GPIO 12 | ADC2_CH5, Touch5, MTDI | Yes | CRITICAL: Must be LOW at boot |
| 15 | GND | Ground | N/A | Common return path |
| 16 | GPIO 13 | ADC2_CH4, Touch4, MTCK | Yes | Safe for general I/O |
| 17 | GPIO 9 | SPI Flash (HD) | No | Reserved for internal SPI flash |
| 18 | GPIO 10 | SPI Flash (WP) | No | Reserved for internal SPI flash |
| 19 | GPIO 11 | SPI Flash (CS) | No | Reserved for internal SPI flash |
| 20 | VIN / 5V | 5V Power Input | N/A | Do not use as 5V logic output |
| 21 | GPIO 6 | SPI Flash (CLK) | No | Reserved for internal SPI flash |
| 22 | GPIO 7 | SPI Flash (SD0) | No | Reserved for internal SPI flash |
| 23 | GPIO 8 | SPI Flash (SD1) | No | Reserved for internal SPI flash |
| 24 | GPIO 15 | ADC2_CH3, Touch3, MTDO | Yes | Outputs PWM/debug during boot |
| 25 | GPIO 2 | ADC2_CH2, Touch2, RTC | Yes | Connected to onboard LED; must be LOW/Float at boot |
| 26 | GPIO 0 | ADC2_CH1, Touch1, RTC | Yes | CRITICAL: Must be HIGH for normal boot |
| 27 | GPIO 4 | ADC2_CH0, Touch0, RTC | Yes | Safe for general I/O |
| 28 | GPIO 16 | UART2 RX, RTC | Yes | Safe for general I/O |
| 29 | GPIO 17 | UART2 TX, RTC | Yes | Safe for general I/O |
| 30 | GPIO 5 | VSPICLK, RTC | Yes | Outputs PWM during boot |
| 31 | GPIO 18 | VSPI MOSI | Yes | Standard SPI data out |
| 32 | GPIO 19 | VSPI MISO | Yes | Standard SPI data in |
| 33 | GND | Ground | N/A | Common return path |
| 34 | GPIO 21 | I2C SDA, RTC | Yes | Default hardware I2C data line |
| 35 | GPIO 3 | UART0 RX | Yes (Input mostly) | Serial debug RX; HIGH at boot |
| 36 | GPIO 1 | UART0 TX | Yes | Serial debug TX; outputs boot log |
| 37 | GPIO 22 | I2C SCL, RTC | Yes | Default hardware I2C clock line |
| 38 | GPIO 23 | VSPI MOSI (Alt) | Yes | Often 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.
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:
- Locate the USB Port: Orient the board so the Micro-USB or USB-C port is facing downward.
- 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.
- 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).
- 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.






