Total newb: can't upload

New to IoT. I'm running an Arduino Nano ESP32 ESP32-S3 and I've been unable to upload the example file 'Blink'. I'm receiving "compilation error: exit status 1" and in the output window I see "error: 'digitalWrite' was not declared in this scope". The rainbow LED is slowly flashing green and the amber and light green LED's are on steady. I've searched hard for solutions and nothing seems to work. What do I need to do?

Hi @nanookbsme.

This error is caused by a bug in the "esp32" boards platform:

There are a couple of fixes for this bug:

A. Use the Official Boards Platform

If you want the most stable experience from your Nano ESP32 board, it is recommended to use the "Arduino ESP32 Boards" platform, which is maintained by the Arduino company, rather than the "esp32" boards platform, which is maintained by 3rd parties. The bug that caused the compilation error is not present in the "Arduino ESP32 Boards" platform.

You can do that by selecting Tools > Board > Arduino ESP32 Boards > Arduino Nano ESP32 from the Arduino IDE menus. After that, the sketch should compile successfully.

B. Adjust Configuration of "esp32" Platform

If you do want to use the 3rd party esp32 platform, you can work around the bug by selecting Tools > Pin Numbering > By GPIO number (legacy) from the Arduino IDE menus. The bug is specific to the default Tools > Pin Numbering > Normal mode (TinyUSB) configuration of the Arduino Nano ESP32 board definition.

Note that when using this "By GPIO number (legacy)" option, you must use the Dn pin name format (e.g., pinMode(D2, OUTPUT)) in your code instead of the integer pin names as we would normally do in Arduino sketches (e.g., pinMode(2, OUTPUT)) in order for your code to match the pin numbers marked on the silkscreen of the Nano ESP32 board. That isn't a problem for the "Blink" example because the LED_BUILTIN macro is configured to work as expected with either Tools > Pin Numbering option.


Hopefully you will be able to upload the "Blink" sketch after using one of the fixes I mentioned above and everything will work as expected after that. If not, let us know and we'll provide further assistance.

'A' above solved my problem. Thank you. I didn't think board selection could be so confusing.

1 Like

Posting in the wrong category
I moved your topic to an appropriate forum category.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

The one you posted in was ONLY for the official Arduino ESP32 board. Which you do not have.

EDIT OK you do have an official ESP32 sorry for the mixup. I have moved it back to where you started from.

It sounded to me like they had an Arduino Nano ESP32; what did I miss?

They were using the Espressif ESP32 core platform rather than the Arduino ESP32 platform, but had selected the Arduino Nano ESP32.

The 3rd party "esp32" boards platform also provides an "Arduino Nano ESP32" board definition.

There is no rainbow LED on the official Arduino ESP32, look at the schematic.

However, on some knock off clones from China there is one of these.

I did?

Well not on my version of the schematic.
UNO R4 WiFI - schematic.pdf (3.2 MB)

Uno R4 WiFi != Nano ESP32?

Correct my bad, sorry. Moved it back again.