VS Code + PlatformIO for ESP32: the environment I use every day

How to get VS Code + PlatformIO ready for the ESP32: installation, platformio.ini, upload and monitor, per-project libraries and debugging.

Also available in: EN, ES

Series Introduction to the ESP32 Part 17 View the series →
VS Code with PlatformIO and the ESP32

If I had to keep just one environment for the ESP32, it would be this one. PlatformIO turns VS Code into a real IDE: build, upload, monitor and debugging, with the project config in a text file.

Installation

  1. Install VS Code.
  2. In Extensions, search PlatformIO IDE and install it.
  3. Wait for it to prepare the toolchain the first time.

That is it. PlatformIO downloads compilers and tools for you.

Create a project

PlatformIO Home → New Project: name, board (Espressif ESP32 Dev Module) and framework (Arduino or ESP-IDF). The structure it generates:

my-project/
├── platformio.ini     # configuration
├── src/main.cpp       # your code
└── lib/               # your own libraries

platformio.ini: the heart

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
upload_speed = 921600

Switching board is changing one line. This is gold when you have several projects:

[env:s3]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200

[env:c3]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino

Pick the environment in the bottom bar and upload.

Upload and monitor

In the status bar:

  • ✓ Build — compile.
  • → Upload — compile and flash.
  • 🔌 Serial Monitor — open the monitor at your configured baud.

Or from the terminal:

pio run -t upload
pio device monitor

Per-project libraries

Instead of installing them globally, you declare them:

lib_deps =
    adafruit/Adafruit BME280 Library@^2.2.4
    knolleary/PubSubClient@^2.8

Huge advantage: the project carries its own versions. If a library breaks tomorrow, your code stays the same.

Debugging

With a board that supports it (ESP32-S3/C3) and a JTAG probe:

debug_tool = esp-builtin

And you get real breakpoints, not printf. It is the quality jump once the project grows.

What I like (and what I do not)

Pros: one environment for almost everything, versionable config, per-project dependencies, real debugging, cross-platform.

Cons: the first build downloads a lot; and if you are new, there are more concepts than in the Arduino IDE.

Summary

  • Install PlatformIO IDE in VS Code and forget the rest.
  • All configuration lives in platformio.ini (versionable).
  • lib_deps pins libraries per project, not globally.
  • Switching board is one line: great for one env per variant.
  • With JTAG you get real debugging.

Next step: VS Code + ESP-IDF if you go deep with the official SDK. Or go back to the series hub.

Related posts

↑↓ navigate ↵ open Esc close