Guide · Beginner · ESP32
PlatformIO vs Arduino IDE for ESP32 in 2026
When PlatformIO pays off: envs, libraries, and CI-friendly firmware.
In this guide
- Goal & materials
- Steps / firmware
- Troubleshooting
- AI assist notes
- Related gear & books
Both tools build the same Arduino-framework firmware for the ESP32, so this is not a question of which one "works." It is a question of how much structure your project needs. The Arduino IDE is the fastest way to get a first sketch running. PlatformIO pays off once you have more than one board, more than one library, or more than one person touching the code.
What each tool actually is
- Arduino IDE 2.x is a desktop editor with a Boards Manager (install "esp32 by Espressif Systems"), a Library Manager, a serial monitor, and one-click upload. A project is a sketch folder with an
.inofile. - PlatformIO is a build system and package manager, usually used through its VS Code extension or the
piocommand line tool. A project is a folder with aplatformio.inifile, asrc/directory, and optionallib/andtest/directories. - arduino-cli sits in between: the Arduino toolchain from the command line, handy for scripting and CI if you want to stay with Arduino tooling.
When the Arduino IDE is the right call
- First projects, classrooms, and quick tests where getting a blink and a serial print matters more than structure.
- Single-file sketches with one or two well-known libraries.
- Following a tutorial written for the Arduino IDE, where matching the author's setup removes variables.
The weak spot is reproducibility. Board package and library versions live in your user profile, not in the project, so the same sketch can build differently on another machine or after an update.
When PlatformIO pays off
Pinned versions per project
Everything that affects the build can live in platformio.ini, which you commit with the code:
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
knolleary/PubSubClient@^2.8
build_flags =
-DSENSOR_INTERVAL_MS=5000
Pin the platform to a specific version (for example platform = espressif32@6.x.y with the version you tested) and use exact or caret versions in lib_deps. A teammate or a CI runner then gets the same toolchain you used.
Multiple environments
One codebase, several targets. Add an section for each board or build variant, such as a classic ESP32 DevKit and an ESP32-S3, or a debug build with verbose logging and a release build without. pio run -e esp32dev builds just one.
Real project layout
Code can be split into normal .cpp and .h files, with shared code in lib/. That matters once a sketch grows past a few hundred lines.
Tests and CI
pio test runs unit tests, either on the board or natively on your computer for logic that does not touch hardware. A CI job (GitHub Actions, GitLab CI, or similar) can run pio run on every push so a broken build shows up before anyone flashes a board.
Moving a sketch to PlatformIO
- Create a project with the matching board, or write
platformio.iniby hand. - Rename your
.inofile tosrc/main.cpp. - Add
#include <Arduino.h>at the top. - Declare functions before they are used, or add prototypes. The Arduino IDE generates prototypes for you; a plain C++ build does not.
- Add each library to
lib_depswith a version, instead of relying on whatever is installed globally. - Set
monitor_speedto matchSerial.begin(), then build, upload, and open the monitor.
Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| "was not declared in this scope" after moving to PlatformIO | Missing prototypes | Declare functions above setup() or move them to a header |
| Builds on one machine, fails on another | Unpinned platform or libraries | Pin versions in platformio.ini |
| Garbled serial monitor | Monitor speed mismatch | Match monitor_speed to Serial.begin() |
| Wrong pins or missing PSRAM | Board definition does not match your module | Pick the closest board ID and check its variant pin map |
| A newer Arduino-ESP32 feature is missing | Platform version lags the Espressif core you read about | Check which Arduino-ESP32 core version your platform release bundles before upgrading |
That last row deserves attention. The Arduino-ESP32 core and the PlatformIO espressif32 platform are released separately, and support for new core versions has not always landed in PlatformIO at the same time. Before chasing a new API, confirm which core your pinned platform actually includes.
A practical rule
Start in whichever tool gets you to a working board fastest. Move to PlatformIO when any of these become true: you need the project to build the same way next year, you target more than one board, you want automated builds, or the code no longer fits comfortably in one file.
Summary
The Arduino IDE wins the first hour. PlatformIO wins the project you still maintain months later, because versions, board variants, tests, and build flags live in the repository instead of on one person's laptop.
Related
- Projects hub
- Newsletter
- Books for deeper reading