|
| 1 | +--- |
| 2 | +title: Nano ESP32 Selecting Pin Configuration |
| 3 | +description: Learn how to switch between default & ESP32 pin configurations when programming your board. |
| 4 | +author: Karl Söderby |
| 5 | +hardware: |
| 6 | + - hardware/03.nano/boards/nano-esp32 |
| 7 | +tags: [ESP32, Pin Configuration] |
| 8 | +--- |
| 9 | + |
| 10 | +The [Arduino Nano ESP32](https://store.arduino.cc/nano-esp32) is a Nano form factor board based on an ESP32-S3 SoC. This board is part of the [Arduino Nano Family](https://store.arduino.cc/pages/nano-family), and follows the pinout of that specific form factor by default. |
| 11 | + |
| 12 | +When programming the board in the "default" mode, the pins labelled on the board matches the pins in the program, **but does not match the ESP32-S3**. This mode can be changed to use the "ESP32" pins instead. |
| 13 | + |
| 14 | +To change this configuration, simply connect your board, go to **Tools > Pin Numbering > Select Option**. More details are available in this tutorial. |
| 15 | + |
| 16 | +## Software & Hardware Needed |
| 17 | + |
| 18 | +- [Arduino Nano ESP32](https://store.arduino.cc/nano-esp32) |
| 19 | +- [Arduino IDE](https://www.arduino.cc/en/software) |
| 20 | +- [Arduino ESP32 Core](https://github.com/arduino/arduino-esp32) (version 2.0.12 and above). Can be installed directly in the Arduino IDE. |
| 21 | + |
| 22 | +## Different Pin Configurations |
| 23 | + |
| 24 | +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. |
| 25 | + |
| 26 | +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. |
| 27 | + |
| 28 | +This of course brings a separate issue, which is that by default, the Nano ESP32 does not use the ESP32's pinout. An example of this is: |
| 29 | +- Pin `2` is actually `5` |
| 30 | +- Pin `5` is actually `8` |
| 31 | +- and so on.. |
| 32 | + |
| 33 | +It is common in a board's design that the actual microcontroller's pins doesn't match the header pins. |
| 34 | + |
| 35 | +Luckily, we have two configurations available to choose between: |
| 36 | +- **Nano (Default)** |
| 37 | +- **ESP32-S3 (Legacy)**. |
| 38 | + |
| 39 | +So, let's say we are configuring a pin in a sketch: |
| 40 | + |
| 41 | +```arduino |
| 42 | +// with default configuration, this enables pin 2 as an output |
| 43 | +pinMode(2, OUTPUT); |
| 44 | +``` |
| 45 | + |
| 46 | +But, using the ESP32 configuration (legacy): |
| 47 | + |
| 48 | +```arduino |
| 49 | +// with ESP32 configuration, this enables pin 2 as an output |
| 50 | +pinMode(5, OUTPUT); |
| 51 | +``` |
| 52 | + |
| 53 | +### Which Pin Config Should I Choose? |
| 54 | + |
| 55 | +The answer to this depends on what platform you prefer most: if you are most familiar with Arduino & the Nano form factor, we recommend you use the default (Nano). |
| 56 | + |
| 57 | +If you experience with the ESP32 platform, and not so much with the Arduino platform, the legacy (ESP32) configuration might be a better option. However please bare in mind that pins in the code will not match the Nano ESP32's physical pin labels. |
| 58 | + |
| 59 | +## Change Pin Configuration |
| 60 | + |
| 61 | +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. |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +You can now upload a sketch, and the configuration will change. |
| 66 | + |
| 67 | +## Nano ESP32 Pin Map |
| 68 | + |
| 69 | +To understand how the Nano ESP32 board's pins correlates with the ESP32-S3 SoC pins, have a look at the pin map below: |
| 70 | + |
| 71 | +| Nano | ESP32 | |
| 72 | +| ----- | ------ | |
| 73 | +| D0 | GPIO44 | |
| 74 | +| D1 | GPIO43 | |
| 75 | +| D2 | GPIO5 | |
| 76 | +| D3 | GPIO6 | |
| 77 | +| D4 | GPIO7 | |
| 78 | +| D5 | GPIO8 | |
| 79 | +| D6 | GPIO9 | |
| 80 | +| D7 | GPIO10 | |
| 81 | +| D8 | GPIO17 | |
| 82 | +| D9 | GPIO18 | |
| 83 | +| D10 | GPIO21 | |
| 84 | +| D11 | GPIO38 | |
| 85 | +| D12 | GPIO47 | |
| 86 | +| D13 | GPIO48 | |
| 87 | +| A0 | GPIO1 | |
| 88 | +| A1 | GPIO2 | |
| 89 | +| A2 | GPIO3 | |
| 90 | +| A3 | GPIO4 | |
| 91 | +| A4 | GPIO11 | |
| 92 | +| A5 | GPIO12 | |
| 93 | +| A6 | GPIO13 | |
| 94 | +| A7 | GPIO14 | |
| 95 | +| BOOT0 | GPIO46 | |
| 96 | +| BOOT1 | GPIO0 | |
| 97 | + |
| 98 | +See the pinout below for a better visual translation: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +## Summary |
| 103 | + |
| 104 | +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. |
0 commit comments