PlatformIO Build Properties for Arduinos

If you’re still using the Arduino IDE and you feel like its getting in the way, check out the Platformio IDE for IoT development.

An open project in Platformio using Atom Text editor

It comes with all the standard tools you nned to compile, build and flash to your controller boards and adds on a bunch of features you would expect to see in an IDE. Things like:

  • text-based build configuration (platformio.ini config file)
  • Debugger
  • Code linting
  • and more.

Build configurations for Boards I used

The platformio.ini file describes your Arduino project, including how to compile, build and flash your project. In this file you can specify multiple build configurations if you wanted to for different boards. You can select between configurations by setting the environment default (env_default).

The following is a simple configuration file. The benefit of this is that the IDE can read in the build config from this file without you having to change the UI options every time you open a different project or want to flash to a different board.


[platformio]
src_dir = src

; *** Uncomment one of the lines below to build/upload only one environment
env_default = d1_wifi


[env:nodemcu]
[env:nodemcu]
platform = espressif8266
framework = arduino
board = nodemcu

[env:nodemcuv2]
platform = espressif8266
framework = arduino
board = nodemcuv2

[env:d1_wifi]
platform = espressif8266
framework = arduino
board = d1_mini
board_f_cpu = 80000000L
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMQTT_MAX_PACKET_SIZE=512
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON

; *** Serial Monitor options
monitor_baud = 9600


[env:esp01]
platform = espressif8266
framework = arduino
board = esp01_1m
board_f_cpu = 80000000L
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMQTT_MAX_PACKET_SIZE=512