Installing ESP32 Board in the Arduino IDE

The ESP32 microcontroller has quickly become one of the most popular boards among hobbyists, engineers, and people interested in the Internet of Things (IoT). It’s powerful, affordable, and comes with built-in Wi-Fi and Bluetooth, making it perfect for projects that need wireless communication or real-time performance.

But before you can start creating with it, you’ll need to set up your programming environment. The easiest way to do this—especially for beginners—is by using the Arduino IDE. While it’s not the most advanced tool for working with the ESP32, it’s familiar to many people, which makes getting started much simpler.

In this tutorial, you’ll learn how to set up the Arduino IDE to work with the ESP32 step by step.

Step 1: Installing or Updating the Arduino IDE

The first step in the setup process is to have the latest version of the Arduino IDE on your computer. If you don’t have it yet, go ahead and download and install it now from the official Arduino website. Having the latest version ensures you have all the newest features and bug fixes.

Step 2: Installing the USB-to-Serial Bridge Driver

Most ESP32 boards come with a USB-to-UART bridge chip. This chip lets your computer communicate with the ESP32 through the USB cable. Different ESP32 boards use different bridge chips. For example, the ESP32 DevKit V1 often uses the CP2102 chip, while the WeMos ESP32 Lite uses the CH340G chip.

cp2102 on esp32 dev kit v1
ch340g on wemos esp32 lite

If your board uses one of these chips, you may need to install a driver before your computer can recognize the board. Here are the links to download the drivers you might need:

However, if you have a newer ESP32 board with models like ESP32-S2, ESP32-S3, or ESP32-C3, you’re in luck. These boards have built-in USB support that your computer recognizes automatically, so you can skip installing drivers and move to the next step.

Step 3: Adding the ESP32 Board to the Arduino IDE

Arduino IDE relies on “board definitions” to communicate with specific hardware. These definitions contain configuration files, libraries, and compiler settings that tell the IDE how to compile and upload code to a particular board. Since the ESP32 is not included by default, you need to add it manually through the Board Manager.

To do this, open the Arduino IDE and go to File > Preferences

arduino ide file menu

A window will pop up. Look for a box labeled “Additional Board Manager URLs”. In that box, add the following URL:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

This URL points the IDE to Espressif’s repository, which contains all the files necessary to enable ESP32 boards.

arduino ide preferences

If you already have other URLs in that box, like one for ESP8266, don’t worry. Just click the small icon next to the box, and a new window will open. Enter each URL on a separate line. When you’re done, click OK to save and close the window.

arduino ide multiple board manager urls

Now look for the board icon on the left side of the Arduino IDE window and click it. This opens the Boards Manager. Wait a moment while it loads the list of available boards. If you’re using an older version of Arduino IDE, go to Tools > Board > Boards Manager… instead.

In the search bar, type “esp32.” You should see an entry that says “esp32 by Espressif Systems.” Click on it, then click the Install button. The IDE will now download and install the esp32 board definitions. This might take a few minutes depending on how fast your internet connection is. When it’s done, you’ll see the word “INSTALLED” next to the package name.

arduino ide esp32 package

Step 4: Selecting the Board and the Port

Now that everything is installed, grab your USB cable and connect your ESP32 board to your computer.

In the Arduino IDE, click on the dropdown menu at the top and select the “Select Other Board and Port” entry. If you’re using an older version of the IDE, go to Tools > Board instead.

arduino ide board and port dropdown menu

A list of boards will appear. Find and select the option that matches your specific ESP32 board. If you’re not sure which one you have, just select “ESP32 Dev Module” as a safe default choice.

arduino ide board selection

Next, select the COM port corresponding to your connected ESP32. If you’re not sure which port is correct, try this trick: unplug your ESP32 and look at which port disappears from the list. Then plug it back in and select that port.

arduino ide port selection

That’s it! You’re now ready to start writing code for your ESP32 using Arduino IDE.

Step 5: Testing the Installation

To make sure everything is set up correctly, let’s test it using the classic Blink example.

This simple program makes the built-in LED on your board turn on and off repeatedly. The LED is usually connected to pin D2, but this can vary depending on your board.

int ledPin = 2;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
}

Once you have the Blink sketch ready, click the Upload button. If everything uploads successfully, you should see the LED on your board start blinking. On some ESP32 boards, you might need to press the “EN” button to make the program start running.

ESP32 Development Board Blink Sketch Working Arduino IDE

Congratulations! You’ve successfully set up your Arduino IDE to work with the ESP32 and run your first program. You’re now ready to explore and start building your own IoT projects.

Troubleshooting

Sometimes things don’t work perfectly the first time, and that’s completely normal. One of the most common problems you might see is an error message that says “A fatal error occurred: Failed to connect to ESP32… failed uploading: uploading error: exit status 2

failed to connect to esp32 error while uploading sketch in arduino ide

Don’t panic if this happens to you. Here’s what’s going on. Some ESP32 boards automatically switch into programming mode when you try to upload code, and everything works smoothly. However, other boards need you to manually put them into programming mode. When this happens, you’ll see the error message.

