ESP32 Pinout Reference: Which GPIO pins should you use?

The ESP32 chip comes with 48 pins with multiple functions. Not all pins are exposed in all ESP32 development boards, and there are some pins that cannot be used.

There are many questions on how to use the ESP32 GPIOs. What pins should you use? What pins should you avoid using in your projects? This post aims to be a simple and easy to follow reference guide for the ESP32 GPIOs.

The figure below illustrates the ESP-WROOM-32 pinout. You can use it as a reference if you’re using an ESP32 bare chip to build a custom board:

ESP32 Pinout chip ESP-WROOM-32

Note: not all GPIOs are accessible in all development boards, but each specific GPIO works in the same way regardless of the development board you’re using. If you’re just getting started with the ESP32, we recommend reading our guide: Getting Started with the ESP32 Development Board.

ESP32 Peripherals

The ESP32 peripherals include:

  • 18 Analog-to-Digital Converter (ADC) channels
  • 3 SPI interfaces
  • 3 UART interfaces
  • 2 I2C interfaces
  • 16 PWM output channels
  • 2 Digital-to-Analog Converters (DAC)
  • 2 I2S interfaces
  • 10 Capacitive sensing GPIOs

The ADC (analog to digital converter) and DAC (digital to analog converter) features are assigned to specific static pins. However, you can decide which pins are UART, I2C, SPI, PWM, etc – you just need to assign them in the code. This is possible due to the ESP32 chip’s multiplexing feature.

Although you can define the pins properties on the software, there are pins assigned by default as shown in the following figure (this is an example for the ESP32 DEVKIT V1 DOIT board with 36 pins – the pin location can change depending on the manufacturer).

This is our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks!  SIGN UP NOW »

This is our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! SIGN UP NOW »

Additionally, there are pins with specific features that make them suitable or not for a specific project. The following table shows what pins are best to use as inputs, outputs and which ones you need to be cautious.

The pins highlighted in green are OK to use. The ones highlighted in yellow are OK to use, but you need to pay attention because they may have unexpected behavior mainly at boot. The pins highlighted in red are not recommended to use as inputs or outputs.

GPIOInputOutputNotes
0pulled upOKoutputs PWM signal at boot
1TX pinOKdebug output at boot
2OKOKconnected to on-board LED
3OKRX pin HIGH at boot
4OKOK
5OKOKoutputs PWM signal at boot
6xxconnected to the integrated SPI flash
7xxconnected to the integrated SPI flash
8xxconnected to the integrated SPI flash
9xxconnected to the integrated SPI flash
10xxconnected to the integrated SPI flash
11xxconnected to the integrated SPI flash
12OKOKboot fail if pulled high
13OKOK
14OKOKoutputs PWM signal at boot
15OKOKoutputs PWM signal at boot
16OKOK
17OKOK
18OKOK
19OKOK
21OKOK
22OKOK
23OKOK
25OKOK
26OKOK
27OKOK
32OKOK
33OKOK
34OKinput only
35OKinput only
36OKinput only
39OKinput only

Continue reading for a more detail and in-depth analysis of the ESP32 GPIOs and its functions.

Input only pins

GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-ups or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs:

  • GPIO 34
  • GPIO 35
  • GPIO 36
  • GPIO 39

SPI flash integrated on the ESP-WROOM-32

GPIO 6 to GPIO 11 are exposed in some ESP32 development boards. However, these pins are connected to the integrated SPI flash on the ESP-WROOM-32 chip and are not recommended for other uses. So, don’t use these pins in your projects:

  • GPIO 6 (SCK/CLK)
  • GPIO 7 (SDO/SD0)
  • GPIO 8 (SDI/SD1)
  • GPIO 9 (SHD/SD2)
  • GPIO 10 (SWP/SD3)
  • GPIO 11 (CSC/CMD)

Capacitive touch GPIOs

