iiOTESP32 Brasil
Contingency mode: public pages and downloads remain available; login, community, and server data may be unavailable.
Professional C/C++ ecosystem

How to Install and Configure PlatformIO for ESP32 in VS Code

**PlatformIO** is the industry-standard tool for compiling, flashing and debugging embedded systems. Integrated directly into **VS Code**, it removes the limitations of traditional IDEs.

platformio.ini for ESP32: Configuration Example

ESP32-S3 target

Use the block below in the platformio.ini file in your project to configure ESP32-S3 compilation.

platformio.ini
ini
1[env:esp32-s3-devkitc-1]
2platform = espressif32
3board = esp32-s3-devkitc-1
4framework = arduino
5monitor_speed = 115200

How to Install PlatformIO IDE in VS Code

1

1. Download and Install VS Code

Download the free Visual Studio Code for Windows, Linux or macOS from the official code.visualstudio.com website.

2

2. Install the PlatformIO IDE Extension

Open the Extensions tab (Ctrl+Shift+X), search for PlatformIO IDE and click Install.

3

3. Install USB-UART Drivers (CH340, CP2102, FTDI)

Make sure the USB-UART bridge drivers (CH340, CP2102 or FTDI) for your board are installed in the operating system.

This page summarizes the installation. For the complete path, with the VS Code screens step by step until the LED blinks, follow the ESP32 first steps in VS Code tutorial. For the display board, using the terminal, see the first steps with ESP32-C3 and a 1.44" LCD.

Folder Structure of an ESP32 PlatformIO Project

/src

Contains the main source code (main.cpp or auxiliary .c/.cpp files).

/include

Dedicated folder for header files and prototype definitions (.h / .hpp).

/lib

Stores custom local libraries specific to the project that are not in the global manager.

/test

Space for automated unit tests using the Unity Framework.

Arduino Framework or ESP-IDF: Which Should You Use on ESP32?

FeatureArduino FrameworkESP-IDF (Native Espressif)
Learning curveEasy / Fast prototypingIntermediate / Advanced
Hardware controlAbstracted by friendly functionsDirect access to registers and low-level APIs
Flash memory usageMedium (includes Arduino runtime)Minimal / Fully optimized
FreeRTOS supportAvailable in the backgroundNative / Seamless task integration

PlatformIO serial monitor (pio device monitor)

Open the serial terminal using the shortcut in the VS Code bottom bar or from the terminal:

pio device monitor -b 115200

ESP32 firmware upload (pio run -t upload)

Flash the compiled file directly to the ESP32 over the USB cable:

pio run --target upload

Add libraries with lib_deps in platformio.ini

Add dependencies to platformio.ini using the lib_deps directive.

pio Terminal Commands: Compile, Flash and Monitor the ESP32

Every action in the PlatformIO graphical interface has a CLI equivalent. Using pio directly in the VS Code integrated terminal is faster day to day and is the only path when you automate builds in scripts or CI pipelines.

Terminal
bash
1pio run # compile the firmware
2pio run -t upload # flash the ESP32
3pio device monitor -b 115200
4pio device list # list serial ports
5pio run -t clean # clean build artifacts
CommandWhat it does
pio runCompiles the project for the environment defined in platformio.ini.
pio run -t uploadCompiles and flashes the firmware to the ESP32 over USB.
pio device monitorOpens the serial monitor. Use -b to force the baud rate.
pio device listLists detected serial ports — useful when the board is not recognized.
pio run -t cleanDeletes build artifacts. It resolves many stubborn compilation errors.
pio pkg installDownloads the libraries declared in lib_deps.

To flash a specific port, add --upload-port COM5 on Windows or --upload-port /dev/ttyUSB0 on Linux. If the project has multiple environments in platformio.ini, select one with -e, for example pio run -e esp32-s3-devkitc-1 -t upload.

Common PlatformIO Errors with ESP32 and How to Fix Them

Error: "A fatal error occurred: Failed to connect to ESP32"

Hold the board's BOOT button when the terminal shows Connecting... or connect a 10uF capacitor between EN and GND.

Serial monitor showing strange characters (garbage)

Make sure the baud rate in monitor_speed exactly matches the value in Serial.begin(115200) in your C++ file.