SPI.h: No such file or directory

C:\users\ats37.platformio\lib\Adafruit-GFX-Library\Adafruit_SPITFT.h:8:18: fatal error: SPI.h: No such file or directory
I tried to make matrixtest for NeoPixel work, but PlatformIO can’t find SPI.h

PS D:__Dokus\Documents\PlatformIO\Neo_Pixel_Matrix_Test> pio upgrade
You’re up-to-date!
PlatformIO 4.2.0 is currently the newest version available.

platformio.ini and the code you’re running?

PlatformIO.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino

The Code is

In PlatformIO, you need to declare the libraries you want to use in platformio.ini (instead of installing them).

So your platformio.ini file should look like:

[env:uno]
platform = atmelavr
board = uno
framework = arduino

lib_deps =
         Adafruit NeoMatrix
         Adafruit NeoPixel
         Adafruit GFX Library
         SPI

You will also need to save a copy of smileytongue24.h into the include directory within your project as this file is part of an example and not part of the library itself.

Additionally, you’ll have to fix this line (as the library uses constants outside the range of the data type and PlatformIO is more strict in flagging it as an error):

    uint16_t bmpcolor[] = { (uint16_t)LED_GREEN_HIGH, (uint16_t)LED_BLUE_HIGH, (uint16_t)LED_RED_HIGH };
5 Likes

Hello Thank you
put SPI, Adafruit_NeoPixel, Adafruit_NeoPixel,Adafruit GFX Library_ID13 in the Project lib Folder

I did’t know what to do with

uint16_t bmpcolor = { (uint16_t)LED_GREEN_HIGH, (uint16_t)LED_BLUE_HIGH, (uint16_t)LED_RED_HIGH };

Can complie it with the Arduino IDE at least.

In file included from lib\Adafruit GFX Library_ID13\src\Adafruit_SPITFT.cpp:36:0:
lib\Adafruit GFX Library_ID13\src\Adafruit_SPITFT.h:26:17: fatal error: SPI.h: No such file or directory
In file included from lib\Adafruit GFX Library_ID13\src\Adafruit_SPITFT.cpp:36:0:
lib\Adafruit GFX Library_ID13\src\Adafruit_SPITFT.h:26: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 > PlatformIO Registry

Why not do it the way I proposed?

1 Like

I did except uint16_t bmpcolor[] = { (uint16_t)LED_GREEN_HIGH, (uint16_t)LED_BLUE_HIGH, (uint16_t)LED_RED_HIGH }; what shell I do with this

If you are still getting:

...: fatal error: SPI.h: No such file or directory

then your platformio.ini is most likely different from the one I proposed.

Can you show your platformio.ini file? Can you also delete everything in libs?

Regarding uint16_t bmpcolor[] = .... Once you have fixed all library problems, you will get a single complation error. Replace the problematic line with:

    uint16_t bmpcolor[] = { (uint16_t)LED_GREEN_HIGH, (uint16_t)LED_BLUE_HIGH, (uint16_t)LED_RED_HIGH };
1 Like

I did it my way First I compiled a necked frame on main.cpp then I put SPI.h as first include then all the other Libraries I wrote all the prototypes above Setup and It comilied the sketch . I don’t even get a warning thank you for helping. I wish a nice week

1 Like

hi manuelbl,

I encountered such issues just now, and resolved using your suggested methods. Thank you.

Thank you kind sir I added SPI to my libs_deps and it worked