To fix this problem, follow these steps carefully.

  1. Click the Upload button in the Arduino IDE to start uploading your sketch.
  2. As soon as you see the “Connecting…” message appear in the console at the bottom of the IDE, press and hold the BOOT button on your ESP32 board.
  3. Keep holding it until you see a message like “Writing at 0x00001000… (2%)” appear. At that point, you can release the BOOT button.
  4. The IDE will continue uploading your program, and when the process is done, you’ll see the “Done uploading” message.
  5. After that, press the EN (Enable) button on your ESP32 to restart it and run the new program you just uploaded.

Remember, you’ll need to repeat this button-pressing sequence each time you upload a new sketch. It might feel annoying at first, but you’ll get the hang of it quickly and it’ll become second nature.

More ESP32 Examples

Now that you know how to upload code to your ESP32, you’ll be happy to know that Arduino IDE comes with lots of example programs specifically designed for ESP32. These examples show you how to do all sorts of cool things, from scanning for nearby WiFi networks to creating your own web server that you can access from your phone or computer.

To find these examples, open the Arduino IDE and go to File > Examples > ESP32. You’ll see a whole collection of example programs. Feel free to click on any of them. The code will load into your IDE, and you can upload it to your board and see what it does. This is a great way to learn by experimenting.

arduino ide esp32 package examples

ESP32 Example: WiFi Scan

Let’s try running one of these example programs together. We’ll use the WiFi Scan example, which is perfect for beginners. This program makes your ESP32 search for all the WiFi networks around you and display information about them, just like when you look for WiFi on your phone.

To find this example, go to File > Examples > WiFi > WiFiScan.

esp32 wifi scan example sketch
#include "WiFi.h"

void setup() {
  Serial.begin(115200);
  // Enable Station Interface
  WiFi.STA.begin();
  Serial.println("Setup done");
}

void ScanWiFi() {
  Serial.println("Scan start");
  // WiFi.scanNetworks will return the number of networks found.
  int n = WiFi.scanNetworks();
  Serial.println("Scan done");
  if (n == 0) {
    Serial.println("no networks found");
  } else {
    Serial.print(n);
    Serial.println(" networks found");
    Serial.println("Nr | SSID                             | RSSI | CH | Encryption");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.printf("%2d", i + 1);
      Serial.print(" | ");
      Serial.printf("%-32.32s", WiFi.SSID(i).c_str());
      Serial.print(" | ");
      Serial.printf("%4ld", WiFi.RSSI(i));
      Serial.print(" | ");
      Serial.printf("%2ld", WiFi.channel(i));
      Serial.print(" | ");
      switch (WiFi.encryptionType(i)) {
        case WIFI_AUTH_OPEN:            Serial.print("open"); break;
        case WIFI_AUTH_WEP:             Serial.print("WEP"); break;
        case WIFI_AUTH_WPA_PSK:         Serial.print("WPA"); break;
        case WIFI_AUTH_WPA2_PSK:        Serial.print("WPA2"); break;
        case WIFI_AUTH_WPA_WPA2_PSK:    Serial.print("WPA+WPA2"); break;
        case WIFI_AUTH_WPA2_ENTERPRISE: Serial.print("WPA2-EAP"); break;
        case WIFI_AUTH_WPA3_PSK:        Serial.print("WPA3"); break;
        case WIFI_AUTH_WPA2_WPA3_PSK:   Serial.print("WPA2+WPA3"); break;
        case WIFI_AUTH_WAPI_PSK:        Serial.print("WAPI"); break;
        default:                        Serial.print("unknown");
      }
      Serial.println();
      delay(10);
    }
  }

  // Delete the scan result to free memory for code below.
  WiFi.scanDelete();
  Serial.println("-------------------------------------");
}
void loop() {
  Serial.println("-------------------------------------");
  Serial.println("Default wifi band mode scan:");
  Serial.println("-------------------------------------");
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
  WiFi.setBandMode(WIFI_BAND_MODE_AUTO);
#endif
  ScanWiFi();
#if CONFIG_SOC_WIFI_SUPPORT_5G
  // Wait a bit before scanning again.
  delay(1000);
  Serial.println("-------------------------------------");
  Serial.println("2.4 Ghz wifi band mode scan:");
  Serial.println("-------------------------------------");
  WiFi.setBandMode(WIFI_BAND_MODE_2G_ONLY);
  ScanWiFi();
  // Wait a bit before scanning again.
  delay(1000);
  Serial.println("-------------------------------------");
  Serial.println("5 Ghz wifi band mode scan:");
  Serial.println("-------------------------------------");
  WiFi.setBandMode(WIFI_BAND_MODE_5G_ONLY);
  ScanWiFi();
#endif
  // Wait a bit before scanning again.
  delay(10000);
}

Upload the sketch to your ESP32 board using the same process you learned earlier. After the upload finishes successfully, open the Serial Monitor and set the baud rate to 115200. Now press the EN button on your ESP32 board to restart it and run the program.

esp32 wifi scan sketch output

If everything is working correctly, you’ll see a list of nearby Wi-Fi networks appear in the Serial Monitor. Pretty cool, right?

Shreepad Prabhu

Shreepad Prabhu

Shreepad is a passionate Electronics & Telecommunication Engineer with a deep love for embedded systems. He has over 15 years of experience, including his time as a Senior Embedded Engineer at Micromax contributing to solutions for Thermo Fisher Scientific, Tata Motors, Liebherr, and John Deere. Since co-founding Last Minute Engineers in 2018, he has written hundreds of articles and guides for Last Minute Engineers to help makers build with confidence. You can find him on LinkedIn