Easy Basics: Project 076f ESP32 Development board - How to use GPIO pins

of Acoptex.com in ESP8266 ESP-32

Basics: Project 076f

Project name: ESP32 Development board - How to use GPIO pins?

Tags: ESP32 Dev Module, ESP32 development board, ESP32 Development board with WiFi and Bluetooth, ESP32-DevKitC V4 development board, ESP-WROOM-32 module with ESP32‑D0WDQ6 chip, Espressif Systems, ESP32-based development board, ESP32 modules, ESP32-WROOM-32, ESP32-WROOM-32U, ESP32-WROOM-32D, ESP32-SOLO-1, USB-UART bridge, IOT, ESP-WROOM-32 Dev Module, ESP32 DEVKITV1, ESP32 pinout reference, how to use GPIO pins

Attachments: none

In this project, you need these parts :

1. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc


We will learn about GPIO pins of the ESP32 development board. There are a lot of different development boards made. You can find more information about them here

There are common questions about the use of pins: Which pins should I use as digital input output pin? Which pins are not in use? Which GPIO pin can you use as an analog pin?

ESP32 chip

ESP32-WROOM-32 is a very popular chip used for the internet of things applications. The main part of this module is ESP32-D0WDQ6 chip.

  • It comes with 48 pins with multiple functions. Please note that not all GPIOs are accessible in all development boards. 
  • It consists of an on-chip WiFi module, Bluetooth low energy module, and Bluetooth module. So if you are working on an embedded systems project, where you need all these modules, you can simply use this board instead of using off the shelf all components one by one. Due to these features, it can be used for many embedded systems applications.
  • It is a very low-cost board.
  • It consists of two cores and each core can be controlled separately.
  • It can operate at the variable frequency range from 80 MHz to 240 MHz.
  • It has a special ultra-low power co-processor. A user can power off processors and can use a low power coprocessor to monitor peripherals at low power like GPIO pins.

The diagram below shows the complete diagram of D0WDQ6 chip:

ESP32 peripheral Interfaces

The figure below illustrates the ESP-WROOM-32 pinout. 

We will discuss the pins of ESP32 DEVKITV1 development board in this project.

There is ESP32 DEVKITV1 development board version with ESP-WROOM-32 module which has 36 GPIO pins. See on the picutre below: 

There is also another development board - ESP32 DEVKITV1 with ESP-WROOM-32 module from Espressif Systems with 30 pins only:

As mentioned earlier, the ESP32 chip used with this board has 48 GPIO pins, but all pins are not accessible through development boards. ESP32 devkit has 36 pins and 18 on each side of the board as shown in the picture above. It has 34 GPIO pins and each pin has multiple functionalities which can be configured using specific registers.  There are many types of GPIOs available like digital input, digital output, analog input, and analog output, capacitive touch, UART communication and many other features mentioned above.

The ESP32 peripherals include:

  • 18 Analog-to-Digital Converter (ADC) channels.  Each ADC is 12 bit SAR technology based.
  • 2 Digital-to-Analog Converters (DAC)
  • 3 SPI interfaces
  • 3 UART interfaces
  • 2 I2C interfaces
  • 16 pulse width modulation (PWM) output channels
  • 2 I2S interfaces
  • 10 Capacitive touch GPIOs
  • 9 touch sensors.
  • it also has a cryptographic hardware acceleration module for various cryptographic algorithms like RSA, AES.

The ADC (analog to digital converter) and DAC (digital to analog converter) features 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).

Input only pins

These pins can’t be used as outputs as they don’t have internal pull-ups or pull-down resistors, so use these pins only as inputs:

  • GPIO34
  • GPIO35
  • GPIO36
  • GPIO37
  • GPIO38
  • GPIO39

SPI flash 

GPIO 6 to GPIO 11 pins are connected to the integrated SPI flash on the ESP-WROOM-32 chip and are not recommended for other uses:

  • 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. So you don’t need to use separate touch sensors in your project when you are using this development board. These capacitive touch sensors can be used to detect any electrical and magnetic waves around like magnetic field detection. You can use a small array of pads instead of push buttons with these touch sensors. 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:

  • TOUCH0 – GPIO4
  • TOUCH1 – GPIO0
  • TOUCH2 – GPIO2
  • TOUCH3 – GPIO15
  • TOUCH4 – GPIO13
  • TOUCH5 – GPIO12
  • TOUCH6 – GPIO14
  • TOUCH7 – GPIO27
  • TOUCH8 – GPIO33
  • TOUCH9 – GPIO32

Analog to Digital Converter (ADC) or Analog GPIO pins

This development board supports 18 ADC channels (while the ESP8266 only has 1 x 10 bits ADC) and each channel is of 12 bits. It can be used to measure analog voltage, current and any analog sensor which provides output in the form of analog voltage. These ADCs can also be used in sleep mode for lower power consumption. Each ADC channel has a resolution of 12 bits which is equal to 3.3 / 4095 where 3.3 volt is a reference voltage and  4095 is minimum step by ADC. So the minimum voltage, we can measure with these ADC channels is about 80 microvolt. Anything less than this will be an error. 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)

Please note taht 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 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. 

Digital to Analog Converter (DAC) pins

This development board has 2 onboard integrated 8-bit DAC. DACs are used to convert digital signals into analog signals. DACs has many applications like voltage control and PWM control.

  • 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)


The ESP32 LED PWM controller has 16 independent channels that can be configured to generate PWM signals with different properties. All general purpose input output pins can be used to generate PWM except digital input pins from GPIO pins 34-39. Because these pins cannot be used as digital output pins. PWM signals are digital output signals. The maximum frequency of these PWM pins is 80 MHz.To set a PWM signal, you need to define these parameters in the code:

  • Select a frequency for pulse width modulation;
  • Select the duty cycle or pulse width;
  • Select the PWM channel. ESP32 provides 16 PWM channels;
  • Assign a digital pin to select the PWM channel.


It has dedicated pins available for two-wire I2C communication. One pin is used for data transfer and another pin is used for clock synchronization. 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)

External interrupt pins

All general purpose input output pins can be used as external interrupt. External interrupts are very useful. When you want to monitor change across any pin, you can use this pin as an interrupt instead of repeatedly monitoring the state of this pin.

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. Check the Boot Mode Selection documentation - it will guide you in the right direction. After resetting, flashing, or booting, those pins work as expected.

Memory card interfacing pins

It also supports memory card interfacing through these pins.


  • HS2_CLK – MTMS
  • HS2_CMD – MTDO
  • HS2_DATA0 – GPIO2
  • HS2_DATA1 – GPIO4
  • HS2_DATA2 – MTDI
  • HS2_DATA3 – MTCK



By default, the pin mapping for SPI is:




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)

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 has a built-in hall effect sensor which is used to detect the magnetic field. Whenever you put this development board in the magnetic field, ESP32 generates a small voltage which can be measured with any pin.


We have learnt about GPIO pins of the ESP32 development board.


  • No libraries required for this project


  • None

Other projects of Acoptex.com
Easy Basics: Project 101a Ai Thinker A9G GPRS GPS development board of Acoptex.com, Not selected 23-11-2019
Easy Basics: Project 100a Ai Thinker A9 GSM GPRS development board of Acoptex.com, Not selected 22-11-2019

Published at 03-06-2019
Viewed: 14252 times