{"id":72084,"date":"2019-10-02T09:34:04","date_gmt":"2019-10-02T09:34:04","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=72084"},"modified":"2024-10-24T14:18:45","modified_gmt":"2024-10-24T14:18:45","slug":"esp32-pinout-reference-gpios","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/","title":{"rendered":"ESP32 Pinout Reference: Which GPIO pins should you use?"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The figure below illustrates the ESP-WROOM-32 pinout. You can use it as a reference if you&#8217;re using an <strong>ESP32 bare chip<\/strong> to build a custom board:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"612\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?resize=1200%2C612&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Pinout chip ESP-WROOM-32\" class=\"wp-image-75258\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?w=1401&amp;quality=100&amp;strip=all&amp;ssl=1 1401w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?resize=300%2C153&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?resize=768%2C392&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/esp32-pinout-chip-ESP-WROOM-32.png?resize=1024%2C523&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> not all GPIOs are accessible in all development boards, but each specific GPIO works in the same way regardless of the development board you\u2019re using. If you\u2019re just getting started with the ESP32, we recommend reading our guide: <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-esp32\/\" target=\"_blank\" rel=\"noreferrer noopener\">Getting Started with the ESP32 Development Board<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Pinout Reference: Which GPIO pins should you use?\" class=\"wp-image-72107\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">ESP32 Peripherals<\/h2>\n\n\n\n<p>The ESP32 peripherals include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-adc-analog-read-arduino-ide\/\">18 Analog-to-Digital Converter (ADC) channels<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-spi-communication-arduino\/\">3 SPI interfaces<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-uart-communication-serial-arduino\/\" title=\"\">3 UART interfaces<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-i2c-communication-arduino-ide\/\">2 I2C interfaces<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-pwm-arduino-ide\/\">16 PWM output channels<\/a><\/li>\n\n\n\n<li>2 Digital-to-Analog Converters (DAC)<\/li>\n\n\n\n<li>2 I2S interfaces<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-touch-pins-arduino-ide\/\">10&nbsp;Capacitive sensing GPIOs<\/a><\/li>\n<\/ul>\n\n\n\n<p>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 \u2013 you just need to assign them in the code. This is possible due to the ESP32 chip\u2019s multiplexing feature.<\/p>\n\n\n\n<p>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 <a href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 DEVKIT V1 DOIT board<\/a> with 36 pins \u2013 the pin location can change depending on the manufacturer).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"538\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?resize=750%2C538&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 DEVKIT V1 DOIT board with 36 pins Pinout\" class=\"wp-image-72102\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?resize=300%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<p>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. <\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<figure class=\"wp-block-table rnt-responsive-table\"><table><tbody><tr><td><strong>GPIO<\/strong><\/td><td><strong>Input<\/strong><\/td><td><strong>Output<\/strong><\/td><td><strong>Notes<\/strong><\/td><\/tr><tr><td><strong>0<\/strong><\/td><td><span class=\"rnthl rntcyellow\">pulled up<\/span><\/td><td><span class=\"rnthl rntcyellow\">OK<\/span><\/td><td>outputs PWM signal at boot, must be LOW to enter flashing mode<\/td><\/tr><tr><td><strong>1<\/strong><\/td><td><span class=\"rnthl rntcred\">TX pin<\/span><\/td><td><span class=\"rnthl rntcyellow\">OK<\/span><\/td><td>debug output at boot <\/td><\/tr><tr><td><strong>2<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td>connected to on-board LED, must be left floating or LOW to enter flashing mode<\/td><\/tr><tr><td><strong>3<\/strong><\/td><td><span class=\"rnthl rntcyellow\">OK<\/span><\/td><td><span class=\"rnthl rntcred\">RX pin<\/span><\/td><td> HIGH at boot <\/td><\/tr><tr><td><strong>4<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>5<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td>outputs PWM signal at boot, strapping pin<\/td><\/tr><tr><td><strong>6<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>7<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>8<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>9<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>10<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>11<\/strong><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td><span class=\"rnthl rntcred\">x<\/span><\/td><td>connected to the integrated SPI flash<\/td><\/tr><tr><td><strong>12<\/strong><\/td><td><span class=\"rnthl rntcyellow\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td>boot fails if pulled high, strapping pin<\/td><\/tr><tr><td><strong>13<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>14<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td>outputs PWM signal at boot<\/td><\/tr><tr><td><strong>15<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td>outputs PWM signal at boot, strapping pin<\/td><\/tr><tr><td><strong>16<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>17<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>18<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>19<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>21<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>22<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>23<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>25<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>26<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>27<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>32<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>33<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><\/tr><tr><td><strong>34<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><td><span class=\"rnthl rntcyellow\">input only<\/span><\/td><\/tr><tr><td><strong>35<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><td><span class=\"rnthl rntcyellow\">input only<\/span><\/td><\/tr><tr><td><strong>36<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><td><span class=\"rnthl rntcyellow\">input only<\/span> <\/td><\/tr><tr><td><strong>39<\/strong><\/td><td><span class=\"rnthl rntcgreen\">OK<\/span><\/td><td><\/td><td><span class=\"rnthl rntcyellow\">input only<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Continue reading for a more detail and in-depth analysis of the ESP32 GPIOs and its functions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Input only pins<\/h3>\n\n\n\n<p>GPIOs 34 to 39 are GPIs &#8211; input only pins. These pins don&#8217;t have internal pull-up or pull-down resistors. They can\u2019t be used as outputs, so use these pins only as inputs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO 34<\/li>\n\n\n\n<li>GPIO 35<\/li>\n\n\n\n<li>GPIO 36<\/li>\n\n\n\n<li>GPIO 39<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">SPI flash integrated on the ESP-WROOM-32<\/h3>\n\n\n\n<p>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&#8217;t use these pins in your projects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO 6 (SCK\/CLK)<\/li>\n\n\n\n<li>GPIO 7 (SDO\/SD0)<\/li>\n\n\n\n<li>GPIO 8 (SDI\/SD1)<\/li>\n\n\n\n<li>GPIO 9 (SHD\/SD2)<\/li>\n\n\n\n<li>GPIO 10 (SWP\/SD3)<\/li>\n\n\n\n<li>GPIO 11 (CSC\/CMD)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Capacitive touch GPIOs<\/h3>\n\n\n\n<p>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 <a href=\"https:\/\/randomnerdtutorials.com\/esp32-touch-wake-up-deep-sleep\/\">wake up the ESP32 from deep sleep<\/a>.<\/p>\n\n\n\n<p>Those internal touch sensors are connected to these GPIOs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>T0 (GPIO 4)<\/li>\n\n\n\n<li>T1 (GPIO 0)<\/li>\n\n\n\n<li>T2 (GPIO 2)<\/li>\n\n\n\n<li>T3 (GPIO 15)<\/li>\n\n\n\n<li>T4 (GPIO 13)<\/li>\n\n\n\n<li>T5 (GPIO 12)<\/li>\n\n\n\n<li>T6 (GPIO 14)<\/li>\n\n\n\n<li>T7 (GPIO 27)<\/li>\n\n\n\n<li>T8 (GPIO 33)<\/li>\n\n\n\n<li>T9 (GPIO 32)<\/li>\n<\/ul>\n\n\n\n<p><strong>Learn how to use the touch pins with Arduino IDE:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-touch-pins-arduino-ide\/\">ESP32 Touch Pins with Arduino IDE<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Analog to Digital Converter (ADC)<\/h3>\n\n\n\n<p>The ESP32 has 18 x 12 bits ADC input channels (while the <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-adc-reading-analog-values-with-nodemcu\/\">ESP8266 only has 1x 10 bits ADC<\/a>).&nbsp;These are the GPIOs that can be used as ADC and respective channels:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ADC1_CH0 (GPIO 36)<\/li>\n\n\n\n<li>ADC1_CH1 (GPIO 37)<\/li>\n\n\n\n<li>ADC1_CH2 (GPIO 38)<\/li>\n\n\n\n<li>ADC1_CH3 (GPIO 39)<\/li>\n\n\n\n<li>ADC1_CH4 (GPIO 32)<\/li>\n\n\n\n<li>ADC1_CH5 (GPIO 33)<\/li>\n\n\n\n<li>ADC1_CH6 (GPIO 34)<\/li>\n\n\n\n<li>ADC1_CH7 (GPIO 35)<\/li>\n\n\n\n<li>ADC2_CH0 (GPIO 4)<\/li>\n\n\n\n<li>ADC2_CH1 (GPIO 0)<\/li>\n\n\n\n<li>ADC2_CH2 (GPIO 2)<\/li>\n\n\n\n<li>ADC2_CH3 (GPIO 15)<\/li>\n\n\n\n<li>ADC2_CH4 (GPIO 13)<\/li>\n\n\n\n<li>ADC2_CH5 (GPIO 12)<\/li>\n\n\n\n<li>ADC2_CH6 (GPIO 14)<\/li>\n\n\n\n<li>ADC2_CH7 (GPIO 27)<\/li>\n\n\n\n<li>ADC2_CH8 (GPIO 25)<\/li>\n\n\n\n<li>ADC2_CH9 (GPIO 26)<\/li>\n<\/ul>\n\n\n\n<p><strong>Learn how to use the ESP32 ADC pins:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-adc-analog-read-arduino-ide\/\">ESP32 ADC Pins with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-analog-readings-micropython\/\">ESP32 ADC Pins with MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> ADC2 pins cannot be used when Wi-Fi is used. So, if you&#8217;re using Wi-Fi and you&#8217;re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead. That should solve your problem.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The ESP32 ADC pins don\u2019t have a linear behavior. You\u2019ll probably won\u2019t 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&#8217;ll get a behavior similar to the one shown in the following figure.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"474\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ADC-non-linear-768x474.png?resize=768%2C474&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ADC pins behavior\" class=\"wp-image-72122\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ADC-non-linear-768x474.png?resize=768%2C474&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ADC-non-linear-768x474.png?resize=300%2C185&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><figcaption class=\"wp-element-caption\"> <br><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/espressif\/arduino-esp32\/issues\/92\" target=\"_blank\">View source<\/a> <\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Digital to Analog Converter (DAC)<\/h3>\n\n\n\n<p>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:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>DAC1 (GPIO25)<\/li>\n\n\n\n<li>DAC2 (GPIO26)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">RTC GPIOs<\/h3>\n\n\n\n<p>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 <a href=\"https:\/\/randomnerdtutorials.com\/esp32-external-wake-up-deep-sleep\/\">external wake up source<\/a>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>RTC_GPIO0 (GPIO36)<\/li>\n\n\n\n<li>RTC_GPIO3 (GPIO39)<\/li>\n\n\n\n<li>RTC_GPIO4 (GPIO34)<\/li>\n\n\n\n<li>RTC_GPIO5 (GPIO35)<\/li>\n\n\n\n<li>RTC_GPIO6 (GPIO25)<\/li>\n\n\n\n<li>RTC_GPIO7 (GPIO26)<\/li>\n\n\n\n<li>RTC_GPIO8 (GPIO33)<\/li>\n\n\n\n<li>RTC_GPIO9 (GPIO32)<\/li>\n\n\n\n<li>RTC_GPIO10 (GPIO4)<\/li>\n\n\n\n<li>RTC_GPIO11 (GPIO0)<\/li>\n\n\n\n<li>RTC_GPIO12 (GPIO2)<\/li>\n\n\n\n<li>RTC_GPIO13 (GPIO15)<\/li>\n\n\n\n<li>RTC_GPIO14 (GPIO13)<\/li>\n\n\n\n<li>RTC_GPIO15 (GPIO12)<\/li>\n\n\n\n<li>RTC_GPIO16 (GPIO14)<\/li>\n\n\n\n<li>RTC_GPIO17 (GPIO27)<\/li>\n<\/ul>\n\n\n\n<p><strong>Learn how to use the RTC GPIOs to wake up the ESP32 from deep sleep:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-deep-sleep-arduino-ide-wake-up-sources\/\">ESP32 Deep Sleep with Arduino IDE and Wake Up Sources<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">PWM<\/h3>\n\n\n\n<p>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\u2019t generate PWM).<\/p>\n\n\n\n<p>To set a PWM signal, you need to define these parameters in the code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Signal&#8217;s frequency;<\/li>\n\n\n\n<li>Duty cycle;<\/li>\n\n\n\n<li>PWM channel;<\/li>\n\n\n\n<li>GPIO where you want to output the signal.<\/li>\n<\/ul>\n\n\n\n<p><strong>Learn how to use ESP32 PWM with Arduino IDE:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-pwm-arduino-ide\/\">ESP32 PWM with Arduino IDE<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">I2C<\/h3>\n\n\n\n<p>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:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO 21 (SDA)<\/li>\n\n\n\n<li>GPIO 22 (SCL)<\/li>\n<\/ul>\n\n\n\n<p>If you want to use other pins when using the wire library, you just need to call:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Wire.begin(SDA, SCL);<\/code><\/pre>\n\n\n\n<p><strong>Learn more about I2C communication protocol with the ESP32 using Arduino IDE: <\/strong><a href=\"https:\/\/randomnerdtutorials.com\/esp32-i2c-communication-arduino-ide\/\">ESP32 I2C Communication (Set Pins, Multiple Bus Interfaces and Peripherals) <\/a><\/p>\n\n\n\n<p>More I2C Tutorials with the ESP32:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-i2c-master-slave-arduino\/\" title=\"\">ESP32 I2C Master and Slave (I2C Communication Between Two ESP32) \u2013 Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-i2c-scanner-arduino\/\">ESP32: I2C Scanner (Arduino IDE) \u2013 Finding the Address of I2C Devices<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/tca9548a-i2c-multiplexer-esp32-esp8266-arduino\/\">Guide for TCA9548A I2C Multiplexer with the ESP32<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">SPI<\/h3>\n\n\n\n<p>By default, the pin mapping for SPI is:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>SPI<\/strong><\/td><td><strong>MOSI<\/strong><\/td><td><strong>MISO<\/strong><\/td><td><strong>CLK<\/strong><\/td><td><strong>CS<\/strong><\/td><\/tr><tr><td><strong>VSPI<\/strong><\/td><td>GPIO 23<\/td><td>GPIO 19<\/td><td>GPIO 18<\/td><td>GPIO 5<\/td><\/tr><tr><td><strong>HSPI<\/strong><\/td><td>GPIO 13<\/td><td>GPIO 12<\/td><td>GPIO 14<\/td><td>GPIO 15<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Learn more about SPI communication protocol with the ESP32 using Arduino IDE:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-spi-communication-arduino\/\">ESP32 SPI Communication: Set Pins, Multiple SPI Bus Interfaces, and Peripherals (Arduino IDE)<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">UART<\/h3>\n\n\n\n<p>The ESP32 supports up to three UART interfaces: <strong>UART0<\/strong>, <strong>UART1<\/strong>, and <strong>UART2<\/strong>, depending on the ESP32 board model you\u2019re using.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>UART0<\/strong> is usually reserved for communication with the serial monitor during upload and debugging. However, you can also use it for communication with other devices after uploading the code if the Serial Monitor is not needed.<\/li>\n\n\n\n<li><strong>UART1<\/strong> and <strong>UART2<\/strong>: available to communicate with external devices.<\/li>\n<\/ul>\n\n\n\n<p>Like I2C and SPI, these UART pins can be mapped to any GPIO pin on the ESP32. However, they have a default pin assignment on most board models.<\/p>\n\n\n\n<p>For most ESP32 boards the UART pin assignment is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>UART Port<\/strong><\/td><td><strong>TX<\/strong><\/td><td><strong>RX<\/strong><\/td><td><strong>Remarks<\/strong><\/td><\/tr><tr><td><strong>UART0<\/strong><\/td><td>GPIO 1<\/td><td>GPIO 3<\/td><td>Used for Serial Monitor and uploading code; Can be assigned to other GPIOs;<\/td><\/tr><tr><td><strong>UART1<\/strong><\/td><td>GPIO 10<\/td><td>GPIO 9<\/td><td><span style=\"text-decoration: underline;\">Must <\/span>be assigned to other GPIOs<\/td><\/tr><tr><td><strong>UART2<\/strong><\/td><td>GPIO 17<\/td><td>GPIO 16<\/td><td>Can be assigned to other GPIOs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>About UART1 (GPIO 9 and GPIO10)<\/strong> \u2013 these GPIOs are connected to the ESP32 SPI flash memory, so you can\u2019t use them like that. To use UART1 to communicate with other devices, you must define different pins using the <span class=\"rnthl rntliteral\">HardwareSerial<\/span> library.\u00a0<\/p>\n\n\n\n<p><strong>Learn more about UART with the ESP32<\/strong>: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-uart-communication-serial-arduino\/\" title=\"\">ESP32 UART Communication (Serial): Set Pins, Interfaces, Send and Receive Data (Arduino IDE)<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/randomnerdtutorials.com\/esp32-s3-devkitc-pinout-guide\/\" title=\"\">If you&#8217;re using an ESP32-S3<\/a>, the assignment is completely different. Check out the <a href=\"https:\/\/randomnerdtutorials.com\/esp32-s3-devkitc-pinout-guide\/\" title=\"\">ESP32-S3 pinout here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Interrupts<\/h3>\n\n\n\n<p>All GPIOs can be configured as interrupts.<\/p>\n\n\n\n<p><strong>Learn how to use interrupts with the ESP32:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-pir-motion-sensor-interrupts-timers\/\">ESP32 interrupts with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-interrupts-esp32-esp8266\/\">ESP32 interrupts with MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Strapping Pins<\/h3>\n\n\n\n<p>The ESP32 chip has the following strapping pins:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO 0 (must be LOW to enter boot mode)<\/li>\n\n\n\n<li>GPIO 2 (must be floating or LOW during boot)<\/li>\n\n\n\n<li>GPIO 4 <\/li>\n\n\n\n<li>GPIO 5 (must be HIGH during boot)<\/li>\n\n\n\n<li>GPIO 12 (must be LOW during boot)<\/li>\n\n\n\n<li>GPIO 15 (must be HIGH during boot)<\/li>\n<\/ul>\n\n\n\n<p>These are used to put the ESP32 into bootloader or flashing mode. On most development boards with built-in USB\/Serial, you don\u2019t 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 <a href=\"https:\/\/docs.espressif.com\/projects\/esptool\/en\/latest\/esp32\/advanced-topics\/boot-mode-selection.html\" target=\"_blank\" rel=\"noopener\">ESP32 Boot Mode Selection can be found here<\/a>.<\/p>\n\n\n\n<p>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 <a href=\"https:\/\/docs.espressif.com\/projects\/esptool\/en\/latest\/esp32\/advanced-topics\/boot-mode-selection.html\" target=\"_blank\" rel=\"noopener\">Boot Mode Selection documentation<\/a> to guide you in the right direction. After resetting, flashing, or booting, those pins work as expected.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pins HIGH at Boot<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPIO 1<\/li>\n\n\n\n<li>GPIO 3<\/li>\n\n\n\n<li>GPIO 5<\/li>\n\n\n\n<li>GPIO 6 to GPIO 11 (connected to the ESP32 integrated SPI flash memory &#8211; not recommended to use).<\/li>\n\n\n\n<li>GPIO 14<\/li>\n\n\n\n<li>GPIO 15<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Enable (EN)<\/h3>\n\n\n\n<p>Enable (EN) is the 3.3V regulator&#8217;s enable pin. It&#8217;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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">GPIO current drawn<\/h3>\n\n\n\n<p>The absolute maximum current drawn per GPIO is 40mA according to the &#8220;Recommended Operating Conditions&#8221; section in the ESP32 datasheet.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ESP32 Built-In Hall Effect Sensor<\/h3>\n\n\n\n<p>The ESP32 also features a <a href=\"https:\/\/randomnerdtutorials.com\/esp32-hall-effect-sensor\/\">built-in hall effect sensor<\/a> that detects changes in the magnetic field in its surroundings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>We hope you&#8217;ve found this&nbsp;reference guide for the ESP32 GPIOs useful. If you have more tips about the ESP32 GPIOs, please share by writing a comment down below.<\/p>\n\n\n\n<p>If you&#8217;re just getting started with the ESP32, we have some great content to get started:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\" target=\"_blank\" rel=\"noreferrer noopener\">Learn ESP32 with Arduino IDE<\/a><\/strong><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-esp32\/\" target=\"_blank\" rel=\"noreferrer noopener\">Getting Started with the ESP32 Development Board<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\" target=\"_blank\" rel=\"noreferrer noopener\">20+ ESP32 Projects and Tutorials<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-web-server-arduino-ide\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 Web Server Tutorial<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/esp32-vs-esp8266\/\">ESP32 vs ESP8266 &#8211; Pros and Cons<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.  <\/p>\n<p class=\"read-more-container\"><a href=\"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/\" class=\"read-more button\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":72107,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,269,264],"tags":[],"class_list":["post-72084","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-guide-project","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/how-to-use-esp32-gpios.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/72084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=72084"}],"version-history":[{"count":7,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/72084\/revisions"}],"predecessor-version":[{"id":163456,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/72084\/revisions\/163456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/72107"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=72084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=72084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=72084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}