Home

Guide no. 27

From installation to the first blinking LED: the ESP32 package, the right driver, choosing board and port, and what to do when the upload won't start. With the same steps in PlatformIO.

By Ada Intelisano · informaticait.it technical team

Download the PDF (A4, 4 pages) Free to print and share, without changes — CC BY-ND 4.0
In short
  • In Arduino IDE 2 you add Espressif's esp32 package from the Boards Manager, after pasting its address in Preferences.
  • The board to choose for the DevKitC is ESP32 Dev Module; the Serial Monitor runs at 115200.
  • The DevKitC has no LED on a pin: the classic Blink doesn't compile. You need an external LED, for example on GPIO 23.
  • If the upload won't start: data cable, right port, monitor closed, and as a last resort hold down BOOT.

Arduino IDE 2

Arduino IDE 2: from install to first upload1InstallArduino IDE 22Add the URLin Preferences3Install «esp32»Boards Manager4Pick boardESP32 Dev Module5Pick the portCOM / ttyUSB6Uploadand open monitorinformaticait.it

Open File › Preferences (on Mac Arduino IDE › Settings) and paste the address of the Espressif package into “Additional boards manager URLs”:

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

Then open the Boards Manager, search for “esp32” and install the package by Espressif Systems: the current version is 3.3.12. Connect the board, choose ESP32 Dev Module and the port from the menu at the top: when the connection is there, the board name appears in bold. The default upload speed is 921600.

The USB driver

Between the USB socket and the ESP32 there is a chip that acts as a serial port. Espressif says the driver is usually already in the operating system and installs itself. If the port doesn't show up, look at the marking on the chip next to the USB socket:

ChipOn which boardsDriver
CP2102N (Silicon Labs)original Espressif DevKitC V4CP210x USB to UART Bridge VCP, from the Silicon Labs website
CH340many Arduino and ESP32 clonesCH341SER by WCH
CH9102some ESP32 boards from other makersCH343SER by WCH

To find the port on Windows open Device Manager, then unplug and plug the board back in: the COM port that disappears and comes back is the board's. On Linux add your user to the dialout group and log in again; on Mac the port is called /dev/cu.…

DevKitC buttons and socketESP32-WROOM-323V3GNDEN23VP22VNTX34RX352132GND3319251826527171416124GND0132D215D3D1CMDD05VCLKBOOThold it to force download modeMicro-USBpower and upload: use a data cableENreset: restarts the boardinformaticait.it

EN restarts the board. BOOT is for when automatic upload doesn't work: hold BOOT down, press and release EN, then release BOOT; the board waits for the sketch. You usually don't need it: the DevKitC circuit does this by itself.

The first sketch

First circuit: an LED on GPIO 23−+ESP32-WROOM-323V3GNDEN23VP22VNTX34RX352132GND3319251826527171416124GND0132D215D3D1CMDD05VCLKGPIO 23GND220 ΩLED: long leg to the resistorinformaticait.it

LED with a 220 Ω resistor between GPIO 23 and the GND next to it. The long leg of the LED (anode) goes toward the resistor. GPIO 23 is a free pin: it doesn't interfere with booting (see guide no. 26).

// First sketch for the ESP32-DevKitC: blinks an LED on GPIO 23 and writes to the Serial Monitor.
// The DevKitC has no LED connected to a pin: LED with a 220 ohm resistor between GPIO 23 and GND.
#include <Arduino.h>

const int PIN_LED = 23;
int conta = 0;

void setup() {
  Serial.begin(115200);          // open the Serial Monitor at the same speed
  pinMode(PIN_LED, OUTPUT);
  Serial.println("Hello, I'm the ESP32!");
}

void loop() {
  digitalWrite(PIN_LED, HIGH);
  delay(500);
  digitalWrite(PIN_LED, LOW);
  delay(500);
  conta++;
  Serial.print("Blinks: ");
  Serial.println(conta);
}

Open the Serial Monitor at 115200: after each reset you will also see the ROM lines, such as rst:0x1 (POWERON_RESET),boot:0x13; boot:0x13 means a normal boot.

The same steps in PlatformIO

Install Visual Studio Code, then from the extensions list the official PlatformIO IDE extension (it already contains everything you need). From PlatformIO Home create a New Project with the board “Espressif ESP32 Dev Module” (esp32dev) and the Arduino framework. The sketch goes in src/main.cpp and must begin with #include <Arduino.h>. This is the configuration file:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
Arduino IDE 2PlatformIO
Librariesin the IDE's shared folderper project, in lib_deps: they install themselves
Default upload speed921600460800
Default Serial Monitor speedchosen in the window9600: set monitor_speed = 115200
Compile, upload, monitorbuttons at the topbar at the bottom or Ctrl+Alt+B, Ctrl+Alt+U, Ctrl+Alt+S
Arduino-ESP32 core versionthe one chosen in the Boards Managerdepends on the espressif32 platform: 7.1.3 uses 3.3.12

Many examples out there are written for core 2.x, which has some different functions (for example the PWM ones): if an old sketch doesn't compile, check which version it was written for.

What about the Arduino UNO?

There is nothing to add: the “Arduino AVR Boards” package is already there. Choose Arduino Uno and the port. The UNO does have an LED on pin 13, so the Blink example works as it is (LED_BUILTIN). Many clones use the CH340 chip: if the upload gives the error “can't set com-state”, Arduino recommends installing version 3.7.2022.01 of the driver and blocking automatic updates.

Common mistakes

Message or symptomWhyFix
“No serial data received” or “Timed out waiting for packet header”no response: charge-only cable, wrong port or automatic reset faileddata cable, right port, monitor closed elsewhere, then hold BOOT
“Wrong boot mode detected (0x13)”the board communicates but doesn't enter upload modehold BOOT down, press EN, try again
The port doesn't show upmissing driver or cable without data wiresUSB chip driver; try another cable and another socket, no hub
Garbled characters in the monitorspeed different from the sketch's115200 on both
'LED_BUILTIN' was not declaredthe DevKitC has no LED on a pinwrite the pin number of your LED
Linux: “Permission denied”user not in the dialout groupsudo usermod -a -G dialout $USER and log in again
Upload fails only with the circuit connectedsomething on TX/RX, on GPIO 0 or 2disconnect and try again
Sources: Espressif, arduino-esp32: “Installing”, 3.3.12 release notes, boards.txt and pins_arduino.h, “Troubleshooting” · Espressif, esptool “Troubleshooting” and “Boot Mode Selection”; ESP-IDF “Establish Serial Connection with ESP32”; DevKitC V4 user guide and schematic · Silicon Labs and WCH, CP210x, CH341SER and CH343SER drivers; PlatformIO, documentation (VS Code, esp32dev, espressif32, options) · Arduino, Help Center (third-party platforms, upload problems, board not recognized, CH340 error) and UNO R3 documentation

Useful products

Other guides

All our guides →
Loading...
Back to top