The ESP32 has 10 internal capacitive touch sensors. These can sense variations in anything that holds an electrical charge, like the human skin. So they can detect variations induced when touching the GPIOs with a finger. These pins can be easily integrated into capacitive pads, and replace mechanical buttons. The capacitive touch pins can also be used to wake up the ESP32 from deep sleep.

Those internal touch sensors are connected to these GPIOs:

  • T0 (GPIO 4)
  • T1 (GPIO 0)
  • T2 (GPIO 2)
  • T3 (GPIO 15)
  • T4 (GPIO 13)
  • T5 (GPIO 12)
  • T6 (GPIO 14)
  • T7 (GPIO 27)
  • T8 (GPIO 33)
  • T9 (GPIO 32)

Analog to Digital Converter (ADC)

The ESP32 has 18 x 12 bits ADC input channels (while the ESP8266 only has 1x 10 bits ADC). These are the GPIOs that can be used as ADC and respective channels:

  • ADC1_CH0 (GPIO 36)
  • ADC1_CH1 (GPIO 37)
  • ADC1_CH2 (GPIO 38)
  • ADC1_CH3 (GPIO 39)
  • ADC1_CH4 (GPIO 32)
  • ADC1_CH5 (GPIO 33)
  • ADC1_CH6 (GPIO 34)
  • ADC1_CH7 (GPIO 35)
  • ADC2_CH0 (GPIO 4)
  • ADC2_CH1 (GPIO 0)
  • ADC2_CH2 (GPIO 2)
  • ADC2_CH3 (GPIO 15)
  • ADC2_CH4 (GPIO 13)
  • ADC2_CH5 (GPIO 12)
  • ADC2_CH6 (GPIO 14)
  • ADC2_CH7 (GPIO 27)
  • ADC2_CH8 (GPIO 25)
  • ADC2_CH9 (GPIO 26)

Note: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead, that should solve your problem.

The ADC input channels have a 12 bit resolution. This means that you can get analog readings ranging from 0 to 4095, in which 0 corresponds to 0V and 4095 to 3.3V. You also have the ability to set the resolution of your channels on the code, as well as the ADC range.

The ESP32 ADC pins don’t have a linear behavior. You’ll probably won’t be able to distinguish between 0 and 0.1V, or between 3.2 and 3.3V. You need to keep that in mind when using the ADC pins. You’ll get a behavior similar to the one shown in the following figure.

Download our Free eBooks and Resources

Digital to Analog Converter (DAC)

There are 2 x 8 bits DAC channels on the ESP32 to convert digital signals into analog voltage signal outputs. These are the DAC channels:

  • DAC1 (GPIO25)
  • DAC2 (GPIO26)

RTC GPIOs

There is RTC GPIO support on the ESP32. The GPIOs routed to the RTC low-power subsystem can be used when the ESP32 is in deep sleep. These RTC GPIOs can be used to wake up the ESP32 from deep sleep when the Ultra Low Power (ULP) co-processor is running. The following GPIOs can be used as an external wake up source.

  • RTC_GPIO0 (GPIO36)
  • RTC_GPIO3 (GPIO39)
  • RTC_GPIO4 (GPIO34)
  • RTC_GPIO5 (GPIO35)
  • RTC_GPIO6 (GPIO25)
  • RTC_GPIO7 (GPIO26)
  • RTC_GPIO8 (GPIO33)
  • RTC_GPIO9 (GPIO32)
  • RTC_GPIO10 (GPIO4)
  • RTC_GPIO11 (GPIO0)
  • RTC_GPIO12 (GPIO2)
  • RTC_GPIO13 (GPIO15)
  • RTC_GPIO14 (GPIO13)
  • RTC_GPIO15 (GPIO12)
  • RTC_GPIO16 (GPIO14)
  • RTC_GPIO17 (GPIO27)

Learn how to use the RTC GPIOs to wake up the ESP32 from deep sleep: ESP32 Deep Sleep with Arduino IDE and Wake Up Sources

