Simple quick start "blink" using PlatformIO on boards: Uno
, DOIT ESP32 DevKit v1
, NodeMCU v1.0 (ESP-12E)
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
vi ~/.bashrc
(or .profile or zshrc...) and addexport PATH="$PATH:~/.platformio/penv/bin"
- close your terminal and reopen or
source ~/.bashrc
to reload the PATH - (optional) activate the virtual environment,
. activate
which should now be in the PATH - can you run the cli?
pio
? if not go here, https://docs.platformio.org/en/latest/installation.html
- Just search for and install the extension
PlatformIO
- Open
settings.json
in VSCode (from the Command Palette typePreferences Open Settings (JSON)
) - Add the following (inside
{...}
),note, customPATH probably isn't necessary since we added it to the"platformio-ide.customPATH": "~/.platformio/penv/bin", "platformio-ide.useDevelopmentPIOCore": true
PATH
- Restart VSCode
The following is based on, https://docs.platformio.org/en/latest/quickstart.html
In step 3 the three boards are boards I am planning on using in this project. To use other boards just run pio boards
and find the ID of the boards(s)
- Open VSCode then open the folder the project will live
- Open a terminal (preferably in VSCode) can
cd
to your working folder - run
pio project init -b esp32doit-devkit-v1 -b nodemcuv2 -b uno
- this will create a new file platformio.ini a Travis CI file, and some scaffolding, include, src, lib, test folders
- confirm the platformio.ini contains the boards,
[env:esp32doit-devkit-v1] board = esp32doit-devkit-v1 framework = arduino platform = espressif32 [env:nodemcuv2] board = nodemcuv2 framework = arduino platform = espressif8266 [env:uno] board = uno framework = arduino platform = atmelavr
- use the cli an run ,
pio run
this will take a minute to fetch the board firmware and build it. Look in the newly created folder /.pio to see what is pulled down - once everything is built then you need to upload the program (/src/main.cpp) to a board, this example uploads to the ESP8266 board,
pio run -e nodemcuv2 -t upload
. Note, if you have all your boards connected via a serial port then you don't need to specify-e
or which environment to upload to
That is it, your board should be flashing. Note, in main.cpp your LED_BUILTIN pin may be 13 (Uno), verify your board's schematics for the pin usage.
pio device monitor -b 115200
This project doesn't need VSCode or the PlatformIO extension in VSCode. If you look closely at the commands executed, all that is needed is PlatformIO Core and the included CLI.