Using custom private libraries

Platformio noob here. I am very interested in using platformio for some work projects. One thing that has always seemed to be a bit of a battle is working out the best way to use both managed public libraries (e.g. from Arduino library manager), and private libraries (e.g. from work).

Platformio looks great for dealing with the libraries available through the library manager. I’m interested in what the best practise is for using private libraries though. There seems to be a lot of posts that are almost relevant, but not quite found what I’m looking for yet.

The private libraries I want to use are all existing repos, and in previous non-platformio projects these have been submodules in the project repo. I’m not really against this, but I wondered if there’s some “unified” way to deal with both types of libraries in Platformio, rather than using library manager for some and git submodules for others. Any thoughts?

PlatformIO’s library management is already unifying those. See lib_deps documentation. I can mix public and private libraries as in e.g.

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = 
   # public lib from registry
   adafruit/Adafruit GFX Library @ ^1.10.4 
   # git link to private lib. can even be with #hash, #tag and #branch
   https://github.com/maxgerhardt/SC18IS602B-arduino.git
   # ...

PlatformIO will then download the libraries into .pio\libdeps\<environment> if they do not exist and then use them.

To update the downloaded libraries, you can either remove the .pio folder again to force a redownload or open a PIO CLI and do a pio lib update, or use the PIO Home screen → Libraries to update them.

It is still possible to however to do it with the git submodules way. You would add the repository of your library as a folder in the project’s lib/ folder, and update them with git submodule update.

Perfect! That’s the kind of elegant solution I was looking for. I couldn’t see the wood for the trees when going through documentation obviously!