How to use PlatformIO with VS Code
Projects with firmware in this repository use the same structure:
firmware/
├── platformio.ini
└── src/
└── main.cpp
The platformio.ini file identifies the board and framework. The main code is located in src/main.cpp.
1. Install Visual Studio Code
- Visit the official VS Code download page.
- Choose Windows, macOS, or Linux and complete the installation.
- Open VS Code.
2. Install PlatformIO
- In VS Code, open Extensions in the sidebar.
- Search for PlatformIO IDE.
- Install the official extension published by PlatformIO.
- Wait for the installation to finish and restart VS Code if requested.
You do not need to install PlatformIO Core separately: it is included with the extension. You can also read the official PlatformIO documentation for VS Code.
3. Open a project from this repository
- Open the project's folder inside
projects/. - In VS Code, select File > Open Folder.
- Open the project's
firmware/folder specifically. It contains the - Wait while PlatformIO prepares the board tools the first time you open it.
platformio.ini file.
Do not open only the main.cpp file: PlatformIO needs the folder containing platformio.ini to be open.
4. Build and upload to the board
Use the PlatformIO buttons in the bottom bar of VS Code:
- ✓ Build: checks and compiles the code;
- → Upload: compiles and uploads the program to the board connected by USB;
- Plug Monitor: opens the serial monitor.
The same actions are available under PlatformIO > Project Tasks. The official documentation explains the Build, Upload, and Serial Monitor tools.
If the project has more than one board configured, select the correct PlatformIO environment. The Tamagotchi project, for example, has environments for Arduino Uno and Arduino Nano.
5. Before uploading
- Connect the board using a USB cable that also supports data transfer.
- Check that the board model matches the environment in
platformio.ini. - Close the serial monitor before uploading if the port is busy.
- If there is more than one USB port, select the correct port in the PlatformIO tasks.
Special setup for Byte do Milhão
The esp-control firmware uses Wi-Fi and server information. Inside firmware/include/, copy config.example.h to config.h and replace all TODO values. The real configuration file is ignored by Git to prevent Wi-Fi passwords from being published.