Platformio.ini for single project with libraries for multiple platforms

Hi everyone,

I have a project that needs to run in different MCUs (different platform and different boards) but all using the same Arduino framework. Right now, the two MCUs that I’m testing with are the Arduino Pro Mini 8Mhz and the Teensy LC. Aside from using the Arduino libraries, I also have custom libraries, some are specific to the TeensyLC and some are specific to Atmel AVR. These libraries deal mostly with interrupts and sleep functions.

How do I organize my libraries and the platformio.ini so that depending on the default_envs I choose, PlatformIO will select the correct libraries?

My platformio.ini:


default_envs = pro8MHzatmega328

;default_envs = teensylc


;                              ENVIRONMENTS PARAMETERS                                 ;


;Libraries and parameters shared accross environements                                 ;



elapsedmillis = elapsedMillis

softwareserial = SoftwareSerial

servo = Servo


framework = arduino

lib_deps =





monitor_filters = time, send_on_enter

monitor_flags = --echo

monitor_speed = 57600


platform = teensy

board = teensylc

lib_extra_dirs =


lib_deps =




platform = atmelavr

board = pro8MHzatmega328

monitor_port = COM5

upload_port = COM5

upload_flags = -e

lib_extra_dirs =


lib_deps =