3

What I am trying to do

I have an ESP32-CAM, and I want to use Visual Studio Code, I already used the Arduino IDE at first, and it worked fine.

To work with the ESP32 on VS Code I installed the extension from espressif, it seems to "work".

I created a new project arduino-as-component which give me a main.cpp like this

#include "Arduino.h"

extern "C" void app_main() { initArduino(); pinMode(4, OUTPUT); digitalWrite(4, HIGH); // Do your own thing }

My problem

When I build the project that a newly created, without changing a thing, I get an error

../main/main.cpp:1:10: fatal error: Arduino.h: No such file or directory        
 #include "Arduino.h"

Things I tried

I downloaded the library from the Espressif Github, and imported it inside the file main/CMakeLists.txt

idf_component_register(
    SRCS "main.cpp"
    INCLUDE_DIRS "./libraries/arduino/cores/esp32"
)

But then I get a new error

../main/libraries/arduino/cores/esp32/Arduino.h:28:10: fatal error: avr/pgmspace.h: No such file or directory
 #include <avr/pgmspace.h>

I feel like I could have endless errors like this, and that it's not the right way to import a library.

I also tried to use a code that worked on the aduino IDE, but I get similar errors.

anonymous2
  • 4,902
  • 3
  • 22
  • 49
Gregory Boutte
  • 181
  • 2
  • 8

1 Answers1

0

If you are using ESP-IDF and VS Code you will need to

  • Press "F1"
  • Type "Arduino"
  • Click on the option "add Arduino as component"

You wait, and it will be installed. After the installation, it should compile correctly.

Rohit Gupta
  • 507
  • 2
  • 3
  • 18