The preferred way is to NOT download the Arduino library yourself. Instead go to PIO Home / Libraries (in Visual Studio Code) or to PlatformIO Registry and search for the library. If it is found, add the name of the library to platformio.ini
(an example can be seen if you click on the Installation tab in the search result). PlatformIO will then take care of the download, unpacking etc.
As an example: search for ArduinoJson. It’s a registered library. So you can then add it to platformio.ini
:
lib_deps =
ArduinoJson
If the library is not registered, you can go the other route, e.g. for library ABC:
- Download the library
- Unzip the library
- Put it into the
lib
directory within your project
The project structure should then look like:
include
lib
+-- abc
+-- examples
+-- include
+-- keywords.txt
+-- library.json
+-- src
src
test
Or if it is a very minimalistic library:
include
lib
+-- abc
+-- abc.h
+-- abc.c
src
test