Dynamic variables

Dynamic variables (interpolations) are useful when you have a custom configuration data between build environments. For examples, extra build_flags or project dependencies lib_deps.

Each variable should have a next format: ${<section>.<option>}, where <section> is a value from [<section>] group, and <option> is a first item from pair <option> = value.

You can inject system environment variable using sysenv as a section. For example, ${sysenv.HOME}.

  • Variable can be applied only for the option’s value

  • Multiple variables are allowed

  • The Section [platformio] and Section [env] sections are reserved and could not be used as a custom section. Some good section names might be extra or custom.


If you need to share common configuration options between build environments, please take a look at “Global scope” in Section [env] or extends option which allows extending of other sections.


; You MUST inject these options into [env:] section
; using ${extra.***} (see below)
build_flags = -D VERSION=1.2.3 -D DEBUG=1
lib_deps_builtin =
lib_deps_external =

platform = atmelavr
framework = arduino
board = uno
build_flags = ${extra.build_flags}
lib_deps =

platform = espressif8266
framework = arduino
board = nodemcuv2
build_flags = ${extra.build_flags} -Wall
lib_deps =
  knolleary/PubSubClient @ ~2.6
  paulstoffregen/OneWire @ ^2.3.5

; Keep sensitive data in environment variables
; Unix
; export WIFI_SSID='\"my\ ssid\ name\"'
; export WIFI_PASS='\"my\ password\"'
; Windows
; set WIFI_SSID='"my ssid name"'
; set WIFI_PASS='"my password"'

extends = env:nodemcuv2
platform = espressif32
board = esp32dev
build_flags =


Be careful with special characters in system environment variables on Unix systems, especially when they are used as the value for preprocessor directives. Symbols like $, &, ~, etc must be explicitly escaped, for example:

export WIFI_PASS='\"my\~p\&a\\\$\$\$\$word\"'