Failure building Adafruit Sensor Calibration Library - can't find Adafruit_SPIFlash.h

I’m building a project that leverages sensor data and have been having problems ever since I started including Adafruit’s Sensor Calibration library. More specifically, at compile time I’m seeing the following error message:

In file included from .pio/libdeps/altimeter/Adafruit Sensor Calibration/Adafruit_Sensor_Calibration.h:61:0,
                 from .pio/libdeps/altimeter/Adafruit Sensor Calibration/Adafruit_Sensor_Calibration.cpp:1:
.pio/libdeps/altimeter/Adafruit Sensor Calibration/Adafruit_Sensor_Calibration_SDFat.h:14:10: fatal error: Adafruit_SPIFlash.h: No such file or directory

And this is what the offending line in the library looks like:

#if defined(EXTERNAL_FLASH_DEVICES) || defined(PIN_QSPI_SCK)
#include <Adafruit_SPIFlash.h>

What’s weird is that #include <Adafruit_SPIFlash.h> was already included in my main.cpp long before I started using the sensor calibration library and it never gave me any issues about not finding the SPIFlash header file.

My platformio.ini reads as follows:

platform = nordicnrf52
board = adafruit_clue_nrf52840
framework = arduino
lib_ldf_mode = deep+
lib_deps = 
	adafruit/Adafruit SPIFlash@^3.4.1
	adafruit/SdFat - Adafruit Fork@^1.2.3
	adafruit/Adafruit Arcada Library@^2.5.0
	adafruit/Adafruit BMP280 Library@^2.1.1
	adafruit/Adafruit EPD@^4.3.2
	adafruit/Adafruit AHRS@^2.2.4
	adafruit/Adafruit Sensor Lab@^0.4.2
	adafruit/Adafruit Sensor Calibration@^1.1.2

And I can see both libraries Adafruit Sensor Calibration and Adafruit SPIFlash correctly installed in the project’s libdeps folder.

What am I missing?

Seems like you’ve found a bug in PlatformIO’s LDF. I was able to reproduce your error with the above platformio.ini and minimal code

#include <Arduino.h>
#include <Adafruit_Sensor_Calibration_SDFat.h>

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

Please report it to Issues · platformio/platformio-core · GitHub.

I’ve also checked that lib_ldf_mode = chain+ does not make a difference.

To compile it, some workarounds have to be used to help PlatformIO…


at the bottom of the platformio.ini defines that macro to the same value is it would be normally, but PlatformIO then sees the dependency correctly.

1 Like

Thanks for the quick response!
Bug filed at Failure building Adafruit Sensor Calibration Library - can’t find Adafruit_SPIFlash.h · Issue #3907 · platformio/platformio-core · GitHub

The workaround works great!