Home | Difficulty level | Beginner | Install the IDE PlatformIO extension for Visual Studio Code (VSCode): Windows, 32-bit Linux

Install the IDE PlatformIO extension for Visual Studio Code (VSCode): Windows, 32-bit Linux

PlatformIO is available as an extension for Visual Studio Code (also called VSCode) from Microsoft. VSCode is a free lightweight code editor for Windows, MacOS, 32-bit Linux and 64-bit. Installing the PlatformIO extension for VSCode is a good alternative to the official Atom-based solution. VSCode is a code editor much lighter than Atom. Available on all environments, including 32-bits, this is a great solution if you want to recycle an old PC in development station.

Install Visual Studio Code (VSCode) for Windows, macOS, or Linux

Go to the official VSCode page to download and install the version that fits your environment.

  • Windows : installer ou ZIP
  • macOS : dmg
  • Linux 32-bits : .deb, .rpm, .tag.gz
  • Linux 64-bits : .deb, .rpm, .tag.gz

platformio visual studio code 0 installation

Installing the PlatformIO IDE package

VSCode works very similar to Sublime Text (good ideas are often copied …). Invoke the extension manager with the CTRL + P key combination (or Cmd + P under macOS).

In the field that appears at the top of the screen, type ext platformio-ide. This command starts the search for the extension on the market and opens the extension manager with the results.

platformio visual studio code 1 search extension

There are two extensions available PlatformIO IDE and PlatformIO IDE. The first (least downloaded) is the official version. The second is an alternative extension developed by the developer Jun Han. The operation is similar. Jun Han does not have the Initialize or Update Project feature that allows you to easily add maps or create a new project. You choose. For this tutorial, I opted for the official extension.

Click Install. As with Atom, VSCode launches the necessary dependencies installation. There is absolutely nothing else to do. It is always the same magic that operates.

platformio visual studio code 2 install dependances

In passing you will notice that VSCode installs Clang for the self-completion of the C / C ++ code.

How to use the PIO extension

The Visual Studio Code extension provides shortcuts to the main functions of the PlatformIO SDK. They are accessible in 2 ways:

  • From the command palette that is called with the key combination Ctrl (or Cmd on macOS) + Shift + P and then entering the keyword platformio

platformio visual studio code 3 ctrl shif p palette command

  • Finally from an icon bar (similar to the one we have on Atom) at the bottom of the screen. It is presented in detail just after

platformio visual studio code 4 icone tools

The Jun Han extension also adds options in the context menu (right click).

The integration of the SDK is much less important than under Atom, but the main functions are:

  • Build
  • Upload
  • Clean
  • Initialize or update project
  • Library Manager
  • Terminal
  • Rebuild c / C ++ index
  • Serial Monitor

Create a new project

First, create a new (empty) folder for your new project. Then open this folder File> Open Folder (Ctrl + O). From the toolbar, call the Initialize or update project function or Ctrl + Shift + P and then Initialize. Find the desired map by typing the first letters. Here ESP32.

platformio visual studio code 5 initialize project

PIO prepares the tree and creates the platformio.ini configuration file.

platformio visual studio code 5 new project

Right-click the src folder and then click New File. Give a name and cpp as an extension. Add the following structure as the program base. You can code as on the Arduino IDE or Atom!

Icon bar

The icon bar under Atom is also present on VSCode. It is much less visible. It is located in the lower bar.

platformio visual studio code 4 icone tools

There are the main functions:

  • Build: code compilation
  • Upload: upload the code. Card detection is automatic
  • Clean: Empty the .penv folder that contains the compiled firmware for the various project platforms
  • Run a task: Convenes the PlatformIO menu. This is the equivalent of Ctrl (or Cmd on macOS) + Shift + P then platformio
  • Initialize or Update Project: Update or create a new project
  • Library Manager: Opens the Terminal and displays the available commands (see below for more details)
  • Serial Monitor: starts the serial monitor. Communication is initiated on the first detected COM port
  • Terminal: Opens Terminal or Power Shell on Windows

Problem with the Series Monitor: Manually adjust the speed

By default, the serial port is set to 9600 baud on the official extension. Jun Han added a setting to set the speed. To use a different speed, open the Terminal and run the following command

  • -b : baudrare
  • 115200 : 115200 bauds

Visual Studio Code is a very good alternative to the Atom editor. Very light, it starts much faster than Atom. It will also fit very well in a light configuration or a recycled PC running 32-bit Linux. You will be a little less guided than on Atom which remains PlatformIO’s official development platform. The SDK is very well documented, the grip is very fast.