Skip to content

Arduino IDE Compatibility

Arduino IDE Compatibility

This section introduces the Arduino IDE as a development environment for ESP32. By the end of this section, you will be able to:

  • Install and configure the ESP32 board support package in Arduino IDE
  • Manage libraries for ESP32 development
  • Write, compile, and upload a basic ESP32 sketch
  • An Arduino IDE installation (version 2.x recommended)
  • An ESP32 development board and USB cable
  • The USB-UART driver installed (CP2102 or CH340)

The Arduino IDE is the most accessible development environment for ESP32. It abstracts away complex toolchain configuration, allowing developers to focus on application logic. The ESP32 Arduino Core (maintained by Espressif) provides full API compatibility.

How the Arduino IDE Works with ESP32:

  1. You write a sketch (.ino file) with setup() and loop() functions
  2. The IDE compiles the sketch using the ESP32 toolchain (XTensa GCC)
  3. The compiled binary is uploaded to the ESP32 via the serial bootloader
  4. The ESP32 executes the firmware on reset
  • Full Wi-Fi and Bluetooth API (analogous to standard Arduino Ethernet library)
  • Peripheral API: GPIO, ADC, DAC, I2C, SPI, UART, PWM (LEDC), I2S
  • FreeRTOS task management (underlying scheduler)
  • OTA (Over-the-Air) update support
  • Deep sleep and power management
  • File system support (SPIFFS, LittleFS)

Arduino IDE 2.x (Recommended)

  1. Open Arduino IDE
  2. Go to File > Preferences (or Arduino IDE > Settings on macOS)
  3. In the “Additional Boards Manager URLs” field, add:
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  4. Click OK
  5. Go to Tools > Board > Boards Manager
  6. Search for “ESP32”
  7. Find esp32 by Espressif Systems
  8. Click Install (the installation is ~500 MB and takes several minutes)

Arduino IDE 1.8.x (Legacy)

The steps are identical. Note that the IDE 1.8.x may have slower compilation times.

  1. Go to Tools > Board > ESP32 Arduino
  2. Select your board variant:
    • For standard DevKit: ESP32 Dev Module
    • For NodeMCU-32S: NodeMCU-32S
    • For M5Stack Core2: M5Stack-Core2
    • For XIAO ESP32-C3: XIAO_ESP32C3
    • For ESP32-CAM: AI Thinker ESP32-CAM
  3. Select the correct port under Tools > Port
  4. Verify the upload speed: Tools > Upload Speed > 921600 (or 115200 if unstable)

Common ESP32 libraries and their installation:

LibraryPurposeInstall Method
PubSubClientMQTT clientLibrary Manager: “PubSubClient by Nick O’Leary”
ArduinoJsonJSON parsing/creationLibrary Manager: “ArduinoJson by Benoit Blanchon”
DHT sensor libraryDHT11/DHT22Library Manager: “DHT sensor library by Adafruit”
Adafruit Unified SensorSensor abstractionLibrary Manager: “Adafruit Unified Sensor”
U8g2OLED displayLibrary Manager: “U8g2 by Oliver Kraus”
WiFiManagerWi-Fi configuration portalLibrary Manager: “WiFiManager by tzapu”

To install via Library Manager:

  1. Go to Tools > Manage Libraries (or Ctrl+Shift+I)
  2. Search for the library name
  3. Click Install

Create a new sketch (File > New) and enter:

#include <WiFi.h>
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32 Test Sketch");
Serial.print("Connecting to Wi-Fi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
Serial.print("Uptime: ");
Serial.print(millis() / 1000);
Serial.println(" seconds");
delay(5000);
}

Upload Steps:

  1. Connect the ESP32 via USB
  2. Select the correct board and port (Tools > Board, Tools > Port)
  3. Put the ESP32 in flash mode:
    • Hold the BOOT button
    • Press and release the EN (reset) button
    • Release the BOOT button (Some newer boards auto-reset and do not require this step)
  4. Click the Upload button (right arrow) or press Ctrl+U
  5. Wait for “Connecting…” and then the upload progress bar
  6. After “Done uploading,” open the Serial Monitor (Tools > Serial Monitor, 115200 baud)
  7. Press the EN button to reset the ESP32 and observe the output

Expected Serial Monitor output:

ESP32 Test Sketch
Connecting to Wi-Fi............
Connected! IP address: 192.168.1.100
Uptime: 1 seconds
Uptime: 6 seconds
Uptime: 11 seconds
  • ESP32 board appears in the Board Manager after installation
  • The selected board matches the physical hardware
  • The USB port is detected and selectable
  • Sketch compiles without errors
  • Upload completes to 100%
  • Serial Monitor shows the expected output
  • Wi-Fi connection is successful with the correct IP address

”Failed to connect to ESP32: Timed out” during upload

Section titled “”Failed to connect to ESP32: Timed out” during upload”

Causes:

  • ESP32 not in flash/download mode
  • Wrong port selected
  • USB cable is charge-only (no data lines)

Solutions:

  1. Hold BOOT, press EN, release BOOT, then try uploading again
  2. Verify the correct COM/port is selected
  3. Try a different USB cable (preferably one known to work for data)
  4. Reduce upload speed to 115200 baud

”A fatal error occurred: MD5 of file does not match data in flash”

Section titled “”A fatal error occurred: MD5 of file does not match data in flash””

Causes:

  • Unstable serial connection
  • Power fluctuations during upload

Solutions:

  1. Use a shorter USB cable
  2. Reduce upload speed to 115200
  3. Power the ESP32 via an external 5V supply instead of USB

Causes:

  • Library Manager did not install correctly
  • Library not compatible with ESP32

Solutions:

  1. Restart the Arduino IDE
  2. Verify the library appears in Sketch > Include Library > Manage Libraries
  3. Install the library manually by downloading from GitHub and placing in the libraries folder

Common causes:

  1. Using AVR-specific code (e.g., avr/pgmspace.h) on ESP32
  2. Missing ESP32 board package

Solutions:

  1. Check for architecture-specific code and replace with ESP32 equivalents
  2. Reinstall the ESP32 board support package
  3. Update the Arduino IDE to the latest version
  • Use Arduino IDE 2.x: It has a modern editor, faster compilation, and built-in serial plotter
  • Maintain library versions: Note library versions for reproducible builds
  • Check the Board Selection: The wrong board selection can cause compile errors or incorrect pin mapping
  • Keep the ESP32 Core Updated: Espressif releases frequent updates; check for updates in Boards Manager every few months
  • Use a dedicated USB port: Avoid USB hubs for stable communication, especially during upload
  1. Arduino IDE requires the ESP32 board support package (add via Boards Manager URL)
  2. Board selection must match the physical hardware for correct pin mapping
  3. Libraries are installed via Library Manager (PubSubClient, ArduinoJson, etc.)
  4. Upload requires the ESP32 to be in flash mode (hold BOOT, press EN)
  5. Arduino IDE 2.x is recommended over 1.8.x for better performance