GPIO

  • gpio
  • GPIO

What should be considered when configuring ESP32 GPIO pins?

ESP32 series modules include the ESP32-WROOM family and the ESP32-WROVER family. The main GPIO usage notes are as follows.

For WROOM-32/32D/32U/32E/32UE, 26 pins are available to customers:

  • On WROOM-32/32D/32U, GPIO6 to GPIO11 are occupied by the embedded flash and cannot be used for other purposes.
  • On WROOM-32E/32UE, GPIO6 to GPIO11 are also occupied by the embedded flash and are no longer brought out to module pins.
  • GPIO34, GPIO35, GPIO36, and GPIO39 are input-only pins and cannot be used as outputs.
  • ESP32 includes a GPIO matrix, so some peripheral interfaces can be mapped to any available free pins. In other words, hardware design does not always need to tie a function to one fixed pin.
  • WROOM-32/32D/32U are not recommended for new designs. WROOM-32E/32UE are recommended instead.
  • On WROOM-32E/32UE modules with QSPI PSRAM, GPIO16 is used internally for embedded PSRAM and cannot be used for other functions.

For details, refer to Table 6-2 GPIO_Matrix in the ESP32 Datasheet.

For WROVER*/WROVER-I*/WROVER-B/WROVER-IB/WROVER-E/WROVER-IE, 24 pins are available to customers:

  • On WROVER*/WROVER-I*/WROVER-B/WROVER-IB, GPIO6 to GPIO11 are occupied by embedded flash and cannot be used for other purposes.
  • On WROVER-E/WROVER-IE, GPIO6 to GPIO11 are occupied by embedded flash and are no longer brought out to module pins.
  • GPIO34, GPIO35, GPIO36, and GPIO39 are input-only pins and cannot be used as outputs.
  • On WROVER series modules, GPIO12 is internally pulled up, so it is not recommended for touch sensing.
  • ESP32 includes a GPIO matrix, so some peripheral interfaces can be mapped to any available free pins.
  • WROVER*/WROVER-I*/WROVER-B/WROVER-IB are not recommended for new designs. WROVER-E/WROVER-IE are recommended instead.

For details, refer to Table 6-2 GPIO_Matrix in the ESP32 Datasheet.

ESP32 has 3 UARTs, but downloading firmware is only supported through UART0, and its pins are fixed.

* indicates a product that has reached end-of-life status.

What is the GPIO level toggle speed on ESP32?

GPIO level toggling takes about `300 ns`.

If multiple ESP32 GPIOs are configured for edge interrupts, why might interrupts not trigger correctly, and how can this be handled?

As stated in the ESP32 Series Chip Errata, when the power domain of some RTC peripherals is enabled, the digital inputs on GPIO36 and GPIO39 may be pulled low for about 80 ns. There is currently no direct fix. The workaround is to ignore input events from GPIO36 and GPIO39 when the power domain for those sensors is turned on.

Why does GPIO19 on ESP32-C3 still read high after being configured as input with pull-down, while other pins read low normally?

  • On ESP32-C3, GPIO19 is the USB D+ pin. Its pull-up is controlled by both the GPIO pull-up and the USB pull-up logic. If either one is enabled, the effective pull-up resistor is enabled.
  • GPIO19 has the USB pull-up enabled by default, so even if the pin is configured as input with pull-down, the pull-up remains active and the pin still reads high.
  • This issue is fixed in the GPIO driver in ESP-IDF v4.4.3 and later. If you are using an older ESP-IDF version, write 0 directly to the USB_SERIAL_JTAG_DP_PULLUP register bit.

Can GPIO drive strength be configured in ESP-IDF?

Yes. Use the gpio_set_drive_capability API to configure GPIO drive strength.

Why does gpio_install_isr_service() return ESP_ERR_NOT_FOUND when initializing a new GPIO interrupt service on ESP32?

This error usually means that the chip is short on available interrupt sources. In practice, multiple peripherals are often consuming interrupt sources at the same time. Try reducing interrupt usage in other components before initializing the new GPIO interrupt.

How can the input level of an ESP32 RTC_GPIO be read?

uint8_t level = (uint8_t)((REG_GET_FIELD(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT) & BIT(gpio_num)) ? 1 : 0);

How can a GPIO button be used in Light-sleep mode?

You can enable the button wake-up feature. Note that a non-RTC GPIO cannot enable both GPIO edge triggering and level triggering at the same time. The existing features in the Button component can be used to implement this.