How to Install & Program an ESP32 with Arduino IDE for the first time?

ESP32 is a series of small and fast microcontroller boards like Arduino but comes with inbuilt Wi-Fi and Bluetooth features. In our last tutorial, we discussed the basics of ESP32: its Pinout, specifications, schematic, etc. Now it’s time to dive into the Arduino IDE-ESP32 programming tutorial. So by the end of this post, you will be able to install and program your ESP32 with Arduino IDE.

ESp32_30pin
ESp32 Dev board(30 pins)

The ESP32 boards can be programmed using many different programming languages. For example, you can program your ESP32 board in C++ language(like the Arduino) or MicroPython. And to make use of all of the ESP32 features Espressif has officially provided the Espressif IoT Development Framework, or ESP-IDF (tutorial link).

But since most of the users are familiar with the Arduino IDE, it is recommended for beginners. And it is the easiest way to get started in programming the ESP32 board. While this may not be the best environment to work with the ESP32, being a familiar application, the learning period is quite easy.

 

Materials Required to Program ESP32 with Arduino IDE:

  • ESP32 Module
  • Arduino IDE software installed on PC/R-PI
  • Micro USB cable to upload the code to ESP32
Are you a beginner? Start your journey of ESP32 with this very first tutorial:

ESP32 Dev board Pinout, Specifications, datasheet, and Schematic 

 

How to install ESP32 library on Arduino IDE(Windows, Mac OS X, and Linux)

Step 1: Download the Arduino IDE from the official website of Arduino. You can download the software for Windows, Mac, and Linux 32 bit, 64 bit, Arm, Arm64.

Download the Arduino IDE
Download the Arduino IDE

 

Step 2: Open Arduino IDE. Then go to File>Preference from the top menu

Preference option in Arduino IDE

 

Step 3: Paste the URL: “https://dl.espressif.com/dl/package_esp32_index.json” into the “Additional Board Manager URLs” box as shown in the figure below. Then, click the “OK” button:

Additional Board Manager URL box

Note: In case there are already some links present in the Additional Board Manager URL, you can add new URLs by using a comma to separate them.

 

Step 4: Now open board manager from Tools>Board Menu as shown in the figure below. The board manager dialog box will appear in front of you.

Board Manager menu

 

Step 5: In the board manager dialog box, click on the search bar. Then type “ESP32” and hit enter. Now select and click on the install button for “ESP32 by Espressif systems”, wait for the installation to be download and installation to be complete. Once the installation is finished, close the Board Manager dialog box.

Install the ESP32 board

 

Step 6: Now after the installation, in the Tools> Board menu a new option should appear “ESP32 Arduino” as shown in the figure below. Click on this option and select the version of your ESP32 board (I have selected the ESP32 dev module from the list).

ESP32 Board option in Arduino IDE
ESP32 Board option in Arduino IDE

 

Step 7: Now after selection of the correct board version we have to select the port to which the ESP32 board is connected. So go to Tools>Port, and select the port (like COM4 as shown in the figure given below).

ESP32 Port

Note: If you don’t see any port option there, try inserting the board into another USB port. And if the issue persists, you need to install the Arduino board driver follow these steps as shown in this link.

 

How to Program ESP32 with Arduino IDE?

Step 8: Now you are ready to upload your code/sketches to the ESP32 board. Type a simple onboard LED blinking code(given below) and upload it to the board.

#define LED_BUILTIN 2
void setup() {
pinMode (LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(2000);
digitalWrite(LED_BUILTIN, LOW);
delay(2000);
}

 

Just remember some key points during the upload process:

  • Make sure that you have selected the correct COM port and board version. Baud rate should be 115200 or lower.
  • Important: If there is an error while uploading the program then you may see this error message A fatal error occurred: Failed to connect to ESP32: Timed out… Connecting…”. Try to Press and hold the BOOT button on the ESP32 board during the complete upload process.

 

  • When you see the message as shown in the figure below, release the BOOT button.

Done uploadin message

  • If everything went as expected, there would be a “Done uploading” message, and the onboard LED of the ESP32 board will start blinking.
Onboard LED blinking on ESP32
Onboard LED blinking on ESP32
>> Next Tutorial:

ESP32 blinking LED project using Arduino IDE 

 

Leave a Comment