Skip to content

PlatformIO Project Configuration

Project Configuration with PlatformIO

All platformio projects have a main configuration file called platformio.ini. In this file you can configure the microcontroller you will be using and other parameters such as the upload method.

This is our default platformio.ini:

; platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

We can make it better:

[common]
lib_deps =
  https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
  https://github.com/mikalhart/TinyGPSPlus
  https://github.com/adafruit/DHT-sensor-library
  https://github.com/timotto/Readline
  https://github.com/Rhomb-io/rhio-pinmap

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = COM3
monitor_port = COM3
monitor_speed = 115200
lib_deps = ${common.lib_deps}
monitor_filters = esp32_exception_decoder

Some important things are happening here.

  • First we've added a new section, [common], which includes a list of rhomb.iot dependencies. PlatformIO will connect to the Internet and download these dependencies automatically. You can add more libraries to your project from PlatformIO Home > Libraries
  • The serial port has been configured to upload the firmware and have a serial monitor for debugging. You will have to modify these values according to the COM ports in your computer. In linux/Mac it will appear as /dev/ttyUSB or /dev/ttyACM
  • The monitor_filters = esp32_exception_decoder is a cool option for ESP32 (also available for ESp8266) to see decoded backtrace error messages, so you can catch the error line when your code crash.

Configuration for multiple Master Modules

You can configure multiple microcontrollers on your platformio.ini file and select one as default:

; platformio.ini for rhomb.iot v0.1.0

[user]
upload_port = SELECT_PORT
monitor_port = SELECT_PORT
monitor_speed = 115200

[platformio]
default_envs = esp32
data_dir = "lib/rhomb.iot/data"
test_dir = "lib/rhomb.iot/test"

[common]
lib_deps =
  https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
  https://github.com/mikalhart/TinyGPSPlus
  https://github.com/adafruit/DHT-sensor-library
  https://github.com/timotto/Readline
  https://github.com/Rhomb-io/rhio-pinmap

[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = ${user.upload_port}
monitor_port = ${user.monitor_port}
monitor_speed = ${user.monitor_speed}
lib_deps = ${common.lib_deps}
monitor_filters = esp32_exception_decoder

[env:zeroUSB]
platform = atmelsam
board = zeroUSB
framework = arduino
upload_port = ${user.upload_port}
monitor_port = ${user.monitor_port}
monitor_speed = ${user.monitor_speed}
lib_deps =
  ${common.lib_deps}
  FlashStorage

[env:espressif8266]
platform = espressif8266
board = esp_wroom_02
framework = arduino
upload_port = ${user.upload_port}
monitor_port = ${user.monitor_port}
monitor_speed = ${user.monitor_speed}
lib_deps = ${common.lib_deps}


[env:uno]
platform = atmelavr
framework = arduino
board = uno
upload_port = ${user.upload_port}
monitor_port = ${user.monitor_port}
monitor_speed = ${user.monitor_speed}
lib_deps = ${common.lib_deps}

[env:mega]
platform = atmelavr
board = megaatmega2560
framework = arduino
upload_port = ${user.upload_port}
monitor_port = ${user.monitor_port}
monitor_speed = ${user.monitor_speed}
lib_deps = ${common.lib_deps}
  • Every master module has a section: [env:esp32], [env:zeroUSB], [env:espressif8266], [env:uno] and [env:mega]
  • The [user] section sets a global COM port for upload and monitor in each master.
  • The section [platformio] contains the option default_envs that establishes which microcontroller you're working with. You can only flash/compile with one master at a time. It also contains the path for the data directory, where there are the HTML files for the ESP32 AP Web Server and the directory for unit testing.

User configuration

At this point your IDE is ready to work with rhomb.iot. The next step is to configure rhomb.IoT to work as you want.

Continue with User Configuration File

Comments