Phase 2: Setup & Development 14 min read read

VS Code with ESP32: PlatformIO and ESP-IDF Extension Setup Guide

Set up VS Code for ESP32 development using PlatformIO or the Espressif IDF extension. Covers IntelliSense configuration, JTAG debugging, CMake integration, and recommended extensions.

Updated June 18, 2026

Why VS Code for ESP32?

VS Code is the editor of choice for the majority of ESP32 developers who move beyond the Arduino IDE. Its combination of a first-class editing experience (IntelliSense, multi-cursor editing, split panes, integrated terminal), deep Git integration, and a rich extension marketplace makes it a significant productivity upgrade over the Arduino IDE’s basic text editor. Two official extensions bring ESP32 development into VS Code: the PlatformIO IDE extension (for Arduino framework development) and the ESP-IDF VS Code Extension by Espressif (for native IDF development).

Installing VS Code

Download VS Code from code.visualstudio.com. It is available for Windows, macOS, and Linux. The installer is 100 MB and the app launches in under 5 seconds on modern hardware. VS Code is updated monthly — accept updates when prompted; updates never break existing projects because extensions and project settings are stored independently from the application binary.

After installation, install the C/C++ extension from Microsoft (search “C/C++” in the Extensions sidebar, Ctrl+Shift+X) — this provides IntelliSense for C and C++ code. You do not need to configure it separately; both PlatformIO and the IDF extension configure it automatically as part of their project setup.

Option A: PlatformIO IDE Extension

PlatformIO is the most popular extension for Arduino framework ESP32 development in VS Code. Install it from the Extensions sidebar: search “PlatformIO IDE” and click Install. After installation (it downloads toolchains in the background — this takes several minutes), the PlatformIO icon (a circular design) appears in the left activity bar.

Creating Your First PlatformIO ESP32 Project

  1. Click the PlatformIO icon → “New Project”
  2. Name: My_ESP32_Project
  3. Board: Search “ESP32 Dev Module” and select it
  4. Framework: Arduino
  5. Location: (choose a folder)
  6. Click Finish

PlatformIO creates the project structure and downloads the ESP32 platform (toolchain + framework) if not already installed. Open src/main.cpp — it contains a starter template with #include <Arduino.h>, setup(), and loop(). Write your code here exactly as you would in Arduino IDE.

The PlatformIO toolbar appears at the bottom status bar of VS Code:

  • ✓ (checkmark) — Build/Compile
  • → (right arrow) — Upload
  • 🔌 (plug) — Serial Monitor
  • ⬆ (upload with monitor) — Upload + open monitor

Configuring platformio.ini

All project configuration lives in platformio.ini at the project root. A full configuration for an ESP32 project:

[env:esp32dev]
platform        = espressif32
board           = esp32dev
framework       = arduino
monitor_speed   = 115200
monitor_filters = esp32_exception_decoder  ; decode crash stack traces automatically
upload_speed    = 921600
build_flags     =
  -DCORE_DEBUG_LEVEL=2
  -DBOARD_HAS_PSRAM

lib_deps =
  bblanchon/ArduinoJson @ ^7.0.4
  knolleary/PubSubClient @ ^2.8.0
  adafruit/Adafruit_BME280_Library @ ^2.2.4

The esp32_exception_decoder monitor filter is particularly valuable — when the ESP32 crashes and prints a stack trace (hex addresses), the filter automatically decodes it into function names and line numbers, showing you exactly where in your code the crash occurred.

Option B: Espressif IDF Extension

The ESP-IDF extension by Espressif is the official tool for native IDF development in VS Code. Install it from the Extensions sidebar: search “ESP-IDF” by Espressif Systems and install it.

On first use, run the command “ESP-IDF: Configure ESP-IDF extension” (Ctrl+Shift+P, type “ESP-IDF Configure”). The setup wizard asks you to:

  1. Choose express or advanced setup mode (express is fine for most users)
  2. Select your Python executable
  3. Choose the ESP-IDF version to download (or point to an existing installation)
  4. Choose the tools download directory

Express mode downloads ESP-IDF and all toolchains automatically — about 15–20 GB total. When complete, the IDF extension is fully configured.

IDF Extension Key Commands

All IDF extension commands are available through the VS Code command palette (Ctrl+Shift+P):

  • ESP-IDF: Build your Project — equivalent to idf.py build
  • ESP-IDF: Flash your Project — equivalent to idf.py flash
  • ESP-IDF: Monitor Device — equivalent to idf.py monitor
  • ESP-IDF: Launch GUI Menuconfig Tool — opens menuconfig in a VS Code webview panel
  • ESP-IDF: Set Espressif Device Target — sets the chip target (esp32, esp32s3, etc.)
  • ESP-IDF: Create project from Extension Template — creates a new IDF project with CMakeLists.txt

The IDF extension also adds a sidebar panel showing your project components, available examples, and a GUI menuconfig — a significant improvement over the terminal-based menuconfig for configuration-heavy projects.

Setting Up JTAG Hardware Debugging

JTAG debugging requires a hardware probe. Common options:

  • ESP-Prog — Espressif’s official JTAG+UART programmer, ~$15, plug-and-play with both extensions
  • J-Link EDU — Segger’s popular debug probe, excellent software support, ~$60
  • FTDI FT2232H breakout — budget option, requires manual OpenOCD configuration

For PlatformIO, add to platformio.ini:

debug_tool  = esp-prog
debug_init_break = tbreak app_main

Press F5 to start debugging. VS Code enters debug mode: a debug toolbar appears at the top, the Variables panel shows current variable values, the Call Stack panel shows the function call chain, and you can set breakpoints by clicking the gutter (red dot) next to any line. Execution pauses at each breakpoint, letting you inspect state without any Serial.print statements.

Recommended Extensions for ESP32 Development

Extension Purpose
PlatformIO IDE Full ESP32 Arduino framework build, upload, monitor
ESP-IDF (Espressif) Native IDF development, menuconfig GUI, component management
C/C++ (Microsoft) IntelliSense, syntax highlighting, error detection
GitLens Enhanced Git — blame annotations, history browsing, comparison
Better Comments Colour-coded comment types (TODO, FIXME, NOTE, WARN)
Hex Editor (Microsoft) View and edit binary files, .bin firmware images
Remote – SSH Develop on a remote Linux machine or Raspberry Pi
Error Lens Shows compiler errors inline at the problematic line

Useful VS Code Settings for ESP32 Projects

Add these to your VS Code settings.json (Ctrl+Shift+P → “Open User Settings JSON”) for a more comfortable ESP32 development experience:

{
  "editor.formatOnSave": false,         // don't auto-format; C++ style varies
  "editor.tabSize": 4,                  // 4-space indentation
  "files.trimTrailingWhitespace": true, // clean commits
  "terminal.integrated.shell.windows": "cmd.exe",  // for IDF CMD compatibility
  "C_Cpp.intelliSenseEngine": "default",
  "C_Cpp.default.cStandard": "c17",
  "C_Cpp.default.cppStandard": "c++17"
}

These settings are personal preferences — adjust them to match your team’s coding style. The C++ standard settings (c17, c++17) match the standard the ESP32 Arduino core uses, preventing false IntelliSense errors for C17/C++17 features.

Frequently Asked Questions

Projects to Build

Put this knowledge to work — try one of these hands-on projects.