### PlatformIO Board Configuration Examples Source: https://docs.platformio.org/en/stable/boards/ststm32/grasshopper_l082cz Complete PlatformIO configuration examples for the Grasshopper-L082CZ board. Shows basic setup, hardware parameter overrides, and upload protocol selection. Each configuration example demonstrates different aspects of board customization and project setup. ```ini [env:grasshopper_l082cz] platform = ststm32 board = grasshopper_l082cz ``` ```ini [env:grasshopper_l082cz] platform = ststm32 board = grasshopper_l082cz ; change microcontroller board_build.mcu = stm32l082czy6 ; change MCU frequency board_build.f_cpu = 32000000L ``` ```ini [env:grasshopper_l082cz] platform = ststm32 board = grasshopper_l082cz upload_protocol = dfu ``` -------------------------------- ### PlatformIO OLIMEX ESP32-PoE Configuration Examples Source: https://docs.platformio.org/en/stable/boards/espressif32/esp32-poe Configuration examples for PlatformIO project targeting OLIMEX ESP32-PoE board. Shows basic setup, board parameter overrides, and upload protocol selection. Requires PlatformIO Core or IDE with espressif32 platform support. ```ini [env:esp32-poe] platform = espressif32 board = esp32-poe ``` ```ini [env:esp32-poe] platform = espressif32 board = esp32-poe ; change microcontroller board_build.mcu = esp32 ; change MCU frequency board_build.f_cpu = 240000000L ``` ```ini [env:esp32-poe] platform = espressif32 board = esp32-poe upload_protocol = esptool ``` -------------------------------- ### USB Host Shield Example Configuration Source: https://docs.platformio.org/en/latest/integration/ci/appveyor Complete AppVeyor configuration example for USB_Host_Shield_2.0 project, demonstrating multiple test cases and external library dependencies. ```YAML build: off environment: matrix: - PLATFORMIO_CI_SRC: "examples\\Bluetooth\\PS3SPP\\PS3SPP.ino" - PLATFORMIO_CI_SRC: "examples\\pl2303\\pl2303_gps\\pl2303_gps.ino" install: - cmd: git submodule update --init --recursive - cmd: SET PATH=%PATH%;C:\Python27\Scripts - cmd: pip install -U platformio - cmd: git clone https://github.com/xxxajk/spi4teensy3.git C:\spi4teensy test_script: - cmd: pio ci --lib="." --lib="C:\\spi4teensy" --board=uno --board=teensy31 --board=due ``` -------------------------------- ### PlatformIO ESP32C3 Board Configuration Examples Source: https://docs.platformio.org/en/stable/boards/espressif32/weactstudio_esp32c3coreboard PlatformIO configuration examples for WeAct Studio ESP32C3CoreBoard. Shows basic board setup with default settings and advanced configuration with custom MCU and frequency parameters. Use the first example for simple projects and the second for customized builds. ```ini [env:weactstudio_esp32c3coreboard] platform = espressif32 board = weactstudio_esp32c3coreboard ``` ```ini [env:weactstudio_esp32c3coreboard] platform = espressif32 board = weactstudio_esp32c3coreboard ; change microcontroller board_build.mcu = esp32c3 ; change MCU frequency board_build.f_cpu = 160000000L ``` -------------------------------- ### PlatformIO Installation and CLI Commands Source: https://docs.platformio.org/en/latest/integration/ide/cloud9 Commands for installing PlatformIO Core in Cloud9 environment and basic project initialization. Includes installation script execution and project creation for specific development boards. ```Shell Script sudo python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)" ``` ```Shell Script pio project init --board # initialize project for Arduino Uno pio project init --board uno ``` -------------------------------- ### PlatformIO Board Configuration Examples Source: https://docs.platformio.org/en/stable/boards/espressif32/nodemcu-32s2 Configuration examples for Ai-Thinker NodeMCU-32S2 board using PlatformIO. Shows basic board setup and advanced configuration with build options. Requires PlatformIO extension and espressif32 platform. Basic configuration sets platform and board ID, while advanced configuration allows overriding default MCU settings like frequency and microcontroller type. ```ini [env:nodemcu-32s2] platform = espressif32 board = nodemcu-32s2 ``` ```ini [env:nodemcu-32s2] platform = espressif32 board = nodemcu-32s2 ; change microcontroller board_build.mcu = esp32s2 ; change MCU frequency board_build.f_cpu = 240000000L ``` -------------------------------- ### Arduino Blink program in C++ for PlatformIO Source: https://docs.platformio.org/en/latest/integration/ide/visualstudio Simple Arduino Blink example written in C++. Demonstrates basic setup and loop functions, toggling the built‑in LED with one‑second delays. Compatible with the Arduino framework in PlatformIO. ```C++ #include "Arduino.h" void setup() { pinMode(LED_BUILTIN, OUTPUT); // set pin as output } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off delay(1000); // wait for a second } ``` -------------------------------- ### PlatformIO Board Configuration Examples Source: https://docs.platformio.org/en/stable/boards/espressif32/nano32 Complete set of PlatformIO configuration examples for the MakerAsia Nano32 board including basic setup, advanced overrides, and upload protocol configuration. These examples demonstrate how to configure board-specific settings like MCU type, frequency, and upload protocols in platformio.ini files. ```ini [env:nano32] platform = espressif32 board = nano32 ``` ```ini [env:nano32] platform = espressif32 board = nano32 ; change microcontroller board_build.mcu = esp32 ; change MCU frequency board_build.f_cpu = 240000000L ``` ```ini [env:nano32] platform = espressif32 board = nano32 upload_protocol = esptool ``` -------------------------------- ### Install PlatformIO Core with wget (macOS/Linux) Source: https://docs.platformio.org/en/stable/core/installation/methods/installer-script Installs or upgrades PlatformIO Core using the `wget` command to download the installer script and then executes it with `python3`. This method is an alternative to `curl` for macOS and Linux systems. ```shell wget -O get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py python3 get-platformio.py ``` -------------------------------- ### Create symlinks for PlatformIO CLI tools (Unix/Linux) Source: https://docs.platformio.org/en/stable/core/installation/shell-commands Creates symbolic links for PlatformIO executables in a directory on the user's PATH, enabling easy access to `platformio`, `pio`, and `piodebuggdb`. Two methods are provided: user‑local symlinks and system‑wide symlinks (requires sudo). ```Shell ln -s ~/.platformio/penv/bin/platformio ~/.local/bin/platformio ln -s ~/.platformio/penv/bin/pio ~/.local/bin/pio ln -s ~/.platformio/penv/bin/piodebuggdb ~/.local/bin/piodebuggdb ``` ```Shell mkdir -p /usr/local/bin ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb ``` -------------------------------- ### pio lib uninstall command example Source: https://docs.platformio.org/en/latest/core/userguide/lib/cmd_uninstall Demonstrates a practical example of uninstalling a library from global storage, showing the expected output format and confirmation message. ```bash > pio lib -g uninstall AsyncMqttClient Library Storage: /storage/dir/... Uninstalling AsyncMqttClient @ 0.2.0: [OK] ``` -------------------------------- ### AppVeyor YAML Example for USB_Host_Shield_2.0 with PlatformIO Source: https://docs.platformio.org/en/stable/integration/ci/appveyor Specific example for integrating USB_Host_Shield_2.0 project using pio ci in AppVeyor, cloning extra libraries and testing multiple examples on various boards. Depends on git submodules and Python; inputs are example INO files and boards like uno; outputs CI test reports; limited to specified libraries and may need repo-specific adjustments. ```yaml build: off environment: matrix: - PLATFORMIO_CI_SRC: "examples\\Bluetooth\\PS3SPP\\PS3SPP.ino" - PLATFORMIO_CI_SRC: "examples\\pl2303\\pl2303_gps\\pl2303_gps.ino" install: - cmd: git submodule update --init --recursive - cmd: SET PATH=%PATH%;C:\Python27\Scripts - cmd: pip install -U platformio - cmd: git clone https://github.com/xxxajk/spi4teensy3.git C:\spi4teensy test_script: - cmd: pio ci --lib="." --lib="C:\\spi4teensy" --board=uno --board=teensy31 --board=due ``` -------------------------------- ### PlatformIO pio lib install Command Usage Examples Source: https://docs.platformio.org/en/latest/core/userguide/lib/cmd_install This command installs libraries for PlatformIO projects from the Library Registry, repositories, or local files. It requires a platformio.ini file for project dependencies and supports options like environment specification, global installation, and force reinstall. Limitations include deprecation and the need to rebuild project index for IDE integration if issues arise. ```bash pio lib [STORAGE_OPTIONS] install [OPTIONS] [LIBRARY...] # RECOMMENDED # install all project dependencies declared via "lib_deps" # (run it from a project root where is located "platformio.ini") pio lib install [OPTIONS] # install project dependent library # (run it from a project root where is located "platformio.ini") pio lib install [OPTIONS] [LIBRARY...] # install dependencies for the specific project environment # (run it from a project root where is located "platformio.ini") pio lib -e myenv install [OPTIONS] [LIBRARY...] pio lib -d /path/to/platformio/project -e myenv install [OPTIONS] [LIBRARY...] # install to global storage (NOT RECOMMENDED) pio lib --global install [OPTIONS] [LIBRARY...] pio lib -g install [OPTIONS] [LIBRARY...] # install to custom storage pio lib --storage-dir /path/to/dir install [OPTIONS] [LIBRARY...] pio lib -d /path/to/dir1 -d /path/to/dir2 install [OPTIONS] [LIBRARY...] # [LIBRARY...] forms pio lib [STORAGE_OPTIONS] install (with no args, install project dependencies from "lib_deps") pio lib [STORAGE_OPTIONS] install pio lib [STORAGE_OPTIONS] install @ pio lib [STORAGE_OPTIONS] install @ pio lib [STORAGE_OPTIONS] install pio lib [STORAGE_OPTIONS] install file:// pio lib [STORAGE_OPTIONS] install file:// pio lib [STORAGE_OPTIONS] install pio lib [STORAGE_OPTIONS] install = (name it should have locally) pio lib [STORAGE_OPTIONS] install ("tag" can be commit, branch or tag) ``` -------------------------------- ### PlatformIO DigiX Configuration Examples Source: https://docs.platformio.org/en/stable/boards/atmelsam/digix Configuration examples for the Digistump DigiX board in PlatformIO. These INI-based configurations demonstrate the basic board setup using the 'digix' board ID and advanced customization options for MCU settings. The first example shows a minimal configuration, while the second demonstrates overriding default microcontroller and frequency settings. ```ini [env:digix] platform = atmelsam board = digix ``` ```ini [env:digix] platform = atmelsam board = digix ; change microcontroller board_build.mcu = at91sam3x8e ; change MCU frequency board_build.f_cpu = 84000000L ``` -------------------------------- ### PlatformIO Board Configuration Examples Source: https://docs.platformio.org/en/latest/boards/atmelsam/adafruit_metro_m4_airliftlite Complete set of PlatformIO configuration examples for Adafruit Metro M4 AirLift Lite. Includes basic board setup, custom board settings, and upload protocol configuration. Requires PlatformIO Core or IDE. Default upload protocol is sam-ba with alternatives atmel-ice and jlink. ```ini [env:adafruit_metro_m4_airliftlite] platform = atmelsam board = adafruit_metro_m4_airliftlite ``` ```ini [env:adafruit_metro_m4_airliftlite] platform = atmelsam board = adafruit_metro_m4_airliftlite ; change microcontroller board_build.mcu = samd51j19a ; change MCU frequency board_build.f_cpu = 120000000L ``` ```ini [env:adafruit_metro_m4_airliftlite] platform = atmelsam board = adafruit_metro_m4_airliftlite upload_protocol = sam-ba ``` -------------------------------- ### PlatformIO Build and Upload Commands Source: https://docs.platformio.org/en/stable/core/quickstart Essential PlatformIO CLI commands for building, uploading, and cleaning projects. Supports both all-environment and specific-environment operations for flexible project management. ```bash # Process (build) all environments pio run # Build and upload firmware to all devices pio run --target upload # Clean project (delete compiled objects) pio run --target clean # Process only uno environment pio run -e uno # Build and upload only for uno pio run -e uno -t upload ``` -------------------------------- ### Test Case Setup (C) Source: https://docs.platformio.org/en/stable/tutorials/ststm32/stm32cube_debugging_unit_testing Shows partial implementation of test setup function for GPIO initialization. Demonstrates LED pin configuration for testing. ```c #include "../src/main.h" #include void setUp(void) { LED_GPIO_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = LED_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; ``` -------------------------------- ### AppVeyor YAML Config Using pio ci for PlatformIO Libraries Source: https://docs.platformio.org/en/stable/integration/ci/appveyor This setup employs pio ci for testing PlatformIO libraries or examples in AppVeyor, specifying source files via matrix and boards. It handles submodules and PlatformIO installation; inputs include source paths and board IDs; outputs test results; suitable for libraries with extra lib/board options, but requires YAML matrix for multiple sources. ```yaml build: off environment: matrix: - PLATFORMIO_CI_SRC: "path\\to\\source\\file.c" - PLATFORMIO_CI_SRC: "path\\to\\source\\file.ino" - PLATFORMIO_CI_SRC: "path\\to\\source\\directory" install: - cmd: git submodule update --init --recursive - cmd: SET PATH=%PATH%;C:\Python27\Scripts - cmd: pip install -U platformio test_script: - cmd: pio ci --board= --board= --board= ``` -------------------------------- ### pio debug - Launch GDB with Initialization File Source: https://docs.platformio.org/en/latest/core/userguide/cmd_debug Demonstrates launching a GDB instance and loading an initial configuration file using the `--interface=gdb` and `--` options to pass GDB options. ```cli pio debug --interface=gdb -- -x .pioinit ... Loading section .text, size 0x2c98 lma 0x4000 Loading section .ramfunc, size 0x60 lma 0x6c98 Loading section .data, size 0x100 lma 0x6cf8 Start address 0x47b0, load size 11768 Transfer rate: 4 KB/sec, 3922 bytes/write. target halted due to debug-request, current mode: Thread xPSR: 0x81000000 pc: 0x000028f4 msp: 0x20002c00 target halted due to debug-request, current mode: Thread xPSR: 0x81000000 pc: 0x000028f4 msp: 0x20002c00 Breakpoint 2 at 0x413a: file src/main.cpp, line 26. ``` -------------------------------- ### Configure STM32F103RE Board in platformio.ini Source: https://docs.platformio.org/en/stable/boards/ststm32/genericSTM32F103RE Basic configuration setup for the STM32F103RE board in PlatformIO. Defines the board ID and platform. This is the minimum required configuration to start using the board. ```ini [env:genericSTM32F103RE] platform = ststm32 board = genericSTM32F103RE ``` -------------------------------- ### PlatformIO CLI: Update Libraries (Examples) Source: https://docs.platformio.org/en/stable/core/userguide/lib/cmd_update Examples demonstrating how to use the 'pio lib update' command. This includes updating all libraries in global storage and updating specific libraries by name in global storage. The output shows the process of checking and installing updated library versions. ```bash > pio lib -g update Library Storage: /storage/dir/... Updating ESP8266_SSD1306 @ 3.2.3: [Up-to-date] Updating EngduinoMagnetometer @ 3.1.0: [Up-to-date] Updating IRremote @ 2.2.1: [Up-to-date] Updating Json @ 5.4.0: [Out-of-date] LibraryManager: Installing id=64 @ 5.6.4 Downloading [####################################] 100% Unpacking [####################################] 100% Json @ 5.6.4 has been successfully installed! Updating PJON @ 1fb26fd: [Checking] git version 2.7.4 (Apple Git-66) Already up-to-date. Updating TextLCD @ 308d188a2d3a: [Checking] Mercurial Distributed SCM (version 3.8.4) (see https://mercurial-scm.org for more information) Copyright (C) 2005-2016 Matt Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. pulling from https://developer.mbed.org/users/simon/code/TextLCD/ searching for changes no changes found > pio lib -g update Json 4 Library Storage: /storage/dir/... Updating Json @ 5.6.4: [Up-to-date] Updating IRremote @ 2.2.1: [Up-to-date] ``` -------------------------------- ### Configure ATmega6450P Board in PlatformIO Source: https://docs.platformio.org/en/stable/boards/atmelavr/ATmega6450P Basic configuration for the ATmega6450P board in PlatformIO's platformio.ini file. Sets the platform to atmelavr and specifies the board type. This is the minimum required setup to start developing for this microcontroller. ```ini [env:ATmega6450P] platform = atmelavr board = ATmega6450P ``` -------------------------------- ### Configure PlatformIO Project - SODAQ ExpLoRer Source: https://docs.platformio.org/en/latest/boards/atmelsam/sodaq_explorer This snippet demonstrates setting up a PlatformIO project for the SODAQ ExpLoRer board. It shows how to specify the platform and board in the `platformio.ini` file. ```ini [env:sodaq_explorer] platform = atmelsam board = sodaq_explorer ``` -------------------------------- ### PlatformIO Configuration Examples for STC8F2K16S4 Source: https://docs.platformio.org/en/latest/boards/intel_mcs51/STC8F2K16S4 Provides example configurations for setting up the STC8F2K16S4 board in PlatformIO's platformio.ini file. Requires the intel_mcs51 platform. Inputs include board-specific overrides like MCU frequency, outputs are build environment settings. Does not support debugging and is limited to PlatformIO's framework. ```ini [env:STC8F2K16S4] platform = intel_mcs51 board = STC8F2K16S4 ``` ```ini [env:STC8F2K16S4] platform = intel_mcs51 board = STC8F2K16S4 ; change microcontroller board_build.mcu = stc8f2k16s4 ; change MCU frequency board_build.f_cpu = 11059200L ``` -------------------------------- ### Start PlatformIO Home in Shell Source: https://docs.platformio.org/en/latest/integration/ide/clion This shell command launches PlatformIO Home from CLion's terminal, opening the web interface for managing PlatformIO features. It requires PlatformIO to be installed and configured for CLion. Note that some features, such as opening projects, are not supported in this manual setup. ```shell pio -c clion home ``` -------------------------------- ### Basic ESPino Board Configuration Source: https://docs.platformio.org/en/latest/boards/espressif8266/espino Minimal platformio.ini configuration for ESPino board setup using ESP8266 platform. This configuration uses default settings and serves as the starting point for ESPino projects. Requires the espressif8266 platform package. ```ini [env:espino] platform = espressif8266 board = espino ``` -------------------------------- ### Get OTA Uploader Help Source: https://docs.platformio.org/en/latest/platforms/espressif8266 This command executes the `espota.py` script with the `--help` flag to display all available options and their descriptions. This is useful for understanding the full capabilities of the OTA uploader, including destination, authentication, image handling, and output options. ```bash ~/.platformio/packages/framework-arduinoespressif8266/tools/espota.py --help ``` -------------------------------- ### PlatformIO Configuration Examples for MultiTech mDot F411 Source: https://docs.platformio.org/en/stable/boards/ststm32/mts_mdot_f411re Complete set of PlatformIO configuration examples for MultiTech mDot F411 board. Shows basic setup with STM32 platform, board-specific configurations, microcontroller customization, CPU frequency settings, and upload protocol selection. Supports multiple upload protocols including blackmagic, cmsis-dap, jlink, mbed, and stlink. ```ini [env:mts_mdot_f411re] platform = ststm32 board = mts_mdot_f411re ``` ```ini [env:mts_mdot_f411re] platform = ststm32 board = mts_mdot_f411re ; change microcontroller board_build.mcu = stm32f411ret6 ; change MCU frequency board_build.f_cpu = 100000000L ``` ```ini [env:mts_mdot_f411re] platform = ststm32 board = mts_mdot_f411re upload_protocol = mbed ``` -------------------------------- ### PlatformIO Board Configuration Examples Source: https://docs.platformio.org/en/latest/boards/ststm32/olimex_f103 PlatformIO configuration snippets for Olimex STM32-H103 board showing basic setup, build customization, and upload protocol options. Covers common scenarios for STM32F103RBT6 microcontroller development including frequency and MCU overrides. ```ini [env:olimex_f103] platform = ststm32 board = olimex_f103 ``` ```ini [env:olimex_f103] platform = ststm32 board = olimex_f103 ; change microcontroller board_build.mcu = stm32f103rbt6 ; change MCU frequency board_build.f_cpu = 72000000L ``` ```ini [env:olimex_f103] platform = ststm32 board = olimex_f103 upload_protocol = stlink ``` -------------------------------- ### Initialize PlatformIO Project with Multiple Boards Source: https://docs.platformio.org/en/latest/core/quickstart Command to initialize a new PlatformIO project for multiple embedded boards. Creates project structure including platformio.ini, src, and lib directories. Requires confirmation to proceed with creation. ```bash > pio project init --board uno --board nodemcuv2 --board teensy31 ``` -------------------------------- ### PlatformIO Configuration for STM32F446RE Source: https://docs.platformio.org/en/latest/boards/ststm32/genericSTM32F446RE PlatformIO project configuration examples for STM32F446RE microcontroller board. Includes basic setup, advanced build options with custom microcontroller and frequency settings, and upload protocol configuration. All configurations use the genericSTM32F446RE board ID. ```ini [env:genericSTM32F446RE] platform = ststm32 board = genericSTM32F446RE ``` ```ini [env:genericSTM32F446RE] platform = ststm32 board = genericSTM32F446RE ; change microcontroller board_build.mcu = stm32f446ret6 ; change MCU frequency board_build.f_cpu = 180000000L ``` ```ini [env:genericSTM32F446RE] platform = ststm32 board = genericSTM32F446RE upload_protocol = serial ``` -------------------------------- ### Basic Configuration in platformio.ini Source: https://docs.platformio.org/en/latest/boards/espressif32/m5stamp-pico This configuration snippet sets up a basic environment for the M5Stamp-Pico board in the platformio.ini file. It specifies the Espressif32 platform and the board ID, with no additional dependencies required. Input is the board ID; output is a configured build environment. Limited to basic setup without custom overrides. ```ini [env:m5stamp-pico] platform = espressif32 board = m5stamp-pico ``` -------------------------------- ### Install PlatformIO Core with curl (macOS/Linux) Source: https://docs.platformio.org/en/stable/core/installation/methods/installer-script Installs or upgrades PlatformIO Core using the `curl` command to download the installer script and then executes it with `python3`. This method is suitable for macOS and Linux systems. ```shell curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py python3 get-platformio.py ``` -------------------------------- ### Basic WifInfo Board Setup in platformio.ini Source: https://docs.platformio.org/en/latest/boards/espressif8266/wifinfo This configuration defines a build environment for the WifInfo board using the espressif8266 platform. It requires PlatformIO Core and specifies the board ID 'wifinfo' for automatic hardware detection. No inputs or outputs beyond standard PlatformIO build process; suitable for initial project setup. ```ini [env:wifinfo] platform = espressif8266 board = wifinfo ``` -------------------------------- ### Example PlatformIO Configuration for Ruuvi Tag Source: https://docs.platformio.org/en/latest/boards/nordicnrf52/ruuvitag Shows how to set up a PlatformIO environment for the Ruuvi Tag, specifying the platform, board and how to change microcontroller from default. This is useful when you want to customize the build process. ```ini [env:ruuvitag] platform = nordicnrf52 board = ruuvitag ``` -------------------------------- ### Configure Adafruit Metro Board in PlatformIO Source: https://docs.platformio.org/en/latest/boards/atmelavr/metro These INI snippets demonstrate how to select the Adafruit Metro board and Atmel AVR platform in a PlatformIO project. The first example shows the minimal configuration required, while the second example illustrates overriding the default MCU and clock frequency using board_build options. No additional dependencies are needed, but users must ensure the appropriate debug tools are installed if debugging is required. ```INI [env:metro] platform = atmelavr board = metro ``` ```INI [env:metro] platform = atmelavr board = metro ; change microcontroller board_build.m = atmega328p ; change MCU frequency board_build.f_cpu = 16000000L ``` -------------------------------- ### PlatformIO Library Structure Example Source: https://docs.platformio.org/en/latest/librarymanager/creating Illustrates the recommended directory structure for a PlatformIO library, including source and header files. ```text ├── examples │   └── echo ├── include │   └── HelloWorld.h ├── library.json └── src └── HelloWorld.cpp ``` -------------------------------- ### Configure oddWires IOT-Bus JTAG Debug Tool Source: https://docs.platformio.org/en/latest/plus/debug-tools/iot-bus-jtag PlatformIO configuration examples showing how to enable the oddWires IOT-Bus JTAG debugging tool for ESP32 projects. Includes basic debug_tool setup and combined debug/upload protocol configuration for firmware debugging and flashing operations. ```ini [env:myenv] platform = ... board = ... debug_tool = iot-bus-jtag ``` ```ini [env:myenv] platform = ... board = ... debug_tool = iot-bus-jtag upload_protocol = iot-bus-jtag ``` -------------------------------- ### Configure Arduino BT ATmega168 Board Settings Source: https://docs.platformio.org/en/latest/boards/atmelavr/btatmega168 PlatformIO configuration for the Arduino BT ATmega168 board. This configuration sets up the development environment with the correct platform and board settings. The example shows basic setup and how to override default microcontroller and frequency settings. ```ini [env:btatmega168] platform = atmelavr board = btatmega168 ``` ```ini [env:btatmega168] platform = atmelavr board = btatmega168 ; change microcontroller board_build.mcu = atmega168 ; change MCU frequency board_build.f_cpu = 16000000L ``` -------------------------------- ### Define library examples in JSON Source: https://docs.platformio.org/en/latest/manifests/library-json/fields/examples Configuration of example patterns in PlatformIO library manifest. This field defines example projects that demonstrate library usage. Each example includes a name, base directory, and list of files. The examples field supports glob patterns for flexible file matching. ```json { "examples": [ { "name": "Hello", "base": "examples/world", "files": [ "platformio.ini", "include/world.h", "src/world.c", "README", "extra.py" ] }, { "name": "Blink", "base": "examples/blink", "files": ["blink.cpp", "blink.h"] } ] } ``` -------------------------------- ### Write Arduino Unit Tests using Unity Framework (C++) Source: https://docs.platformio.org/en/stable/tutorials/espressif32/arduino_debugging_unit_testing The following C++ example demonstrates how to create unit tests for Arduino code with the Unity testing framework. It defines setUp and tearDown functions, several test cases for the String class, and a standard Arduino setup/loop that runs the tests. Place this file as test_main.cpp in a "test" folder and execute via PlatformIO's test commands. ```cpp #include \n#include \n\nString STR_TO_TEST;\n\nvoid setUp(void) {\n // set stuff up here\n STR_TO_TEST = "Hello, world!";\n}\n\nvoid tearDown(void) {\n // clean stuff up here\n STR_TO_TEST = "";\n}\n\nvoid test_string_concat(void) {\n String hello = "Hello, ";\n String world = "world!";\n TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());\n}\n\nvoid test_string_substring(void) {\n TEST_ASSERT_EQUAL_STRING("Hello", STR_TO_TEST.substring(0, 5).c_str());\n}\n\nvoid test_string_index_of(void) {\n TEST_ASSERT_EQUAL(7, STR_TO_TEST.indexOf('w'));\n}\n\nvoid test_string_equal_ignore_case(void) {\n TEST_ASSERT(STR_TO_TEST.equalsIgnoreCase("HELLO, WORLD!"));\n}\n\nvoid test_string_to_upper_case(void) {\n STR_TO_TEST.toUpperCase();\n TEST_ASSERT_EQUAL_STRING("HELLO, WORLD!", STR_TO_TEST.c_str());\n}\n\nvoid test_string_replace(void) {\n STR_TO_TEST.replace('!', '?');\n TEST_ASSERT_EQUAL_STRING("Hello, world?", STR_TO_TEST.c_str());\n}\n\nvoid setup()\n{\n delay(2000); // service delay\n UNITY_BEGIN();\n\n RUN_TEST(test_string_concat);\n RUN_TEST(test_string_substring);\n RUN_TEST(test_string_index_of);\n RUN_TEST(test_string_equal_ignore_case);\n RUN_TEST(test_string_to_upper_case);\n RUN_TEST(test_string_replace);\n\n UNITY_END(); // stop unit testing\n}\n\nvoid loop()\n{\n}\n ``` -------------------------------- ### Configure PATH for PlatformIO CLI (Unix/Linux) Source: https://docs.platformio.org/en/stable/core/installation/shell-commands Adds the PlatformIO binary directory to the user's PATH environment variable to allow invoking `platformio` and related commands from any terminal. Works for Bash and Zsh shells by editing the appropriate profile files. No additional dependencies. ```Shell export PATH=$PATH:$HOME/.local/bin # For Zsh compatibility emulate sh -c '. ~/.profile' ``` -------------------------------- ### PlatformIO Configuration for u-blox NINA-W10 Series Source: https://docs.platformio.org/en/stable/boards/espressif32/nina_w10 This snippet shows the basic configuration for the u-blox NINA-W10 series board in the platformio.ini file. It specifies the platform as 'espressif32' and the board as 'nina_w10'. This is the fundamental setup required to start a project targeting this board. ```ini [env:nina_w10] platform = espressif32 board = nina_w10 ``` -------------------------------- ### Basic FK407M1 Configuration in PlatformIO Source: https://docs.platformio.org/en/latest/boards/ststm32/fk407m1 Sets up the basic PlatformIO environment for the FK407M1 board. Uses the ststm32 platform and fk407m1 board ID. Dependencies include PlatformIO installation. No inputs required; outputs a configured project environment. Limitations: Specific to FK407M1 board only. ```ini [env:fk407m1] platform = ststm32 board = fk407m1 ``` -------------------------------- ### PlatformIO Configuration for NUCLEO-8S207K8 Board Source: https://docs.platformio.org/en/latest/boards/ststm8/nucleo_8s207k8 PlatformIO project configuration examples for NUCLEO-8S207K8 development board. Includes basic board setup, custom microcontroller and frequency settings, upload protocol configuration. Uses STM8S207K8T6 microcontroller with ststm8 platform. Supports ST-LINK debugging and multiple upload protocols. ```ini [env:nucleo_8s207k8] platform = ststm8 board = nucleo_8s207k8 ``` ```ini [env:nucleo_8s207k8] platform = ststm8 board = nucleo_8s207k8 ; change microcontroller board_build.mcu = stm8s207k8t6 ; change MCU frequency board_build.f_cpu = 16000000L ``` ```ini [env:nucleo_8s207k8] platform = ststm8 board = nucleo_8s207k8 upload_protocol = stlinkv21 ``` -------------------------------- ### Install PlatformIO Core Locally (macOS/Linux/Windows) Source: https://docs.platformio.org/en/stable/core/installation/methods/installer-script Installs or upgrades PlatformIO Core by first downloading the `get-platformio.py` script and then executing it using the Python interpreter. This method is cross-platform and works on macOS, Linux, and Windows. ```shell # change directory to the folder where is located downloaded "get-platformio.py" cd /path-to-dir/where/get-platformio.py/is-located # run it python get-platformio.py ``` ```shell # On _Windows OS_ it may look like this: # change directory to the folder where is located downloaded "get-platformio.py" cd C:/path-to-dir/where/get-platformio.py/is-located # run it python.exe get-platformio.py ``` -------------------------------- ### platformio.ini Example Source: https://docs.platformio.org/en/latest/projectconf A sample platformio.ini file demonstrating common configurations for different environments, including libraries, build flags, and debugging options. It showcases the section-based structure and interpolation of values. ```ini [platformio] default_envs = nodemcuv2 ; custom common options [common] build_flags = -D VERSION=1.2.3 -D DEBUG=1 lib_deps_builtin = SPI Wire lib_deps_external = bblanchon/ArduinoJson @ ~5.6,!=5.4 https://github.com/gioblu/PJON.git#v2.0 IRremoteESP8266=https://github.com/markszabo/IRremoteESP8266/archive/master.zip [env:nodemcuv2] platform = espressif8266 framework = arduino board = nodemcuv2 ; Build options build_flags = ${common.build_flags} -DSSID_NAME=HELLO -DSSID_PASWORD=WORLD ; Library options lib_deps = ${common.lib_deps_builtin} ${common.lib_deps_external} https://github.com/me-no-dev/ESPAsyncTCP.git knolleary/PubSubClient@^2.8 paulstoffregen/OneWire ; Serial Monitor options monitor_speed = 115200 monitor_flags = --encoding hexlify ; Unit Testing options test_ignore = test_desktop [env:bluepill_f103c8] platform = ststm32 framework = arduino board = bluepill_f103c8 ; Library options lib_deps = ${common.lib_deps_external} ; Debug options debug_tool = custom debug_server = ${platformio.packages_dir}/tool-jlink/JLinkGDBServer -singlerun -if SWD -select USB -port 2331 -device STM32F103C8 ; Unit Testing options test_ignore = test_desktop ``` -------------------------------- ### PlatformIO Library Manifest (library.json) Example Source: https://docs.platformio.org/en/latest/librarymanager/creating Shows a sample library.json file with various fields like name, version, description, repository, authors, license, dependencies, frameworks, and platforms. ```json { "name": "HelloWorld", "version": "1.0.0", "description": "A \"Hello world\" program is a computer program that outputs \"Hello World\" (or some variant) on a display device", "keywords": "planet, happiness, people", "repository": { "type": "git", "url": "https://github.com/username/hello-world.git" }, "authors": [ { "name": "John Smith", "email": "me@john-smith.com", "url": "https://www.john-smith/contact" }, { "name": "Andrew Smith", "email": "me@andrew-smith.com", "url": "https://www.andrew-smith/contact", "maintainer": true } ], "license": "MIT", "homepage": "https://www.helloworld.org/", "dependencies": { "ownername/print": "~1.3.0" }, "frameworks": "*", "platforms": "*" } ``` -------------------------------- ### Initialize PlatformIO project for Visual Studio using CLI Source: https://docs.platformio.org/en/latest/integration/ide/visualstudio Creates a new PlatformIO project configured for Visual Studio. Requires PlatformIO Core (CLI) installed. Use the board ID to target a specific hardware platform. The generated project includes a platformio.ini file and source directory. ```Shell pio project init --ide visualstudio --board # Example: generate project for Arduino UNO pio project init --ide visualstudio --board uno ``` -------------------------------- ### PlatformIO Configuration for ATmega3290/A Source: https://docs.platformio.org/en/latest/boards/atmelavr/ATmega3290 Basic and advanced configuration examples for setting up the ATmega3290 board in the platformio.ini file using the Atmel AVR platform. The first example provides default setup, while the second demonstrates overriding MCU type and frequency. Inputs are project-specific; outputs enable building and uploading to the board. Limitations include no debugging support. ```ini [env:ATmega3290] platform = atmelavr board = ATmega3290 ``` ```ini [env:ATmega3290] platform = atmelavr board = ATmega3290 ; change microcontroller board_build.mcu = atmega3290 ; change MCU frequency board_build.f_cpu = 16000000L ``` -------------------------------- ### Configure QEMU for PlatformIO Testing Source: https://docs.platformio.org/en/latest/advanced/unit-testing/simulators/qemu Sets up QEMU emulator integration in PlatformIO by configuring platform packages and test commands in platformio.ini. This configuration example targets the HiFive1 board from SiFive using the Freedom-E SDK framework. The setup enables hardware virtualization for embedded testing without requiring physical hardware. ```ini [env:hifive1] platform = sifive framework = freedom-e-sdk board = hifive1 platform_packages = platformio/tool-qemu-riscv test_testing_command = ${platformio.packages_dir}/tool-qemu-riscv/bin/qemu-system-riscv32 -nographic -machine sifive_e -kernel ${platformio.build_dir}/${this.__env__}/firmware.elf ``` -------------------------------- ### AppVeyor Configuration for PlatformIO Projects Source: https://docs.platformio.org/en/latest/integration/ci/appveyor Basic AppVeyor configuration for native PlatformIO projects using the `pio run` command. Sets up Python environment and installs PlatformIO before running tests. ```YAML build: off environment: install: - cmd: git submodule update --init --recursive - cmd: SET PATH=%PATH%;C:\Python27\Scripts - cmd: pip install -U platformio test_script: - cmd: pio run -e -e -e ``` -------------------------------- ### PlatformIO Configuration - Ethernet IoT Starter Kit Source: https://docs.platformio.org/en/stable/boards/freescalekinetis/IBMEthernetKit Example platformio.ini configuration for the Ethernet IoT Starter Kit, demonstrating board selection and environment settings. It also shows how to override default settings using the board_*** option. ```ini [env:IBMEthernetKit] platform = freescalekinetis board = IBMEthernetKit ``` ```ini [env:IBMEthernetKit] platform = freescalekinetis board = IBMEthernetKit ; change microcontroller board_build.mcu = mk64fn1m0vll12 ; change MCU frequency board_build.f_cpu = 120000000L ``` -------------------------------- ### PlatformIO Configuration Examples for Adafruit PyGamer M4 Source: https://docs.platformio.org/en/stable/boards/atmelsam/adafruit_pygamer_m4 Collection of PlatformIO configuration examples for Adafruit PyGamer M4 Express board, showing basic setup, build customization, and upload protocol configuration. All examples use the platformio.ini format and target the atmelsam platform. ```ini [env:adafruit_pygamer_m4] platform = atmelsam board = adafruit_pygamer_m4 ``` ```ini [env:adafruit_pygamer_m4] platform = atmelsam board = adafruit_pygamer_m4 ; change microcontroller board_build.mcu = samd51j19a ; change MCU frequency board_build.f_cpu = 120000000L ``` ```ini [env:adafruit_pygamer_m4] platform = atmelsam board = adafruit_pygamer_m4 upload_protocol = sam-ba ``` -------------------------------- ### PlatformIO Configuration (96Boards Nitrogen) Source: https://docs.platformio.org/en/latest/boards/nordicnrf52/96b_nitrogen Demonstrates setting up a PlatformIO project for the 96Boards Nitrogen board. It specifies the platform, board, microcontroller, frequency, and upload protocol within the `platformio.ini` file. ```ini [env:96b_nitrogen] platform = nordicnrf52 board = 96b_nitrogen ; change microcontroller board_build.mcu = nrf52832 ; change MCU frequency board_build.f_cpu = 64000000L ; change upload protocol upload_protocol = jlink ``` -------------------------------- ### Basic PlatformIO Configuration for VAkE v1.0 Source: https://docs.platformio.org/en/stable/boards/ststm32/vake_v1 Sets up the basic build environment for the VAkE v1.0 board in PlatformIO. Requires PlatformIO IDE installed. No inputs required; outputs a configured project environment. Limited to STM32 platform and vake_v1 board ID. ```ini [env:vake_v1] platform = ststm32 board = vake_v1 ``` -------------------------------- ### Configure Nexys A7 Board in PlatformIO INI Source: https://docs.platformio.org/en/latest/boards/openhw/nexys_a7 Provides INI configuration examples for setting up the Digilent Nexys A7 board in PlatformIO projects. The first example shows basic environment setup with platform and board IDs. The second includes overrides for microcontroller and frequency settings. Requires PlatformIO Core installed, uses standard INI syntax, outputs build configurations for the OpenHW platform. Limitations include board-specific hardware constraints and dependency on debug tool drivers for advanced debugging. ```ini [env:nexys_a7] platform = openhw board = nexys_a7 ``` ```ini [env:nexys_a7] platform = openhw board = nexys_a7 ; change microcontroller board_build.mcu = ; change MCU frequency board_build.f_cpu = 320000000L ``` -------------------------------- ### GoogleTest Test Code Example (Arduino) Source: https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/googletest A basic GoogleTest test code example for Arduino environments, including initialization and test execution within the setup and loop functions. ```cpp #include // uncomment line below if you plan to use GMock // #include // TEST(...) // TEST_F(...) #if defined(ARDUINO) #include void setup() { // should be the same value as for the `test_speed` option in "platformio.ini" // default value is test_speed=115200 Serial.begin(115200); ::testing::InitGoogleTest(); // if you plan to use GMock, replace the line above with // ::testing::InitGoogleMock(); } void loop() { // Run tests if (RUN_ALL_TESTS()) ; // sleep for 1 sec delay(1000); } #else int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); // if you plan to use GMock, replace the line above with // ::testing::InitGoogleMock(&argc, argv); if (RUN_ALL_TESTS()) ; // Always return zero-code and allow PlatformIO to parse results return 0; } #endif ``` -------------------------------- ### Unity Test File Setup (C) Source: https://docs.platformio.org/en/latest/tutorials/ststm32/stm32cube_debugging_unit_testing This C file demonstrates the basic structure for a Unity test file, including the necessary includes and the standard setUp function. The setUp function is used here to enable the clock for the LED GPIO and initialize its pin as an output. ```c #include "../src/main.h" #include void setUp(void) { LED_GPIO_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = LED_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; ``` -------------------------------- ### Configure IAP15F206A Board in PlatformIO Source: https://docs.platformio.org/en/latest/boards/intel_mcs51/IAP15F206A Set up the PlatformIO environment for the IAP15F206A board using the platformio.ini configuration file. This example provides the basic configuration to specify the platform and board. It supports overriding default settings with board-specific options. No external dependencies are required, but a PlatformIO installation is assumed. Inputs are board manifest parameters, outputs are customized build environments. Limitations include no debugging support for this board. ```ini [env:IAP15F206A] platform = intel_mcs51 board = IAP15F206A ``` ```ini [env:IAP15F206A] platform = intel_mcs51 board = IAP15F206A ; change microcontroller board_build.mcu = iap15f206a ; change MCU frequency board_build.f_cpu = 11059200L ``` -------------------------------- ### ESP32 Upload Protocol Configuration - PlatformIO INI Source: https://docs.platformio.org/en/latest/boards/espressif32/m5stack-grey PlatformIO configuration demonstrating how to set upload protocol for M5Stack GREY ESP32. Shows both the available protocols (espota and esptool) and how to explicitly select esptool as the upload method. Essential for proper firmware deployment. ```ini [env:m5stack-grey] platform = espressif32 board = m5stack-grey upload_protocol = esptool ```