Maker tech hub - AI · 3D print · Pi · ESP32 · plus the classic tech archive.

Free ESP32 kit · AI tools directory · Books · Archive

Guide · Beginner · ESP32

PlatformIO vs Arduino IDE for ESP32 in 2026

When PlatformIO pays off: envs, libraries, and CI-friendly firmware.

Written by

Avery J. Parker

IT veteran, maker educator, and author of Network Ninja, 3D Printing Mastery, and AI Workflow Mastery. Business IT: Diversified Tech Solutions.

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 .ino file.
  • PlatformIO is a build system and package manager, usually used through its VS Code extension or the pio command line tool. A project is a folder with a platformio.ini file, a src/ directory, and optional lib/ and test/ 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

  1. Create a project with the matching board, or write platformio.ini by hand.
  2. Rename your .ino file to src/main.cpp.
  3. Add #include <Arduino.h> at the top.
  4. Declare functions before they are used, or add prototypes. The Arduino IDE generates prototypes for you; a plain C++ build does not.
  5. Add each library to lib_deps with a version, instead of relying on whatever is installed globally.
  6. Set monitor_speed to match Serial.begin(), then build, upload, and open the monitor.

Common mistakes and fixes

SymptomLikely causeFix
"was not declared in this scope" after moving to PlatformIOMissing prototypesDeclare functions above setup() or move them to a header
Builds on one machine, fails on anotherUnpinned platform or librariesPin versions in platformio.ini
Garbled serial monitorMonitor speed mismatchMatch monitor_speed to Serial.begin()
Wrong pins or missing PSRAMBoard definition does not match your modulePick the closest board ID and check its variant pin map
A newer Arduino-ESP32 feature is missingPlatform version lags the Espressif core you read aboutCheck 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