Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (2024)

There are several development platforms available for programming the ESP32. You can go with:

  • Arduino IDE – intended for those who are familiar with Arduino
  • Espruino – JavaScript SDK and firmware closely emulating Node.js
  • Mongoose OS – An operating system for IoT devices that is recommended by Espressif Systems and Google Cloud IoT
  • MicroPython – Implementation of Python 3 for microcontrollers
  • SDK provided by Espressif – Official SDK to take advantage of all ESP32 features

When compared to other platforms, the Arduino IDE is the most user-friendly for beginners. While it may not be the ideal platform for working with the ESP32, it is a program that most people are already familiar with, which makes getting started much easier.

Before you can use the Arduino IDE to program the ESP32, you must first install the ESP32 board (also known as the ESP32 Arduino Core) via the Arduino Board Manager. This guide will walk you through the process of downloading, installing, and testing the ESP32 Arduino Core.

What is a Core?

The cores are required to make new microcontrollers compatible with your Arduino IDE as well as existing sketches and libraries. Arduino develops the cores for the microcontrollers (Atmel AVR MCUs) used on their boards, but anyone can develop a core for their own boards as long as they follow the rules and requirements set by Arduino.

Some development boards require the installation of an additional core; therefore, Arduino developed the Boards Manager as a tool to add cores to the Arduino IDE.

For more information on how to use the Arduino IDE Boards Manager, check out their tutorial.

Step 1: Installing or Updating the Arduino IDE

The first step in installing the ESP32 Arduino core is to have the latest version of the Arduino IDE installed on your computer. If you haven’t already, we recommend that you do so right away.

Latest Arduino IDE

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

There are numerous ESP32-based development boards available. Depending on the design, you may need to install additional drivers for your USB-to-serial converter before you are able to upload code to your ESP32.

For example, the ESP32 DevKit V1 uses the CP2102 to convert USB signals to UART signals, whereas the WeMos ESP32 Lite uses the CH340G. The ESP32-CAM, on the other hand, lacks an onboard USB-to-serial converter and requires a separate module.

Make sure to inspect your board carefully to identify the USB-to-serial converter that is present. You’ll probably have either CP2102 or CH340 populated on the board.

If you’ve never installed drivers for these USB-to-serial converters on your computer before, you should do so right now.

CP210x USB to UART Bridge VCP Drivers

CH340 drivers

Step 3: Installing the ESP32 Arduino Core

Launch the Arduino IDE and navigate to File > Preferences.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (3)

Fill in the “Additional Board Manager URLs” field with the following.

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

Then, click the “OK” button.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (4)

If you have already entered the URL for the ESP8266 boards or any other board, you can click on the icon to the right of the field to open a window where you can add additional URLs, one for each row.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (5)

Now navigate to Tools > Board > Boards Manager…

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (6)

Filter your search by entering ‘esp32‘. Look for ESP32 by Espressif Systems. Click on that entry, and then choose Install.

Step 4: Selecting the Board and Port

After installing the ESP32 Arduino Core, restart your Arduino IDE and navigate to Tools > Board to ensure you have ESP32 boards available.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (8)

Now select your board in the Tools > Board menu (in our case, it’s the DOIT ESP32 DEVKIT V1). If you are unsure which board you have, select ESP32 Dev Module.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (9)

Finally, connect the ESP32 board to your computer and select the Port.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (10)

That’s it! You can now begin writing code for your ESP32 in the Arduino IDE.

You should make sure you always have the most recent version of the ESP32 Arduino core installed.

Simply navigate to Tools > Board > Boards Manager, search for ESP32, and verify the version you have installed. If a newer version is available, you should install it.

Step 5: Testing the Installation

Once you’ve finished the preceding steps, you are ready to test your first program with your ESP32! Launch the Arduino IDE. If you disconnected your board, plug it back in.

Let’s upload the most basic sketch of all – Blink!

This sketch uses the on-board LED that most ESP32 development boards have. This LED is connected to digital pin D2, and its number may vary from board to board.

int ledPin = 2;void setup() {pinMode(ledPin, OUTPUT);}void loop() {digitalWrite(ledPin, HIGH);delay(500);digitalWrite(ledPin, LOW);delay(500);}

If everything worked, the on-board LED on your ESP32 should now be blinking! To execute the sketch, you may need to press the EN button on your ESP32.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (11)

Congratulations! You have just programmed your first ESP32!

More ESP32 Examples

The ESP32 Arduino core includes several examples that demonstrate everything from scanning for nearby networks to building a web server. To access the example sketches, navigate to File > Examples > ESP32.

You will see a selection of example sketches. You can choose any of them to load the sketch into your IDE and start experimenting with it.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (12)

ESP32 Example: WiFi Scan

Let’s try to run one of the ESP32 example sketches, which demonstrates how to use the WiFi library to scan nearby WiFi networks and print the results.

You can find this example under File > Examples > WiFi > WiFiScan.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (13)

Load the WiFiScan sketch from the example sketches into your Arduino IDE.

#include "WiFi.h"void setup(){ Serial.begin(115200); // Set WiFi to station mode and disconnect from an AP if it was previously connected. WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); Serial.println("Setup done");}void loop(){ 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("%4d", WiFi.RSSI(i)); Serial.print(" | "); Serial.printf("%2d", 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); } } Serial.println(""); // Delete the scan result to free memory for code below. WiFi.scanDelete(); // Wait a bit before scanning again. delay(5000);}

Once you have uploaded the sketch, open the serial monitor at baud rate 115200 and press the EN button on the ESP32. You should see the SSID, RSSI, WiFi channel, and encryption for each discovered network.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (14)

Troubleshooting

Some ESP32 boards enter flashing mode automatically, and the code is uploaded successfully, while others do not, and you may receive the “A fatal error occurred: Failed to connect to ESP32… Timed out waiting for packet header…” error:

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (15)

This is a common issue, and it indicates that your ESP32 is not in flashing or uploading mode. You can resolve this issue by following the steps outlined below.

  • Hold down the BOOT button on your ESP32 board.
  • Press the Upload button in the Arduino IDE to upload a new sketch.
  • Release the BOOT button when the Writing at 0x00001000… (100%) message appears in the Arduino IDE log after Connecting….
  • You should now see the “Done uploading” message.

That’s it. Now, press the EN button to restart the ESP32 and run the newly uploaded sketch.

Remember! You’ll have to repeat that button sequence every time you want to upload a new sketch.

Installing ESP32 Board in the Arduino IDE: Step-by-Step Guide (2024)
Top Articles
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 6461

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.