How to fix PlatformIO SPI.h: No Such File or Directory
Problem:
When compiling your PlatformIO firmware, you see an error message like
In file included from .pio/libdeps/esp32dev/Adafruit BusIO/Adafruit_BusIO_Register.h:2:0,
from .pio/libdeps/esp32dev/Adafruit INA219/Adafruit_INA219.h:21,
from .pio/libdeps/esp32dev/Adafruit INA219/Adafruit_INA219.cpp:31:
.pio/libdeps/esp32dev/Adafruit BusIO/Adafruit_SPIDevice.h:6:17: fatal error: SPI.h: No such file or directory
*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:SPI.h"
* Web > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************
Solution
Add SPI
to the lib_deps
in platformio.ini
, for example, before:
lib_deps =
adafruit/Adafruit INA219 @ ^1.1.1
After:
lib_deps =
adafruit/Adafruit INA219 @ ^1.1.1
SPI
and then recompile.