PlatformIO is an IDE built on top of other IDE, in other words, PlatformIO is a Plugin for a various source-code editor or IDE like Visual Studio Code, Atom, Eclipse, Visual Studio, and some more.
Setting up PlatformIO is somewhat simple, maybe little more complex than Arduino IDE (just some setup is required for boards other than Arduino 🙂 ).
- Download Visual Studio Code.
- Install PlatformIO extension.
- Create a new project for a specific board.
- Configure to include external libraries.
Note: We can do this by Atom also, but for code completion, it requires other software to be installed(in Windows) and also it’s little slower than VSCode (Visual Studio Code).
Why Use PlatformIO on Visual Studio Code
- PlatformIO is a full-fledged IDE for many development boards and MCUs, like Arduino boards, ESP8266 based boards, Raspberry Pi and more.
- It has a total of 600+ supported boards at the time of writing this article.
- Basic features like Code completion, definition peeking of function or method.
- Project management, external library updater, debugging, unit testing.
- Visual Studio Code opens a lot faster than the Arduino IDE.
In my laptop Vscode opens in 5 seconds and Arduino IDE 15 seconds.
1. Download Visual Studio Code
Visual Studio Code is a source code editor software, or you can say an advanced text editor which can be used as in IDE or Code-editor.
So just download and install from here. And install 😐 .
2. Install PlatformIO Extension
It will take a couple of minutes, you may see terminal at the lower screen in VSCode saying displaying PlatformIO installation, Don’t close the VSCode at this time. Like This,
After that create a project.
For example, if you don’t know what Framework to choose, select Arduino.
You can change the location of the project, but for I chosen Default for simplicity. 🙂
3. Understand PlatformIO Basics
PlatformIO is a lot a better than Arduino IDE and of course it’s somewhat complex.
Unlike Arduino where main file name (.ino) must be in a folder named same as the main file.
Folder Structure of PlatformIO is:-
Let’s Understand these files/folders
Put external libraries here, just like you put libraries downloaded from the internet in Arduino Library Folder.
But these libraries will be limited to that project only, we will fix this later next section.
Configuration for the current project. Here you can define folder location to external libraries, add this line to it,
lib_extra_dirs = C:\example_folder\lib
Reference: Read More here
Where folder C:\example_folder\lib is the folder where the folder of libraries exists. Then add above line to every PlatformIO project you create, so it will be visible to all the projects you want.
OR, you can just also put libraries in “C:\Users\user_name\.platformio\lib“, no need to change platformio.ini.
The main file to compile and upload will be here.
Also called source folder.
The main file where you will write your Arduino code.
It’s in .cpp extension not .ino because some IDE don’t support .ino files as it’s not valid C/C++ file.
In I will tell how to configure PlatformIO for NodeMCU with OTA Update feature.
Thanks for Reading, Share the joy with friends if you like the post.