PWM

The ESP32 LED PWM controller has 16 independent channels that can be configured to generate PWM signals with different properties. All pins that can act as outputs can be used as PWM pins (GPIOs 34 to 39 can’t generate PWM).

To set a PWM signal, you need to define these parameters in the code:

  • Signal’s frequency;
  • Duty cycle;
  • PWM channel;
  • GPIO where you want to output the signal.

Learn how to use ESP32 PWM with Arduino IDE: ESP32 PWM with Arduino IDE

I2C

When using the ESP32 with the Arduino IDE, you should use the ESP32 I2C default pins (supported by the Wire library):

  • GPIO 21 (SDA)
  • GPIO 22 (SCL)

SPI

By default, the pin mapping for SPI is:

SPIMOSIMISOCLKCS
VSPIGPIO 23GPIO 19GPIO 18GPIO 5
HSPIGPIO 13GPIO 12GPIO 14GPIO 15

Interrupts

All GPIOs can be configured as interrupts.

Learn how to use interrupts with the ESP32:

Strapping Pins

The ESP32 chip has the following strapping pins:

  • GPIO 0
  • GPIO 2
  • GPIO 4
  • GPIO 5
  • GPIO 12
  • GPIO 15

These are used to put the ESP32 into bootloader or flashing mode. On most development boards with built-in USB/Serial, you don’t need to worry about the state of these pins. The board puts the pins in the right state for flashing or boot mode. More information on the ESP32 Boot Mode Selection can be found here.

However, if you have peripherals connected to those pins, you may have trouble trying to upload new code, flashing the ESP32 with new firmware or resetting the board. If you have some peripherals connected to the strapping pins and you are getting trouble uploading code or flashing the ESP32, it may be because those peripherals are preventing the ESP32 to enter the right mode. Read the Boot Mode Selection documentation to guide you in the right direction. After resetting, flashing, or booting, those pins work as expected.

Pins HIGH at Boot

Some GPIOs change its state to HIGH or output PWM signals at boot or reset. This means that if you have outputs connected to these GPIOs you may get unexpected results when the ESP32 resets or boots.

  • GPIO 1
  • GPIO 3
  • GPIO 5
  • GPIO 6 to GPIO 11 (connected to the ESP32 integrated SPI flash memory – not recommended to use).
  • GPIO 14
  • GPIO 15

Enable (EN)

Enable (EN) is the 3.3V regulator’s enable pin. It’s pulled up, so connect to ground to disable the 3.3V regulator. This means that you can use this pin connected to a pushbutton to restart your ESP32, for example.

GPIO current drawn

The absolute maximum current drawn per GPIO is 40mA according to the “Recommended Operating Conditions” section in the ESP32 datasheet.

ESP32 Built-In Hall Effect Sensor

The ESP32 also features a built-in hall effect sensor that detects changes in the magnetic field in its surroundings.

Wrapping Up

We hope you’ve found this reference guide for the ESP32 GPIOs useful. If you have more tips about the ESP32 GPIOs, please share by writing a comment down below.

If you’re just getting started with the ESP32, we have some great content to get started:

Thanks for reading.

April 2, 2019


Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

