Nano ESP32 Selecting Pin Configuration

Learn how to switch between default & ESP32 pin configurations when programming your board.


The Arduino Nano ESP32 is a Nano form factor board based on an ESP32-S3 SoC. This board is part of the Arduino Nano Family, and follows the same pinout as all Nano boards. This is very convenient if you want to port a project from another Nano board, as you can preserve the same wiring and pin numbers in the code.

This means that if you want to control a pin you can simply use the pin number that is printed on the board itself:

1// This will enable the pin marked with "D8" on the board:
2digitalWrite(8, HIGH);

Compatibility Mode

However, some libraries previously written for ESP32 boards (to name a few: OneWire, FastLED, ESP32Servo) don't support the pin numbers printed on the board and require you to refer to the internal microcontroller's GPIO number instead. For instance, to refer to the pin labelled "D8" on the board such libraries expect you to write

in your code as that's the GPIO number corresponding to that pin.

For this purpose, we added a compatibility mode so that you can choose which numbering scheme you want to use:

  • when porting an existing Arduino project from another Nano board, it's convenient to use the "Arduino pin" scheme which reflects the numbers printed on the board
  • when using third-party libraries for ESP32, you should use the "GPIO number" scheme which corresponds to the internal numbers

To change this configuration, simply connect your board, go to Tools > Pin Numbering and then select your option. More details are available in this tutorial.

Software & Hardware Needed

Different Pin Configurations

So why does the Nano ESP32 pins not match the ESP32 (MCU) pins? The Nano ESP32 was designed using the Nano form factor, a favorable form factor for many, which has consistently kept its pins for many years.

This makes it possible to migrate an older Nano board, to a newer generation Nano (like the Nano ESP32), without having to change your hardware setup.

This of course brings a separate issue, which is that this numbering does not match the ESP32's native GPIO assignment. An example of this is:

  • Pin
    is actually GPIO
  • Pin
    is actually GPIO
  • and so on (see the full pin map).

It is common in a board's design that the actual microcontroller's pins don't match the header pins.

Default & Legacy Options

Luckily, we have two configurations available to choose between:

  • By Arduino pin (default)
  • By GPIO number (legacy)

So, let's say we are configuring a pin in a sketch, using the

Arduino pin (default)

1// with default configuration, this enables pin 2 as an output
2pinMode(2, OUTPUT);

But, when using the

GPIO number (legacy)
option, we would need to configure it like this:

1// with ESP32 configuration, this enables pin 2 as an output
2pinMode(5, OUTPUT);

Pin Labels

You can also control pins using labels such as

. These labels are predefined in the core, and are adjusted based on what configuration you make.

For example, the following code will access the same pin, regardless of what configuration you use:

2This will configure the "D2" physical pin on your board
3(but will internally configure GPIO 5 on the ESP32)
5pinMode(D2, OUTPUT);

Change Pin Configuration

To change the pin configuration, open the Arduino IDE, and navigate to Tools > Pin Numbering. Here you can select between the default (Nano) and legacy (ESP32) options.

Change pin configuration in the Arduino IDE.
Change pin configuration in the Arduino IDE.

You can now upload a sketch, and the configuration will change.

Nano ESP32 Pin Map

To understand how the Nano ESP32 board's pins correlates with the ESP32-S3 SoC pins, have a look at the pin map below:


See the pinout below for a better visual translation:

Nano / ESP32 pinout
Nano / ESP32 pinout


In this tutorial, we've covered how the Nano ESP32's pinout differ from the ESP32-S3 SoC pinout. We've also had a look at how to change the configuration, and provided a pin map that can be used as a reference when making your next project.

Tutorial Toolbox

Contribute to Arduino

Join the community and suggest improvements to this article via GitHub. Make sure to read out contribution policy before making your pull request.

Missing something?

Check out our store and get what you need to follow this tutorial.

Suggest Changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.
The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.