ESP32 with Arduino IDE: install the board package and run your first sketch

3 min read

The Arduino IDE is the friendliest way to program an ESP32. You write C++ with the familiar Arduino functions, press upload, and the board runs your code. This guide takes you from nothing to a blinking LED.

If your board does not show up at all, start with our ESP32 first steps checklist and come back.

What you need

  • An ESP32 board: the ESP32 DevKit or the ESP32-S3 N16R8.
  • A USB data cable.
  • An LED and a 330 ohm resistor (optional: you can use the built-in LED).
  • A computer running Windows, macOS or Linux.

An ESP32 DevKit board

Step 1: install Arduino IDE

Download the current Arduino IDE from the official Arduino software page and install it. Open it once so it can finish its setup.

Step 2: add the Espressif board URL

Open File, Preferences. In Additional boards manager URLs, add Espressif's stable package index:

https://espressif.github.io/arduino-esp32/package_esp32_index.json

This is the stable release URL given in Espressif's Arduino getting started guide. If you already have other URLs there, keep them and separate the new one with a comma. Click OK.

Step 3: install the esp32 package

Open Tools, Board, Boards Manager, search for esp32 and install esp32 by Espressif Systems. The download is large, so give it a few minutes.

A warning: there is also a package called "Arduino ESP32 Boards". It only supports Arduino's own boards. For the boards in our shop, you need the Espressif one. The official Arduino-ESP32 installation guide describes the same procedure and alternatives.

Step 4: select your board and port

  • Under Tools, Board, pick ESP32 Dev Module for the classic DevKit, or ESP32S3 Dev Module for an ESP32-S3.
  • Under Tools, Port, select the serial port that appears when you plug the board in.
  • On an N16R8, also set Flash Size to 16MB and PSRAM to OPI PSRAM, as described in our N16R8 guide.

Step 5: your first sketch

This sketch blinks an LED on GPIO4 and prints a message once per second. Using GPIO4 avoids guessing which pin hosts the on-board LED; it is a safe pin, see the pinout guide.

const int LED_PIN = 4;

void setup() {
  Serial.begin(115200);
  pinMode(LED_PIN, OUTPUT);
  Serial.println("Hello from the ESP32");
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  Serial.println("LED on");
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  Serial.println("LED off");
  delay(1000);
}

Wire the LED's long leg through the 330 ohm resistor to GPIO4, and the short leg to GND.

Step 6: upload and read the output

Click the Upload arrow. The IDE compiles the code and sends it to the board. Open Tools, Serial Monitor and set the speed to 115200. You should see the messages and a blinking LED.

If the upload stops at "Connecting...", hold the BOOT button on the board until the upload starts, then release it. Some boards need this the first time.

Common problems

  • No serial port: try another cable, and install the CP210x or CH340 driver if your board uses that chip.
  • "Failed to connect": hold BOOT during upload, and check that the right board is selected.
  • Garbage in the Serial Monitor: the baud rate does not match Serial.begin(115200).
  • Upload works but nothing happens: check the wiring and that you used a free pin.
  • Board resets in a loop: check Flash and PSRAM settings for your exact board.

Next steps

Conclusion

Four things to remember: add the Espressif URL, install "esp32 by Espressif Systems", pick the right board and port, and use a data cable. Once your first LED blinks, everything else is the same loop with different sensors.

The sketch uses only standard Arduino functions. It was not compiled in this article's environment, so tell us if you hit a problem.

Sources