Back

VsCode & PlatformIO

VsCode & PlatformIO

Installation

1. VSCode

Download: https://code.visualstudio.com/


2. PlatformIO Extension

  1. Select the Extensions tab
  2. Enter "PlatformIO" in the search
  3. Select PlatformIO from the search results
  4. Install PlatformIO. VSCode will restart after installation.

Creating a Project

  1. Select the PlatformIO extension
  2. Choose PIO Home
  3. Select New Project
  1. Select Board & Framework:
  • Board: ATmega328P (or Arduino Uno).
  • Framework: None.
  1. Wait for PlatformIO to create the project.

PlatformIO Folder Structure

  1. .pio: Contains build files, libraries, and more.
  2. .vscode: Contains configurations for VSCode. Changes here are usually not necessary.
  3. include: Header files can be placed here.
  4. lib: Libraries for the project.
  5. src: Main code files. Your main.c belongs here.
  6. test: For unit tests.
  7. platformio.ini: Central configuration file for PlatformIO.

platformio.ini

The platformio.ini is the central configuration file. Example configuration for ATmega328:

[env:atmega328p]
platform = atmelavr
board = atmega328p
framework = none         // if you use Arduino write it here.
upload_protocol = COM9   // look for your device port

The platformio.ini is the central configuration file for the project. Multiple environments (e.g., env:esp32dev) can be created to quickly switch between production and debugging. The file format is in YAML, so be careful with the indentation.

More info here:
Project Configuration
Environment Variables


Build, Debug, Upload

  1. PIO Home - Opens the PlatformIO homepage
  2. Build - Build the project
  3. Upload - Upload the project to the microcontroller
  4. Clean - Clean build files
  5. Test - Start unit tests or invoke the environment for testing
  6. Serial Monitor - Serial communication
  7. Terminal - A terminal with loaded PIO variables
  8. Environment - Quickly switch the environment
  9. Serial Monitor Config - Settings for the serial monitor

More info here: https://docs.platformio.org/en/latest/projectconf/build_configurations.html