The ESP32 chip comes with 48 pins with multiple functions. Not all pins are exposed in all ESP32 development boards, and some pins 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:
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.
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).
Additionally, there are pins with specific features that make them suitable or not for a particular 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 an unexpected behavior mainly at boot. The pins highlighted in red are not recommended to use as inputs or outputs.
|0||pulled up||OK||outputs PWM signal at boot, must be LOW to enter flashing mode|
|1||TX pin||OK||debug output at boot|
|2||OK||OK||connected to on-board LED, must be left floating or LOW to enter flashing mode|
|3||OK||RX pin||HIGH at boot|
|5||OK||OK||outputs PWM signal at boot, strapping pin|
|6||x||x||connected to the integrated SPI flash|
|7||x||x||connected to the integrated SPI flash|
|8||x||x||connected to the integrated SPI flash|
|9||x||x||connected to the integrated SPI flash|
|10||x||x||connected to the integrated SPI flash|
|11||x||x||connected to the integrated SPI flash|
|12||OK||OK||boot fails if pulled high, strapping pin|
|14||OK||OK||outputs PWM signal at boot|
|15||OK||OK||outputs PWM signal at boot, strapping pin|
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-up 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)
Learn how to use the touch pins with Arduino IDE: ESP32 Touch Pins with Arduino IDE
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)
Learn how to use the ESP32 ADC pins:
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 can also set the resolution of your channels on the code and 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.
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)
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
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
The ESP32 has two I2C channels and any pin can be set as SDA or SCL. When using the ESP32 with the Arduino IDE, the default I2C pins are:
- GPIO 21 (SDA)
- GPIO 22 (SCL)
If you want to use other pins when using the wire library, you just need to call:
Learn more about I2C communication protocol with the ESP32 using Arduino IDE: ESP32 I2C Communication (Set Pins, Multiple Bus Interfaces and Peripherals)
By default, the pin mapping for SPI is:
|VSPI||GPIO 23||GPIO 19||GPIO 18||GPIO 5|
|HSPI||GPIO 13||GPIO 12||GPIO 14||GPIO 15|
Learn more about SPI communication protocol with the ESP32 using Arduino IDE: ESP32 SPI Communication: Set Pins, Multiple SPI Bus Interfaces, and Peripherals (Arduino IDE)
All GPIOs can be configured as interrupts.
Learn how to use interrupts with the ESP32:
The ESP32 chip has the following strapping pins:
- GPIO 0 (must be LOW to enter boot mode)
- GPIO 2 (must be floating or LOW during boot)
- GPIO 4
- GPIO 5 (must be HIGH during boot)
- GPIO 12 (must be LOW during boot)
- GPIO 15 (must be HIGH during boot)
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 from entering 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 their 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) 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.
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:
- Learn ESP32 with Arduino IDE
- Getting Started with the ESP32 Development Board
- 20+ ESP32 Projects and Tutorials
- ESP32 Web Server Tutorial
- ESP32 vs ESP8266 – Pros and Cons
Thanks for reading.
173 thoughts on “ESP32 Pinout Reference: Which GPIO pins should you use?”
Thanks, very usefull.
Thank you! 🙂
Really, really useful – thank you…
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
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:
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.
I am absolutely brand new to this whole “trade” I guess I would call it, but I’m trying to get up to speed as quickly as I can to complete a 16 x 16 Led matrix graduation cap for my daughter, but everywhere I’ve looked there is very little or no information on this other than lots of videos that crank out music while showing someone’s finished project in operation. In summary, I have an ESP32 -WHOOM – 32D which is a 5v or 3.5v board with different pinouts than what I’ve seen here, so I was wondering if anyone has the same board ?
I think this is the pinout for that board: https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2018/08/esp32-pinout-chip-ESP-WROOM-32.png
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 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.
I think you can only use A1.. while WiFi is used. It’s a design problem of the ESP32 chip.
Thank you for sharing that.
We definitely need to test that situation.
could you share with us the results of your test about using ADC pins while using WIFI ?
I ran a crude test with wifi in use and the commented out lines did not work.
analogRead( 36 );
analogRead( 39 );
analogRead( 34 );
analogRead( 35 );
analogRead( 32 );
analogRead( 33 );
//analogRead( 25 );
//analogRead( 26 );
//analogRead( 27 );
//analogRead( 14 );
//analogRead( 12 );
//analogRead( 4 );
//analogRead( 0 );
//analogRead( 2 );
//analogRead( 15 );
One more a real Rui-Tutorial !! Very, very useful for my projects.
Many thanks to Sara and Rui
Thank you so much for your support!
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?
yes you can use any pin from 0-33 as outputs. you could also use gpio 6-11 but it would interfere with the spi communications between the esp’s processor and it’s flash memory and it is thus a bad idea.
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.
Thank you so much for your kind words!
I’m really glad you find our tutorials helpful.
If you want to learn more about the ESP32 you can take a look at our ESP32 projects repository (it’s free):
We also have a course about ESP32, take a look at the contents here:
Thank you and good luck with your projects! 🙂
Thanks for the nice overview. I have a question about pin current ratings. You declare 12 and 6 mA in your article which can also be found at other web pages. However if I read the datasheet correctly (https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf) it should be 40 and 28 mA. Where are your numbers from?
You are right.
We’ve update the post.
Thanks for letting us know.
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.
Yes, it is possible to power the ESP32 using external power supply.
What exactly are you using to power the ESP32?
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
It is like Aliexpress – DOIT ESP32 DEVKIT V1 Board (Wi-Fi and Bluetooth). Thanks for your kindly response
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.
might be a problem with the power supply:
solution Tantal capacitor 47uF between GND and VCC
Thanks, very usefull.
There is ONE I2C-interface only! Yes, 2 lines are used to provide one I2C-bus only.
Anyway, very useful overview!
Thank you for making that clear.
Very good, congratulations !
Thank you 🙂
i want to use esp wroom32 module in my custom pcb,how to do it.can you please help me
At the moment, we don’t have any project/tutorial about that subject.
We have a project in which we build a shield for the ESP32 board. But I don’t think it is what you’re looking for:
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 🙂
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.
Not sure if this is still relevant, but I encountered a similar issue in my custom PCB project with the ESP32-WROVER-B. Datasheet is
I hit two snags:
– using a strapping pin for my SPI display. Pay special attention to all pins mentioned in section 2.3 “Strapping Pins”. They all are trouble. So other than IO0 (for boot mode) I did not connect any of them
– missing pullups on #EN and IO0 and missing capacitor on #EN. The datasheet is a bit sneaky about these. The example schematic doesn’t mention the pullup for IO0 and the capacitance for #EN is 0.2uF (as there are two circuits mentioning that). I experimented and even use 0.3uF for my capacitor on #EN.
With this setup, I got the board to reliably flash using esptool.
My project can be found here: github.com/deets/deets-fpv-vtx-scanner
You can use KiCad 5 to see the schematic that I verified works for me.
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.
Thank you! 🙂
@ 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.
how can I connect ESP32 WROOM to 18650 (3.7 V) battery ?
You can use a Low DropOut Regulator (LDO) to convert the 3.7V to 3.3V and power the ESP32 through the 3.3V pin.
You can use the MCP1700-3320E LDO, for example.
I hope this helps.
You can also get an 18650 ‘shield’ which has an LDO fitted and offers a 3v output? Cost me 2 UKP from eBay
I’m not familiar with that “shield”, but with what you’ve described, it seems a good fit.
Here is a link to one?
Yes. That should work.
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 !
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.
Interestingly I was just doing a small ESP32 Arduino project and I couldn’t toggle GPIO 16 or 17 in my code. It took a while to realize what was going on, but I eventually moved to different pins. After that I did some digging I discovered that pins 16 and 17 are used by PSRAM on the WROVER modules.
Pin 16 is used as the chip select for PSRAM, and 17 is used for the clock signal. It would probably be good to note this above.
You can see it on the schematics on the WROVER datasheet: https://www.espressif.com/sites/default/files/documentation/esp32-wrover_datasheet_en.pdf
Thanks for sharing that.
Can you share what your project does?
I’ve used GPIO 16 successfully with projects that involve taking a photo (I guess this doesn’t use PSRAM). However, if trying to video stream in high-resolution settings, it might crash because it needs to use PRAM.
I can give you the broad strokes. I was prototyping a industrial controller using a ESP32 using a ESP32 DevKitC — which uses a WROVER module and not a WROOM). I needed multiple serial ports, I2C, SPI, and assorted GPIO. Hence the conflict with 16&17
I thought you were referring to the ESP32-CAM, my mistake.
Merci beaucoup !
Thank you very much
You’re welcome. 🙂
Randomnerdtutorials, you guys are great. Your articles are very very much helpful.
GPIO 5, 12 (MTDI) and 15 (MTDO) are strapping pins, i.e. not OK to use during boot.
GPIO 12 must be low (0) and GPIO 5 and 15 high (1) during boot.
Thanks for the excellent overview.
Small remark: GPIO13 seems to be missing in the list of GPIOS
Thanks for noticing.
I’ve added GPIO 13 now.
Hello all ,
RTC GPIOs… What is RTC is it REAL TIME CLOCK..or something else?
Yes, RTC stands for Real Time Clock in this case.
Can you give some explanation RTC in context with GPIO
I am not able to find any information.
Basically, these GPIOs are routed to the RTC low-power subsystem can be used when the ESP32 is in deep sleep. You can use the RTC GPIOs to wake up the ESP32 from deep sleep (read ESP32 External Wake Up): https://randomnerdtutorials.com/esp32-external-wake-up-deep-sleep/
thank you, this article is very useful
You’re welcome! Thanks for reading!
Many thanks. Your article would have saved me hours if available earlier!!! 👍
I am having problems with analogRead (). It does not work.
I need to read the value of the sensor. Thank you
Can you use a different GPIO? Any of the following GPIOs should be safe to use with Wi-Fi + AnalogRead():
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)
GPIO 15 (the one you’re using belongs to ADC2 and any ADC2 pin causes some issues when used with Wi-Fi).
Try with GPIO 33 for example and let me know your results.
I have a ESPWROOM-32 module, but it has 38 pins. What pin layout do I use? Top 3.3V on left, GND on right and 5V bottom left and CLK on right. Putting the USB connect at the bottom. Help?
To use the pinout, please check the labels on the board and then compare with the pinout that we have.
Usually, in different boards, the same labels refer to the same GPIO.
For example, the pin marked as RX2 on the silkscreen of the board is GPIO16. D2 is GPIO2 and so on.
I hope this helps.
Hi, This is very good tutorial and it is so helpful.
Thankyou so much 🙂
You’re welcome! Thanks for reading
hi Rui and Sara,
Thanks for providing the great website. I wonder if you know how to flash a naked esp32 chip, not the module? I am working on a customer board which doesn’t have USB port.
Unfortunately, we’ve never tried it yet.
However, this can help you figure out what pins need to be high and low in order to enter boot mode: https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection
Thanks Sara. I am trying a method and will have a look at the reference you directed.
Super it is very useful. Thanks a lot.
Thank you 🙂
It was a great description. Could please tell me which pins can’t be used when using WIFI.
As mentioned in the article:
“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.”
I have exactly the board of this tutorial with 36 pins.
I connected GPIO16 and GPIO17 to a standard optocoupled relay board and when the asyncwebserver sends a web page to the client the relays drive crazy.
Avoid those pins.
hi, i have a DOIT ESP32 devkitV1(clone) –
pinout seems to match the real doit devkitv1 🙂
in some of the info i have read on the internet it has a onboard Temperature sensor,
yet i dont seem to be able to find examples that use it? or what specific sensor it is? – i have used the Hall sensor onboard fine.
is this temp sensor accessible, and worth the effort (will it just show me how much my board has warmed up, or will it give me usable environment data?)
ps — is there a way (software) to use the RED power led?? i can use the BLUE one, LED_BUILTIN (its gpio2) but can i use the power led?
Hi, i was wondring, can i use other GPIO as CS pin for SPI
Yes, you can use.
You just need to define that on your code.
A really good guide, thanks
I have only one question, with the devkit (30 gpio), how can I take a manual RESET button outside? Thanks again 🙂
You can use the Enable pin.
Read the section about the enable pin in the post.
I wanted to take the time to thank you for these series of articles. I have a number of these generic AliExpress/Aokin ESP-WROOM-32 boards and while I was able to use them without much trouble, it always bothered me that I didn’t have any “solid” documentation for them. Now I know exactly what I am dealing with.
Again, Thank You…
I went through a similar process figuring out the Adafruit Esp32 Huzzah Feather board, and created my own reference chart. If it’s useful to anyone, help yourself:
Very useful, before creating any new project i always keep this page in front of me. Thanks
Update GPIO15 function for Enabling/Disabling Debugging Log Print over U0TXD During Booting very useful for final deliverable product
This particular article is for the 36 pin kit… Do you have the same breakdown of the 30 pin kit?
Hi. The pinout is basically the same, but doesn’t include GPIOs 6 to 11.
Hello can u help me?
i’m using esp32 for my project and i using pressure sensor .
the output of the sensor, i using GPIO36 but it doesn’t work..
Hi Eva. What is the sensor that you’re using?
i’m using MPX5700AP
Thank You for this excellent resource! Random Nerds is definitely helping to educate and expand this community’s capabilities. ☺
Thank you so much for your feedback.
Very useful resource.
Many thanks from France.
This helped a lot, thank you.
Very informative article indeed, thank you.
I am planning to do my own home automation project using ESP32-WROOM-32U module.
I simply don’t need all the IO pins, and am planning to breakout only the pins I need to minimize the PCB footprint (IC2 and IO 16-27).
I used a ‘Test board Burn Fixture Programmer’ to upload the sketch, and all future updates should be OTA updates. Hence, I don’t need to mess about with the boot mode once the module is soldered to the PCB.
The question is, do I have to connect any of the Strapping Pins to anything if I want a normal boot and occasional OTA updates?
Thank you for your comment.
I think you get a clear answer if you read this guide: https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection
I hope this helps.
Thanks for your help Sara.
I have read the link you provided, and found it very informative, but could not find a direct answer to my question.
Through trial and error, I found that providing 3.3V and GND did not work, but by using a pullup resistor on pin 3 (EN pin), the ESP started normally and I could flash it over the air without having to press anything or short any pins. Later I found this information already provided in the datasheet on page 15.
Thanks for sharing it. I wasn’t aware of that.
I need libraries Esp32 devkit v1 36pin in fritzing
hello thank you for the article, you what pins do I have to use to connect the ultrasonic sensor?
With the ESP32, you can use any GPIO that can be input for the TRIG pin and any GPIO that can be output for the ECO pin.
For example, you can use GPIO 26 and 27.
Thank you very much for this informative article …but what about the librarys that works with arduino, are all compatible with the ESP32.
It depends on the library.
Many libraries are compatible.
In DOIT dev kit GPIO21 and GPIO22 are used by I2C bus. Why those pins are not mentioned as I2C interface in the bare module, in the case if I decide to develop my own custom board.
In fact, with the ESP32 you can choose almost any pin to act as I2C.
However, when using Arduino IDE libraries, it chooses GPIO 21 and GPIO22 as default I2C pins.
I have a project developed on TTGO T7 Ver 1.0
It is a simple keypad 3X4 reader, plus and RFID decoder (get RFID data from TX of RDM6300 and extract the ID of the card) Match the keyboard input with the one store on EEprom, match the RFID with the stored on EEprom and if the match send an encrypted signal (like Go) through Bluetooth to a slave identical TTGO chip.
I wonder if the project can work if i try to use a regular ESP32 NodeMCU.
TTGO chips are only in China and very hard to get through Ali. ESP32 is easier to buy , even from Amazon. This is my problem.
Does the VIN pin also work as a 5V output when ESP board is powered from USB? Mine doesn’t but I’ve seen you do it on your tutorials…
Yes, the 5V pin can be an output when the board is powered from USB.
Thanks for the quick reply. Problem turned out to be a mislabeled silkscreen on my board, marking as ground the CMD pin.
You guys are the best!
Lots of great info on this page! Thank you.
Thank you, very useful!
I migrated my latest project (self balancing gyrosopic two wheeler) from Arduino Uno to ESP32 because the processor is just too slow. Loop() runs in less than a millisecond. Wow.
ESP32 PICO kit V4 require manual RESET after powering off.
After powering ON the device, the software doesn’t boot up automaticully. I have to press the reset button. This means that the PICO device is completely unusable as Alarm Device, due to a failure in automatic restart after power break down! Googling for solutions bring me up to install a 4.7 k resistance between +3.3V and IO0 pin. This works only if the powerOFF take place for severals seonds!
Is there an other solution to activate the automaticully StartUp after a power faillure ?
thank you very much for this realy useful reference guide for the ESP32 GPIOs .
I have one DS18B20 connceted to the ESP32 GPIO 14 and sometime, the ESP32 has a problem to conect to the WiFi.
Could the problem be in the badly selected GPIO, as mentioned above?
I’m a bit confused about the “Input only” pins as well. I did a board and used one of them (IO34) as an output, didn’t work of course.
The original ESP32 WROOM Pinout picture (also on top of this article), doesn’t mark them as “input only”.
they have a PWM “snake line”, doesn’t make sense for an input only.
GPIO stands for General Purpose Input OUTPUT… how can this be Input only???
1) Any chance for an explanation about the UART pins or include this link to this webpage: [https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/]
2) It would also be super helpful to have an example of UART being used, maybe using it to show two ESP32s communicating via UART0 and UART2.
3) Some explanation on SoftwareSerial or a link to this page: [https://www.arduino.cc/en/Reference/softwareSerial] and a URL to as an example [https://randomnerdtutorials.com/sim900-gsm-gprs-shield-arduino/#more-42170]. I think SoftwareSerial is no longer being included in IDE because I just installed latest clean version of Arduino IDE 1.8.13 Windows and I get an error ‘include SoftwareSerial.h not found’ (or I am doing something wrong as something isn’t making sense to me!) when I use code like yours above.
Sorry if any of these things have already been done, I tried your website search for “UART2” and get no results.
Any idea why float batteryLevel = map(analogRead(12), 0.0f, 4095.0f, 0, 100); seems to give back 100 no matter how bad the battery is?
Hi Sara and Rui,
I’m new to ESP32, and found your posts extremely helpful. Thanks.
I’m preparing a project to be used with Home Assistant, but I have three questions regarding the pinout:
1- You mention that if my project uses WiFi (which is the case) I should not use ADC2. So, is Wifi killing 10 of my GPIO? I’m a little confused, since many ADC2 are green on your table. If I exclude all ADC2 and all non-recommended pins, I would end up with just two “touch” pins – 32 and 33. Is that so?
2- If I load the ESP32 with 2 touch pads, 4 sensors (thermistor, LDR, humidity, PIR) on GPIO 33, 32, 35, 34, 39, 36 and 10 pulse keys on GPIO 23, 22, 1, 21, 19, 18, 5, 17 and 16 do you think it would work?
3- Do you have similar pinout recommendations of the ESP32-S2?
Thanks in advance.
1- What we mean is that you can’t use ADC in the ADC2 pins when using wi-fi. You can use those pins as standard input or output or touch pins, and they will work fine. They won’t work properly as ADC pins.
2- I think those pins will work, but it is always better to test everything before making any permanent connections.
3- At the moment, we don’t have any articles for the ESP32-S2.
I hope this helps.
So I tried the tutorial and sent you a message about things that didn’t work but never got an answer. Basically one issue was in the code const char had to be changed to char, also no matching function for call to HttpClient http
Where did you post your question?
Since you are one of our customers, you can post your issues in the RNTLAB forum.
It is easier for me to follow your issues there:https://rntlab.com/forum/
What is the meaning of ADC(PA) for gpio36 and 39.
ADC is clear (Analog-Digital-Converter)
But what stays PA for?
Are there any of the GPIO pins that can be read as a nibble or a byte for the purpose of reading jumpers or a switch? Thanks.
Great write up and very helpful reference page, I have it bookmarked. One thing I want to mention is that you list the absolute maximum per GPIO current draw as 40mA and I’m not so sure this is exactly correct. I see where you are getting this value from, the “output drive strength” on page 43 of https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf (and page 53 lists the configurable values), but after doing a lot of searching for this value I came across the following thread which claims the maximum current draw is 12mA per GPIO and goes on to explain what “output drive strength” means. I found it enlightening.
I don’t know where he gets the number 12mA per GPIO from as I myself don’t see any reference in any data sheet as to the maximum current draw per GPIO. The only thing I see is a cumulative current draw of 1200mA on page 42 of the above referenced datasheet. So at this point I’m left taking his word for it and erroring on the side of caution. And if this is a maximum value, I would guess that running at 60% of this value would be about where you would want to be for stability and longevity.
I am also developing projects and industrial applications on 8051, AVR, ARDUINO and Raspberry PI.
This info is better for me to develop the projects in feature on ESP32.
Once again thank you.
Really detailed Document for everybody!
Hi Great write up. I am using a ESP32 where EN pin is connected to 3.3v.on switch it is pulled down to ground. The problem is the ESP32 does not boot unless I press the EN button.
May you point what am I missing?
I think this might help:https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection
Hi, I see that there are 2 I2S interfaces available, but no specific pins showed on the pinout. Does it mean that any 3 pins can be used for I2S?
That’s missing in our tutorial.
For I2S, you can use GPIOs 25 and 26, marked as DAC1 and DAC2 on the image pinout.
For I2S we need MCLK, LRCLK, BCLK, Data IN, and Data OUT. I’m curious if you had specific recommendations for these. Of course, I can verify myself. 🙂
It is mentioned that GPIO 37 and 38 can be used as ADC pins. Where those pins located in DEVKIT 1 board and ESP32 chip?
Those are not available on the development board. Only on the ESP32 chip.
Hi and thanks a lot for this work, just a quick point I came up with on a recent project. GPIO16 and GPIO17 could be used for internal flash memory purpose (cf. ESP32-PICO-D4, ESP32 datasheets) so they can’t be used normally.
Pratically I get stuck on reboot behavior when pluging a TM1637 DIO and CLK to thos pins on TTGO-Micro32 based boards.
May be nice to mention this somewhere 😉
Hi, really useful information. I’ve found an edge case! Would be great for you to add a caveat to your article if possible.
GPIOs 13 and 14 CANNOT be used without any issues. If there’s an SD card present using the standard GPIOS 18,19,23,26 and something is connected to GPIOs 13 and 14, the ESP32 will refuse to boot until the SD card is removed.
If anyone is aware of a solution to this, I’d be happy to hear about it!
Thanks for sharing.
I didn’t know about that.
What ESP32 board model did you use?
Very useful. I use the page constantly to keep an eye on the ports I’m using in a design. Might be useful to add info about the presence of the embedded CAN controller. It is said to be compatible with the SJA1000 CAN controller. The default pins are GPIO5 (CAN TX) and GPIO4 (CAN RX). Of course you’ll still need a CAN transceiver to connect to a CAN bus. The transceiver must be 3.3V technology like MAX3051 or SN65HVD23x unless you’re willing to mess with level shifters.
For details see
Earlier versions of the ESP32 have the limitation that the minimum CAN bit rate is 25 kb/s. As of ESP chip version 2, the bit rate can be as low as 12 kb/s (Espressif made changes to the clock which drives the CAN controller).
Greetings from Belgium,
Je dispose d’une ESP32-CAM et je souhaite modifier l’UART pour gagner en fluidité. Comment faire ?
First of all, thank you for the detailed information you have given about the esp32 pinout.
I have question about strapping pins. I have to connect GPIO15(MTDO) to GND with my pull down resistor(30kOhm) to disable a few elements initially passive.
Will this be a problem for booting? I read section of strapping pins of dataheet. But I did not understand. In my opinon it is not enough information.
At finally Is silencing the boot message an obstacle to boot? Boot message is not important for me. Can I connect this pin with pull down resistor?
I’m asking the same question for GPIO 5.
I have a board “NodeMCU-ESP-S3-12K” but the excellent Sara and Rui + internet helped. Thank you and a nice day.
Hi, very usefull.
Thank you very much
thanks for the write up. If I want to power the esp32 with external power (so no usb connection), my chip has two 5v pins, two 3.3v pins and two grounds. Its the wemos chip with the oled display. Where would I apply the voltage to and what voltage to apply? I assume applying 3.3 to one of the 3.3 would work, but which one? and I assume could use any ground pin for negative. I think applying 5v to one of the 5v pins would also work, but again, which pin? Is there one that is input power and one for output? Thanks for your input in this question
You can power it with 3.3V on the 3.3V pins (any of those pins) or with 5V on the 5V pins (any of the 5V pins).
You can also choose the GND pin.
After powering it with 3.3V on one pin, the other 3.3V pins will output 3.3V.
I hope this is clear.
Great reference ! But I have a problem using the HSPI bus on the TTGO T-Display Board(ESP32).
I am trying to interface a VS1053 mp3 decoder using the HSPI on the TTGO (the VSPI is used for the display). Apparently nobody has ever done this before, or I can’t find where, after an exhaustive search.
Here is my code snippit:
// initialize SPI bus;
// Wiring of VS1053 board
//VS1053 player(VS1053_CS, VS1053_DCS, VS1053_DREQ);
VS1053 player(33, 32, 15);
void setup () //=========== Settup ======================
// initialize SPI HSPI bus
mySPI.begin(25, 27, 26, 33); // clock,MISO,MOSI,CS
After many tries … nothing works! Any suggestions greatly appreciated
Thanks for making this page. I refer to it all the time when planning which pins to use in a design.
I’ve been trying to understand what goes on with the pins that are indicated as emitting PWM on start-up. What’s the nature of that PWM? Is it some fixed frequency and duty cycle, is it configurable, or something else? Do you have any info about that?
Thanks for the article. Is it true that pin 5V on esp32 can be given a voltage of 5 to 12 volts?
Esp32 can work with CD74HC4067?
Hi, thanks for such a useful article. I always have this open when I work with the ESP.
However, I stumbled over some points.
First of all the link
found on your site under Boot Mode Selection documentation.
According to https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/boot-mode-selection.html
Next you have the section Strapping Pins but this has at least some information no use in the overview of all GPIOs found there is listed that the GPIO2 can be used without restriction as input and output in the Strapping section is then but that it could lead to problems with the wiring of this GPIO because over it the boot mode is set.
With me this error has led to a layout error and a longer troubleshooting.
But maybe this is only a problem if you use the ESP32 stand alone without a develepmont board. Would be great if you would check this and adjust the article if necessary.
I’m sorry for the issue it might have caused you.
I added a few extra pieces of information to the article about that.
Thanks for the updated link.
I have a ESP32 devkit 30 pin version board. I uploaded some code on it which works fine. But after that something went wrong and the USB onboard chip seems to have got destroyed/damaged so the board is no more detected on Arduino IDE as a com port. The code previously loaded still works however. Can you please suggest a way to upload a newer version of my code (may be by using a USB to TTL board and TX-RX pins on the ESP32)? I searched on internet but could not find any clearly mentioned instruction set to upload code using Arduino IDE into the ESP32 devkit 30 pin version with damaged USB port. Any suggestion/guidance will help me make this board usable with the required code uploaded into it. Thank you very much.
Anyone can please help on this specific question? Thank you.
Whilst I cannot give you exactly what you are looking for, I can share a similar experience and indicate how far I got with it.
I was using an Arduino Mega 2560 R3 and regularly updating the code during an ongoing development ( still ongoing ! ). I suspect there was too much ‘Touch Current’ thru either my PC Power Supply or separate Arduino PSU. This indicates a common but annoying lack of insulation resistance thru the 240V mains power supply. This would sometimes result in more than just a ‘Bing Bong’ when plugging the Arduino in ( blanking of monitor, loud clicks in speakers etc ). I often have several projects running concurrently and need to swap things over frequently.
Anyway, the Arduino had a 16U2 USB interface and it stopped working similar to how you describe. To be precise, it is still recognised by the PC when plugged in and more importantly by ‘Device Manager’ under Windows, but will not upload newly compiled sketches ( times out without any Arduino LED activity – TX & RX on a Mega ). I still had another Mega 2560 R3 board and that was still fine.
So I put out a question on Facebook ‘Arduino for Beginners’ group on 4th January 2023 beginning ‘I seem to have a dead….’ etc. I ultimately received a reply form another, more experienced user. It told me that the user had experienced something similar and had successfully used Atmel’s ‘Flip’ software to reprogram his board. He could not provide the original link he had used, but provided another similar internet article.
I followed this and was beset by problems, some links to required firmware downloads etc., were dead and I spent a long time ( a day ? ) trying to solve this.
I did ultimately succeed in getting all the required items together, but if you get a missing dll error, look first within the files you have, it is NOT necessary to trawl the internet for .dll files as suggested. Ultimately, I got the correct firmware and Flip running, but it could not see my board. However, I eventually explored the Flip software, which even has an ‘Emulate Mode’ built in and risked tried known working Arduino UNOs and other Mega 2560 R3s, but they were not seen by the Flip software either.
Since Device Manager on that ( Win 7 ) PC could see all the boards, including the faulty one, I concluded that something ‘new’ about either Windows 7 or a subsequently loaded ( Microsoft Update ? ) version of the USB drivers, was preventing communication. Looking at the good quality of Flip and its documentation, I noticed an Atmel supplied USB driver update in the installation or installed software file structure. I’m not sure it loaded properly although it appeared to, even though I tried to purge newer copies off the PC. I did not succeed in reflashing my Mega. However, Windows 2000 and XP were the Atmel recommended operating environment for running Flip, so I may yet dig out an old laptop I have somewhere and try that ! I have since bought 2 x Mega 2560 and 2 x Mega Pro for £70 total to continue my projects, BUT, I bought them with CH340 USB interfaces as I get the impression the 16U2 versions are prone to this problem. I have archived all files I downloaded, but you should not have difficulty finding them yourself.
Please note, there is a program called ‘Deauther’ that requires the use of some of the software described for this repair, to similarly upload an image of a portable WiFi network attack device that can run on a ‘watch’ based ESP32 to disrupt networks. Perhaps some of the broken links to the required software have been taken down to prevent this spreading so easily ?
I wish you every success with this one – Noel
GPIO16, GPIO17 are not available on certain variant
Love this page, use it all the time! Can you please update for ESP32-c3. Many thanks.
I’ll order one and take of care of the pinout guide soon.
The pinout is similar to the esp8266mod and the footprint is the same. Many are using it as a esp32 replacement for the 8266mod.
It might be good to cross-reference it on the 8266 page also: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
I want to control the Built in led from an AI Thinker ESP32-CAM i have. I want to use it when i take a photo and send by email
To control the led i use the GPIO 4 as a digital Output.
I can turn the led ON (an intense light). And i can turn the led OFF.
Still when it is off. It is not all off. There is still a very small light coming out of the builtin led.
I want the led totally off, so it does not consume more current from the battery.
I also use my project in deep sleep, so this issue is important so that it does not consume more battery.
May i use a pull down resistor on the GPIO 4???
Does ESP32 have internal Pull downs resitors?
Thanks in advance.
Thanks for the article. However, I have about 10 of these ESP32 units and they all have either 30 pins, like your photgraph above, or 38 pins. I would add that there are some newer boards with different USB chips on: CH340, 2102 & 9102. The 2102 chip boards need you to press the BOOT button to get them to upload a sketch. The others seem to manage by themselves. Also, some of them have different USB sockets too. I don’t like the USB ‘C’ format, the engagement of the plug is much less precise with the Micro USB. Sometimes, the USB C type will disconnect and reconnect at random when moved. I would also avoid those without two onboard LEDs. Some only have a Power LED and not a programmable LED_BUILTIN. I load ‘Blink’ to test my new boards and of course that won’t work !
If a pin is multiplexed. How to I program a pin to disable both TOUCH2 and ADC1 but enable GPIO2?
I love all your articles, its such a use full resource! Thanks a lot for that!
According to the official datasheet on the esp32, there are only 5 strapping pins. On page 21 there are IO12, 15, 0, 2, 5 listed, you added the extra IO4! Is it possible, this is not correct?
Here is the link to the datasheet: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
I followed this documentation: https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/boot-mode-selection.html#boot-mode-message
hello I have a question about the GPIO 25 and GPIO 26
what is the EMAC_RXD0 and EMAC_RXDI ?
I am working in a project and I am using 9, 10 & 11 GPIOs as outputs connected with a tranisistor, LED indicator and relay. In above information your recommendation is not use this pins as output or input because they are connected to the integrated SPI flash, If I decide to use them, what would be the consequences or why I couldn’t use them?
If you use those pins, the code running on the ESP32 will probably crash.