PlatformIO IDE for VScode

PlatformIO IDE is the next-generation integrated development environment for IoT.


Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Python, PHP, Go) and runtimes (such as .NET and Unity)

../../_images/platformio-ide-vscode.png

Installation

Note

Please note that you do not need to install PlatformIO Core separately if you are going to use PlatformIO IDE for VScode. PlatformIO Core is built into PlatformIO IDE and you will be able to use it within PlatformIO IDE Terminal.

  1. Download and install official Microsoft Visual Studio Code. PlatformIO IDE is built on top of it

  2. Open VSCode Package Manager

  3. Search for official platformio-ide package

  4. Install PlatformIO IDE.

../../_images/platformio-ide-vscode-pkg-installer.png

Quick Start

This tutorial introduces you to the basics of PlatformIO IDE workflow and shows you a creation process of a simple “Blink” example. After finishing you will have a general understanding of how to work with projects in the IDE.

Setting Up the Project

  1. Create empty directory (or use existing) and open it via File > Open...

../../_images/platformio-ide-vscode-open-folder.png
  1. Initialize PlatformIO Project using one of these methods:

    • Run “Initialize or Update Project” command using ctrl+alt+i hotkey

    • Launch “VS Code Menu: View > Command Palette…” or use hotkey Ctrl+Shift+P (Cmd+Shift+P for macOS), search for PlatformIO: Initialize or Update Project, and press enter

  2. Select a board. You can change it any time in Project Configuration File platformio.ini or add new using the same PlatformIO: Initialize or Update Project command.

../../_images/platformio-ide-vscode-select-board.png
  1. Create FREE PIO Account which opens access to extra features, such as:

Please open PIO Terminal using PlatformIO Toolbar PIO_VSCODE_TOOLBAR_TERMINAL

  1. Create New File named main.cpp in src folder

../../_images/platformio-ide-vscode-new-src-file.png
  1. Copy the next source code to the just created file main.cpp

Warning

The code below works only in pair with Arduino-based boards. Please follow to PlatformIO Project Examples repository for other pre-configured projects.

/**
 * Blink
 *
 * Turns on an LED on for one second,
 * then off for one second, repeatedly.
 */
#include "Arduino.h"

// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 13

void setup()
{
  // initialize LED digital pin as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);

  // wait for a second
  delay(1000);

  // turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);

   // wait for a second
  delay(1000);
}
  1. Build your project with ctrl+alt+b hotkey (see all Key Bindings in “User Guide” section below)

../../_images/platformio-ide-vscode-build-project.png
  1. Learn more about PlatformIO Toolbar and other commands (Upload, Clean, Serial Monitor, Library Manager, Run Other Tasks) in “User Guider” section.

Happy coding with PlatformIO!

User Guide

PlatformIO Toolbar

PlatformIO IDE Toolbar is located in VSCode Status Bar (left corner) and contains quick access buttons for the popular commands. Each button contains hint (delay mouse on it).

../../_images/platformio-ide-vscode-toolbar.png
  • PlatformIO: Build

  • PlatformIO: Upload

  • PlatformIO: Clean

  • PlatformIO: Run Other Tasks

  • Initialize new PlatformIO Project or Update existing…

  • Library Manager

  • Serial Port Monitor

  • PIO Terminal

Key Bindings: Building / Uploading / Other Tasks

  • ctrl+alt+i Initialize or Update Project

  • ctrl+alt+b / cmd-shift-b / ctrl-shift-b Build Project

  • cmd-shift-d / ctrl-shift-d Debug project

  • ctrl+alt+u Upload Firmware

  • ctrl+alt+s Open Serial Port Monitor

  • ctrl+alt+t Run Other Tasks (Upload using Programmer, Upload SPIFFS image, Test Project, Update packages and libraries, Upgrade PlatformIO Core)

Extension Settings

platformio-ide.useBuiltinPIOCore

Use built-in PlatformIO Core, default configuration is true.

platformio-ide.useDevelopmentPIOCore

Use development version of PlatformIO Core, default configuration is false.

platformio-ide.autoRebuildAutocompleteIndex

Automatically rebuild C/C++ Project Index when Project Configuration File platformio.ini is changed or when new libraries are installed, default configuration is true.

platformio-ide.customPATH

Custom PATH for platformio command. Paste here the result of echo $PATH (Unix) / echo %PATH% (Windows) command by typing into your system terminal if you prefer to use custom version of PlatformIO Core, default configuration is null.

Serial Port Monitor

You can customize Serial Port Monitor using Monitor options in Project Configuration File platformio.ini:

Example:

[env:esp32dev]
platform = espressif32
framework = arduino
board = esp32dev

; Custom Serial Monitor port
monitor_port = /dev/ttyUSB1

; Custom Serial Monitor baud rate
monitor_baud = 115200

Install Shell Commands

Please navigate to FAQ Install PIO Core Shell Commands.

PIO Account

Create FREE PIO Account which opens access to extra features, such as:

Please open PIO Terminal using PlatformIO Toolbar PIO_VSCODE_TOOLBAR_TERMINAL