Intro

PlatformIO IDE is a VS Code Extension- a GUI wrapper around PlatformIO.

Setup

Installation

description
  • View home page for PlatformIO: Click home button at the bottom or click alien icon PIO Home Open

Create a PlatformIO Project

  1. Open the Project Wizard:
    • In Visual Studio Code, click on the PlatformIO icon (an alien head) on the left sidebar.
    • Select “New Project” to open the project creation wizard.
description
  1. Configure Your Project:
    • Project Name: Choose a descriptive name for your project (e.g., MyFirstProject).
    • Board: Select the microcontroller board you are using (e.g., Arduino Uno, ESP32, or STM32).
    • Framework: Pick the framework compatible with your board (e.g., Arduino, ESP-IDF, Mbed OS). PlatformIO will automatically determine this based on your board selection.
    • Location: Set the folder where the project will be stored. You can leave the default location or choose a custom directory.

Tip

To update the configuration manually, modify platform.ini, example:

[env:uno]
platform = atmelavr
; board = uno
framework = arduino
# Mega Uno settings
board = megaatmega2560
upload_port = COM12

Project Folder Structure:

description
  • After creating the project, PlatformIO will generate a folder structure like this:

    MyFirstProject/
    ├── include/    # Header files (optional)
    ├── lib/        # Custom libraries
    ├── src/        # Your main source code
    ├── platformio.ini # Configuration file
    
  • In Arduino IDE, most files use the .ino extension, but in PlatformIO, all your code files will be kept in the src folder, and there will be a main.cpp file


Create a sample sketch

Here’s a simple example, Arduino Uno Blink Test, demonstrating how to define and call functions:


Build and Upload Your Code

  1. Connect Your Board:

    • Plug in your microcontroller to your computer via USB.
  2. Build the Project:

    • Click the checkmark icon in the PlatformIO toolbar or use the PlatformIO: Build command from the command palette.
    • Ensure there are no errors in your code.
  3. Upload to Board:

    • Click the arrow icon to upload your code to the microcontroller.
    • Monitor the upload process in the Terminal.
  4. Open the Serial Monitor:

    • Click the plug icon in the PlatformIO toolbar to open the Serial Monitor.
    • Set the baud rate to match your Serial.begin() call (e.g., 9600).

Related