51 thoughts on “ESP32 Pinout Reference: Which GPIO pins should you use?”

  1. Excellent , thanks i have been confused with this issue since there are so m any pins and most have diffrenee possibilities. too many variations to remember them withoutu consulting

  2. Very useful and well presented info. It might be useful to point out that the Adafruit Feather pinouts are not compatible with the similar looking DEVKIT V1 DOIT board. Reference:
    learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts

    • Hi Doug.
      Yes, the Huzza 32 from Adafruit has a slightly different pinout.
      But the guide you refer does a great job explaining each individual pin.
      Thanks for sharing.
      Regards,
      Sara 🙂

  3. Hi,

    This is a fine guide, but my experience shows that not all ADC pins can be used when Wifi is started, for me only ADC0 worked ?

    thanks Peter

    • Hi Peter.
      Thanks for sharing that info.
      As I can remember we only had trouble in one specific project in using GPIO4 for analog reading with WiFi.
      We should try each individual ADC pin with WiFi and see if we have any trouble.
      Thank you
      Regards,
      Sara 🙂

  4. Bit confused! I have a NodeMCU-32S board, which pins are Analog and which are digital?? You say GPIO34-39 are input only – so I could use all the other pins (if setMode is set to OUTPUT) to turn on LED’s etc?

    What about the GPIO’s you say to not use? GPIO6 – 11?

    Chris

  5. Thanks a billion. I purchased my first ESP32 the day I first read about it. I thought my knowledge of the 8266 should get me started. BIG MISTAKE. I ordered 4 of them to begin with, and up until a few weeks ago, they have laid capture in a plastic parts box. At long last I found one project that might work with them, and learned how to get the Arduino IDE to write to them. Well my Frogger try ended up pretty bad, never could get it working right, however I did get it to display, so I guess that is something. That said, I have learned more in the last few minutes reading this page then I knew about this little sports car of devices. Again, thanks billions I shall go on reading the rest of your pages. I knew I had come on something good when I first found your pages a few years ago, and you keep the education going and going.

  6. Great work!.. Is it possible to powering esp32 by external supply? I mean, 5v to Vin Pin and Ground to ground. I’ve tried many ways but it is impossible to me. It just work with USB powering. Thanks in advance.

    • Hi Pablo.
      Yes, it is possible to power the ESP32 using external power supply.
      What exactly are you using to power the ESP32?
      Regards,
      Sara 🙂

      • Hi Sara. I’m using 5v power supply direct to V5 pin but doesnt work. It looks such reboot and never run normal, but if I connnect to usb 1a it works fine. I’ve tried 3 boards and it doesnt work. It is chinese, wrover, most common, v4

          • Hi Pablo.
            That’s the same ESP32 board that we usually work with.
            That very weird.
            It should power up by supplying 5V to the VIN pin. Make sure you’re supplying enough current.
            Otherwise, I have no idea why that is happening.
            Regards,
            Sara 🙂

        • might be a problem with the power supply:

          solution Tantal capacitor 47uF between GND and VCC

          see also:
          arduino-hannover.de/2018/07/25/die-tuecken-der-esp32-stromversorgung/

  7. Hey, I need some kind of help…

    I have a custom design with ESP32. My GPIO0 is held LOW, my EN pin is connected to 3.3v. When I boot, I get the “waiting for download” prompt. However, I always get the famous “Timed out waiting for packet header” error.

    Any help is appreciated 🙂

    • Hi Alex.
      When uploading code to the ESP32, you should press the BOOT button, which is the same of held GPIO 0 to LOW. There are other pins that influence uploading code to the ESP32, such as GPIO2, GPIO12, and GPIO15.
      Take a look at the following article: github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection
      It is very informative when it comes to boot mode selection.
      I’ve never experimented with a custom design with only the ESP32 chip (I’ve just experimented with development boards with the chip), so I’m not aware of other stuff that you may need to pay attention to.
      Anyway, I hope you found the article useful and you can solve your problem.
      Regards,
      Sara 🙂

  8. After days of confusion between many articles and distinguishing the
    PINs name and functions, this article made my day. 🙂
    Many thanks for your well written article.

  9. @ bestware – I think you are mistaken.
    There are indeed two separate I2C interfaces. These are referred to as I2C0 and I2C1.
    See e.g. section 11.4 in the ESP32 Technical Reference Manual – where all the registers for control of the two interfaces are listed.
    You can route the SDA and SCL pins of each I2C interface to any GPIO (which can be output and which is in the correct power domain). Please check the technical reference manual if you are interested in details.
    But as Sara Santos correctly explains in the tutorial, the Arduino Wire Library allows one of the I2C’s to be operated – and only on GPIO 21 and 22.

          • Here is a link to one?

            ebay.co.uk/itm/ESP32-18650-Battery-Shield-V3-ESP-32-Micro-USBWemos-LED-for-Arduino-Raspberry-Pi/292498985534?epid=24006249128&hash=item441a4c523e:rk:1:pf:0&checksum=292498985534af0ace93d18544359998ba8308878450&enc=AQADAAAC8FjVrDbVsZ8oH%2F8PNHtt9VX4%2Fw7FZcmMuqsX8uaFEduVaORNXMCeazS4LEKj6KZlHxIUwmX1v17N9DAobpUqdxVjZ98fBA3dYSriex3x9H0ZPD0NygfPp84ctvIzbJ%2BbzWtZG071XChWAyOm6s0TCSn27%2Bzt2yJn0frZtN3i9mn7V8q94X5tBKS9qorMMDmaAQzM1S18k7Mge13VoQhP88eYTF8y3jWwayxCR8L7f%2BcVGGhJraUHz14JnFDDYJPoCLWAPPH40FjIj3YAX7Z1nLrG%2Fzg6bvPtk8VJBMD2Ozz%2FrHbngt%2FNzoFFL5MYBPHfHk%2F3frz2CqDupRrQYiIoFlHM5ruSLxEGE8TvyqxnBLoAOlkbvIe4FE3Bdbfc%2FgGHcQ4H3jCJAG1yLemonUsnNYCWuS%2FokqKUARurc4djDUabWTHG%2B9mvrbn%2F66S%2BnjIOv8ni%2Ba3Ik%2BwMy8pALql5%2BzKxYnqmyHSe%2BeG5nbeBLzu0jKoNFkiLuRxwsxNUEnrBLug8%2F1ZKZKl%2FPTRpv2QCvFLTGIEHCpECWO5V746H0W6m7%2BvQ5P8sio3qIpVDiOexu54CMg7eyLSQxXbdp3zwbX6wD2%2FpLqjrLC4GEIcyn65O1YhUmWuDeBZUJd3XuvW4jcYXuBwd7IMZkhHGjSHEAN8w8TMF%2FwDj%2BOfDIu0R5I4UqTTpr1kvgVuRi5y5Iv7%2B%2F1aTmlqosMeTQJUrr5jkQcdccwrqlRJwLQMmX2SI5Q%2BrjLh%2FjMM%2B6J7k4yiIt%2ByL7oYtNsns76cjiX90MWO1B1WE98zFiUm3vtTMRZJ4HeGeqen%2FkROx0xzL%2FTQKiTUesXclxEhuKMJWwlal9R6rszHx%2BeaL4sjedyEevb1nro5QdYWA6yqJVIRAI%2FmeLHgylZp0ccPWbLpx%2FUzBw%2BqGb3Cq0sXWcFlQ%2BoQcangeThTD24FyA%2FMgD7UUJJerMpzz6gPq0SihxXSQ%2FhSpOG4hgeOtz12j3hUj%2FeQ5YU4rKAAz

  10. You didnt mention about the UARTS apart from saying there are 3. I read somewhere that UART2 on GPIO 16/17 cant be used, or at least those pins cant be used, and I see no other mention of GPIO16/17 above. Do you know what the story is there ?

    Thanks for a great write-up by the way, I come back to it often !

    • Hi Bob.
      As far as I know, you can use GPIO 17 and 16 as UARTs, as well as GPIO 1 and GPIO 3.
      UART0: (GPIO 1 and GPIO3)
      UART2: (GPIO 17 and GPIO 16)

      UART1: (GPIO 9 and GPIO10) – these are connected to the ESP32 SPI flash memory, so you can’t use them. But, you can use UART1 by defining other pins on the HardwareSerial. Andreas Spies has a great video explaining this: youtu.be/GwShqW39jlE?t=182

      Thank you for your interest in our tutorials.
      Regards,
      Sara

Leave a Comment

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.