By default, Nano ESP32 uses pin mapping consistent with the Nano form factor, and is generally compatible with projects made for other Nano boards. Since this pin mapping is different than the one used for common ESP32 boards, some libraries made for ESP32 boards may not function correctly. In this case, you may want to use the standard ESP32 pin numbering.
You can select pin numbering in Tools > Pin Numbering option:
- By Arduino pin (default): Standard for Nano boards by Arduino.
- By GPIO number (legacy): Standard for most ESP32 boards.
Regardless of which pin numbering you use, you can use the pin labels to refer to the pins. The following lines of codes are equivalent, but only the one using
D0 to refer to the pin works with both pin numbering options:
pinMode(2, OUTPUT)(By Arduino pin)
pinMode(5, OUTPUT)(By GPIO number)
pinMode(D0, OUTPUT)(By Arduino pin or By GPIO number)
For a complete overview, see the table below.
|Pin||Arduino pin||GPIO number|