Embedded Development with Platform IO

Updated: 19 March 2024

Prerequisite that you have Python 3.0 installed

PlatformIO provides a bit of a better workflow and development experience for embedded development. Creating applications can be done using the CLI or the VSCode Extension

Platform IO applications can be created using the PlatformIO VSCode Extension using the PlatformIO: PlatformIO Home command in VSCode

Once the application has been created you will have a nice way to develop embedded applications

The main thing that PlatformIO provides us in addition to the workflow is the ability to manage dependencies a little bit better as well as split code into a few different files

As far as I care, the dependency management is the main reason to use PlatformIO

Dependency management uses the platformio.ini file, a simple example of this can be seen below:

platformio-esp-8266/platformio.ini
1
; PlatformIO Project Configuration File
2
;
3
; Build options: build flags, source filter
4
; Upload options: custom upload port, speed and extra flags
5
; Library options: dependencies, extra library storages
6
; Advanced options: extra scripting
7
;
8
; Please visit documentation for the other options and examples
9
; https://docs.platformio.org/page/projectconf.html
10
11
[env:nodemcuv2]
12
platform = espressif8266
13
board = nodemcuv2
14
framework = arduino
15
lib_deps =
16
adafruit/Adafruit GFX Library@^1.11.9
17
adafruit/Adafruit SSD1306@^2.5.9

Adding dependencies can be done using the PlatformIO Registry using the relevant command which will create an entry in the platformio.ini file

You can install this using the PlatformIO CLI which is also included in the VSCode Extension via the PlatformIO: Open PlatformIO Core CLI

An example command for adding one of the libraries I have in the above example is:

Terminal window
1
pio pkg install --library "adafruit/Adafruit GFX Library@^1.11.9"