It finally works with addind #include <SPI.h>
The explanation is :
Because this works around a platformio dependency scanning bug . When you are using a library that depends on the Adafruit BusIO library, the pio dependency scanner is confused by a C preprocessor guard that guards an #include <SPI.h>
there:
#if !defined(SPI_INTERFACES_COUNT) || \
(defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0))
#include <SPI.h>
During compilation, when targeting a standard Arduino board, the guard evaluates to true such that the compiler wants to include that header - but platformio hasn’t provided it.
So adding a plain #include <SPI.h>
in your own code works around this issue because the pio dependency scanner picks up the dependency that way then. Alternatively, and arguably a cleaner work around is to simply add an SPI
line to the lib_deps
directive in your platformio.ini.
Thank you for taking the time to answer me @maxgerhardt