Cheat Sheet Library

PlatformIO Cheat Sheet

A professional embedded build system, usually used as a VS Code extension. Supports Arduino, ESP-IDF, STM32, RP2040 and more, with per-project library versions.

  • 28 entries
  • 6 sections
  • Updated
  • Click a command to see all its options

28 entries

On this page

VS Code Shortcuts #

ShortcutAction
Ctrl + Alt + BBuild
Ctrl + Alt + UUpload
Ctrl + Alt + SSerial monitor
PlatformIO icon (sidebar)Project tasks, libraries, boards, PIO Home

CLI (pio) #

CommandAction
New project in the current folder
Build all environments
Build one environment
Build and upload
Upload to a specific port
Clean the build
Upload the data/ folder (LittleFS / SPIFFS)
ESP-IDF configuration menu
Connected serial ports
Serial monitor (Ctrl + C to exit)
Add a library to the project
Update packages
Installed packages
Search board IDs
Run unit tests
Static code analysis
Update PlatformIO itself

Project Layout #

project/
├── platformio.ini     # configuration
├── src/main.cpp       # your code
├── include/           # headers
├── lib/               # private libraries
├── data/              # files for the filesystem (uploadfs)
└── test/              # unit tests

platformio.ini Example #

[platformio]
default_envs = esp32dev

[env]                              ; shared by all environments
framework = arduino
monitor_speed = 115200
lib_deps =
    bblanchon/ArduinoJson@^7.0.0
    adafruit/Adafruit BME280 Library

[env:esp32dev]
platform = espressif32
board = esp32dev
board_build.filesystem = littlefs
build_flags = -DDEBUG=1

[env:esp32s3]
platform = espressif32
board = esp32-s3-devkitc-1
build_flags = -DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters = esp32_exception_decoder, time

Useful ini Options #

OptionUse
upload_port = COM5 / /dev/ttyUSB0Fix the upload port
upload_speed = 921600Faster uploads
monitor_filters = esp32_exception_decoderDecode crash backtraces
build_flags = -DVERSION=\"1.0\"Defines / compiler flags
build_src_filter = +<*> -<old/>Exclude files
board_build.partitions = huge_app.csvCustom partition table
extends = env:esp32devInherit from another environment

Tips #

  • Commit platformio.ini and src/, ignore .pio/.
  • Arduino sketches: rename .ino to .cpp, add #include <Arduino.h> and declare functions before using them.
  • A "Library not found" error usually means it's missing from lib_deps.