Lesson 3
15 min
Add the ESP32 package to the Arduino IDE, select the board and port, and fix common problems.
Definition
A board package is a collection of files that teaches the Arduino IDE how to recognize a new type of board. It contains the compiler, libraries, and settings specific to that board. Uploading is the process of transferring the compiled program from the computer to the board's memory through a USB cable.
The installation process consists of five steps that only need to be completed once. After that, you will be able to upload programs to your ESP32 just as easily as to an Arduino Uno.
The Arduino IDE does not support the ESP32 by default: you need to add Espressif's board package. Open File > Preferences(or Arduino IDE > Settings on macOS), find the Additional Boards Manager URLs field, and add the following address:
https://espressif.github.io/arduino-esp32/package_esp32_index.jsonIf the field already contains an address (for example, for another family of boards), do not delete it. Add the new URL after the existing one, separated by a comma, or click the icon on the right side of the field to enter one address per line. Then confirm by clicking OK.

Open the Boards Manager(the board icon in the left sidebar, or Tools > Board > Boards Manager), search for "esp32", then install the packageesp32 by Espressif Systems. The download is fairly large, so allow a few minutes for the installation to finish.

Connect the board to your computer. Depending on the USB-to-serial chip used by your board, your computer may need a driver to recognize it:
On many modern computers, the board is recognized without installing anything. If no port appears in the IDE, install the driver corresponding to your chip. The chip's name is printed on the board, near the USB port.
COM3./dev/cu., for example/dev/cu.usbserial-0001./dev/ttyUSB0or/dev/ttyACM0.Linux: Permission Issue
If the port appears but uploading is denied ("Permission denied"), your user account does not have permission to access the serial port. Add your user to the appropriate group using the command below, then log out and log back in.
sudo usermod -a -G dialout $USERIn the Tools menu:
If you are unsure which port to select, disconnect the board and check the list, then reconnect it. The new port that appears is the correct one. If your board is a specific model (ESP32-S3, ESP32-C3, etc.), look for its exact name in the board list instead of keeping "ESP32 Dev Module".

Copy this small program, which displays a message in the Serial Monitor every second, then click the Upload button.
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("Hello from the ESP32!");
delay(1000);
}Next, open the Serial Monitorand set the speed to 115200 baud(the standard speed used with the ESP32, faster than the 9600 baud commonly used with Arduino Uno).

When you click Upload, the IDE performs several operations in sequence. Understanding them helps you identify where a potential problem occurs.
To verify that the IDE has correctly identified your model, upload this program. It asks the chip for its model, number of cores, frequency, and available memory using functions from the ESP32-specificESPobject.
void setup() {
Serial.begin(115200);
delay(1000);
Serial.print("Model: ");
Serial.println(ESP.getChipModel());
Serial.print("Number of cores: ");
Serial.println(ESP.getChipCores());
Serial.print("Frequency: ");
Serial.print(ESP.getCpuFreqMHz());
Serial.println(" MHz");
Serial.print("Free memory: ");
Serial.print(ESP.getFreeHeap());
Serial.println(" bytes");
}
void loop() {
}The information is displayed only once, insidesetup(). If you open the Serial Monitor too late, you will miss it. In that case, press theEN button to restart the board and display the information again.
The classic final test is to blink the built-in LED. On many boards, it is connected toGPIO2. If nothing blinks on your board, it may use a different pin or have no built-in LED. In that case, connect an external LED with a 220-ohm resistor to a suitable output pin of your choice.
const int led = 2; // Built-in LED on many boards
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}The "Connecting........_____" Message Gets Stuck
On some boards, you need to manually put the ESP32 into upload mode. Hold down the BOOTbutton when the IDE displays "Connecting...", then release it when the transfer begins. If the problem persists, try another USB cable, another USB port on your computer, or reduce the upload speed in the Tools menu (Upload Speed, for example 115200).
Espressif regularly releases updates to the esp32 package to fix bugs and add new features. You can install them through the Boards Manager, which displays an update button when a new version is available. If you experience unexpected behavior after an update, you can also reinstall a previous version by selecting it from the package's version dropdown menu.
Exercise
delay. Press the board's EN button and observe what appears in the Serial Monitor.Exercise: Chip Dashboard
chip_info.inoprogram so that it also displays the flash memory size (usingESP.getFlashChipSize()) and the SDK version (usingESP.getSdkVersion()). Write down the values obtained and compare them with your board's advertised specifications.Go Further
millis().