Fatal error: Adafruit_NeoPixel.h: No such file

HI. I see a number of posts with this issue, but I still couldn’t resolve my problem.

I have the Adafruit Library included, but when I go to compile, it cannot find the header file. I even tried to include the lib path to the header file, as QuickFix suggested, but nope.

PlatformIO.ini:

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = espidf
lib_deps = adafruit/Adafruit NeoPixel@^1.10.4

What am I doing wrong?

This is a Arduino library, but you’re using the ESP-IDF framework. These are not compatible to each other.

It seems to me that you’re trying to use a ESP32-C3 board with Arduino instead of the ESP-IDF SDK. Using the new Arduino 2.0 core which supports C3 board is an open issue (Support for the latest Arduino v2.0 · Issue #619 · platformio/platform-espressif32 · GitHub), and due to the war, we can’t expect anything there at the moment, but should instead pray for the developers to get out of this alive.

However, other uses have made custom platform extensions that can help you. I currently recommend for you using the platformio.ini

[env:esp32-c3-devkitm-1]
platform = https://github.com/Jason2866/platform-espressif32.git
board = esp32-c3-devkitm-1
framework = arduino
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
lib_deps = adafruit/Adafruit NeoPixel@^1.10.4

(Requires Git to be installed).

Be aware, this installs the bleeding edge platform and Arduino core, which might have bugs.

(I currently don’t recommend using the version at Support for the latest Arduino v2.0 · Issue #619 · platformio/platform-espressif32 · GitHub because String.replace() has a bug that makes it unusable).

With this platformio.ini and a src/main.cpp of

#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
void setup(){}
void loop(){}

I can compile successfully.

Dependency Graph
|-- <Adafruit NeoPixel> 1.10.4
Building in release mode
Compiling .pio\build\esp32-c3-devkitm-1\src\main.cpp.o
Linking .pio\build\esp32-c3-devkitm-1\firmware.elf
Retrieving maximum program size .pio\build\esp32-c3-devkitm-1\firmware.elf
Checking size .pio\build\esp32-c3-devkitm-1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.8% (used 9216 bytes from 327680 bytes)
Flash: [=         ]  13.0% (used 170118 bytes from 1310720 bytes)
Building .pio\build\esp32-c3-devkitm-1\firmware.bin
esptool.py v3.2.1
Creating esp32c3 image...
Merged 2 ELF sections
Successfully created esp32c3 image.
=======================[SUCCESS] Took 4.54 seconds =======================

Note: After saving the new platformio.ini, PlatformIO will do a task refresh in which it downloads the new platform. This will take a few minutes to complete, depending on the internet and Github connection speed. Before the task refreshing has not finished, one should not press the Build button.

Note 2: If you already created a ESP-IDF project, then PlatformIO may have create CMakeLists.txt and src/main.c etc. for you. You can delete these files and only create src/main.cpp with the code above.

Thank you. That got me unblocked!

I’m going to try to figure out all the .ini settings you’ve given me.

I’m sure i’ll be back with more questions, but again, thank you!


I wish all those in Ukraine and the soldiers on both side who are fighting this war, well, and hope this war ends soon before more lives are lost.

How do I start to move away from Arduino and start to do more work directly with ESP32_ESP-IDF? I suppose I might lose out on a lot of libraries, but I also notice that there are many libraries written for ESP32_ESP-IDF.

I am hoping that that is a more robust way to write code for ESP than to go through a lot of the Arduino legacy.

The current Arduino core is just a component slapped on top of ESP-IDF v4.4 (currently) that implements the Arduino API + libraries. It’s not ages behind the most current ESP-IDF version anymore like before. So one might really see it as a precompiled (static config), fairly recent ESP-IDF plus the Arduino API implementation – not so much difference to ESP-IDF.

The latest ESP-IDF supported by PIO is per Releases · platformio/platform-espressif32 · GitHub v4.3.1, and esp32-c3-devkitm-1 has ESP-IDF support in PlatformIO, so you should be able to develop for that with no problems.

Are you saying that I am not giving up too much for staying with Arduino core? I’ll try to find more to read on this.

How would I best handle errors like this:

src/main.cpp: In function ‘void app_main()’:
src/main.cpp:121:32: error: ‘GPIO_NUM_33’ was not declared in this scope
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
^~~~~~~~~~~
src/main.cpp:121:32: note: suggested alternative: ‘GPIO_NUM_13’
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
^~~~~~~~~~~
GPIO_NUM_13
src/main.cpp:121:3: error: ‘esp_sleep_enable_ext0_wakeup’ was not declared in this scope
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
esp_sleep_enable_wifi_wakeup
*** [.pio/build/esp32-c3-devkitm-1/src/main.cpp.o] Error 1

I feel like if I make a clean break with Arduino (and reduce the number of places something is configured wrongly), then I don’t have to wonder if this problem is because of an Arduino piece that is missing or something else?

(The above is code from Arduino that I am moving over to PlatforimIO and VSCode.)

In Arduino, you implement setup() and loop(), not app_main().

Better use the Arduino APIs for attachInterrupt().

Do #include <hal/gpio_hal.h>.

I was getting ready to transition away from Arduino. For now I am doing:

void setup(){
    app_main();
}

That doesn’t attach a wakeup interrupt for the ESP32. At least it doesn’t do it when I use attachInterrupt(). This call tells the ESP32 to wake up from deep sleep when there is an interrupt and the other one doesn’t wake it up.

That led me to <esp_sleep.h> which has my sleep interrupt function included.

I’ve included both but am getting the same exact errors. And no errors on not finding the header files. Odd. I’ll quit and relaunch VSC…