PlatformIO on VS Code does not find Libraries

I just wanted to make the switch to PlatformIO for Arduino. But I always get the same error: it does not find the includes.
I do have all of them in two different dropbox folders which I registered with c_cpp_properties.json:

“/Users/ak/Dropbox/Learn_ProgramEx/Arduino/Elegoo Uno R3/* *”, “/Users/ak/Dropbox/Learn_ProgramEx/Arduino/libraries/**”

But I always get the error that e.g. these libraries are not found with PlatformIO (cs. with the Arduino IDE):
#include <Arduino.h>
#include <LiquidCrystal.h>
#include <SD.h>

And when I try to install them via PIO it even won’t let me enter anything in the search area…

Any ideas?


1 Like

It sounds like you might be having a few different problems.

which I registered with c_cpp_properties.json

… completely ignoring the warning on line 4? Any changes you make will be lost when you do a build.


If you need to modify the include path, use the build_flags for that.

Since you’re trying to include directories with existing collections of libraries, maybe have a look at the lib_extra_dirs setting?

Since you have a new install, it’s possible any IntelliSense warnings/sqiggles about core libraries like Arduino.h are because they’re not installed yet, which will happen automatically when you do your first build, if you’ve set the platform/framework/board settings correctly in your platformio.ini (creating a new project does that for you automatically).

Regarding entering text into the search area, it’s a known bug in VSCode:

Thank you very much.

Yes, I completely overread the warning :blush:

But I found a different way to get my libraries ti platform:
I plainly copies them from the existing libraries. then I did a platform update/upgrade command and voila - (almost) all libraries are there.

Unfortunately, almost: though I even installed LiquidCystal library before the copy-paste platform/VS does not recognize it and refuses to compile.
Same goes for Arduino.h.

Btw this my platform.ini file:

platform = atmelavr
board = uno
framework = arduino

If you have any further suggestions - I would be happy to try them (or get inspired by them) :wink:

So it actually doesn’t find “Arduino.h” when you try to compile… as before you compile isn’t such a problem*… If it fails to find that include file when compiling then there’s something really wrong here, as that’s provided by the arduino framework, and should be working.

Can you copy and paste the output from an attempted compile (use triple backticks - ``` [left of the 1 key on the number row] - before and after to trigger a code block) so we can see the dependency tree and compile errors. Maybe also a minimal code example that fails (or a link to one of it’s a stock example).

*I personally consider that to be more an annoying cosmetic error that doesn’t stop you from actually building your code when it happens

You are right. Something’s really wrong.
Out of curiosity I checked the builtin libs with this command: platformio lib builtin
And then I added to the top of includes the SPI library. And same here: it can’t find it :frowning:
Heres the compile output:

[Running] cd “/Users/ak/Dropbox/Learn_ProgramEx/Arduino/WaterLevel2LCD2SD/src/” && g++ main.cpp -o main && "/Users/ak/Dropbox/Learn_ProgramEx/Arduino/WaterLevel2LCD2SD/src/"main
main.cpp:1:10: fatal error: ‘SPI.h’ file not found
#include <SPI.h>
1 error generated.
[Done] exited with code=1 in 0.091 seconds

So I checked the folders libdeps and within it the folder uno and the build folder: all are empty!
Then I checked the permission and changed them to rwx for all group, did a new lib install - nothing changed. :frowning:

Heres the part of the code I want to compile (which btw doesn’t work correctly neither - the LCD shows cryptic signs instead of the water level. That’s the second problem…

Btw, I tried to use the triple backticks - ``` in the code but just got another “problem”: unexpected token.

#include <SPI.h>
#include <Arduino.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"

const int chipSelect = 10; //10 is default by shield, but normally on Pin 4
int interval = 20;  //Log to SD Card every 5 seconds

long timer;
String timestring;
String mvalue;

RTC_DS1307 rtc;

int adc_id = 0;
int HistoryValue = 0;
char printBuffer[128];
//void write_LCD(int x, int y, bool clearIt, String text);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  Serial.println("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("SD Card error");
  write_LCD(0,0, true, "card initialized");
  Serial.println("card initialized");
  if (! rtc.begin()) {
    Serial.println("No RTC found");
    write_LCD(0,0, true, "No RTC found");
  } else {
    Serial.println("RTC clock found");
    write_LCD(0,0, true, "RTC found");
  if (! rtc.isrunning()) {
    Serial.println("RTC is not configured");
    write_LCD(0,0, true, "RTC not config");
  // set up the LCD's number of columns and rows:
  // Print a message to the LCD.
  lcd.print("Hello, World!");
  Serial.println("Hello World");

void loop() {
  // put your main code here, to run repeatedly:
     int value = analogRead(adc_id); // get adc value
    if(((HistoryValue>=value) && ((HistoryValue - value) > 4)) || ((HistoryValue<value) && ((value - HistoryValue) > 10)))
      sprintf(printBuffer,"ADC%d level is %d\n",adc_id, value);
      mvalue = String(value);
      write_LCD(0,0,true, "Feuchte");
      write_LCD(0,1,false, String(value));
      HistoryValue = value;
 void write_LCD(int x, int y, bool clearIt, String text) {
  if (clearIt) {

void get_time(){ //Read Time from RTC
  DateTime now =;
  timestring =;
  timestring += "-";
  timestring += now.month();
  timestring += "-";
  timestring += now.year();
  timestring += " ";
  timestring += now.hour();
  timestring += ":";
  timestring += now.minute();
  timestring += ":";
  timestring += now.second();

void write_data() { //Write to SD card
  String dataString = mvalue + "," + timestring;
  File dataFile ="datalog.txt", FILE_WRITE);
  if (dataFile) {
  else {
    Serial.println("error writing datalog.txt");

Can you unpack this, add the folder to your workspace (File -> Add folder to workspace in VSCode) and see if that works. It’s your source code, with a different platformio.ini and the three external libraries you’re using included in the fake_external_lib_dir. The include list in the main.cpp is in a different order, but that is just cosmetic… I just grouped the builtin libraries and then external ones to make sense of what was what. :wink:

Note: You’ll need to update the lib_extra_dirs parameter in the platformio.ini as the path won’t be correct for you! :wink:

If that doesn’t work (it compiles fine for me), we’ll need to look at your platformio install, and see what’s going on.

No, I am sorry. It seems that platformio doesn’t find any library at all: if I comment out include after include it is always the next include that gives me an error.
Some even more disturbing happens: I always (at several times) get asked to install the platformio library (platformio lib install).
Perhaps I should do a complete deinstall of VS and all plugins?

Thanks you for your help!

That sounds more like the error message you get when you try to include a library that isn’t installed, and it’s suggesting how to install it.

You shouldn’t need to remove VSCode, just platformio so that the VSCode PlatformIO extension can re-install it. Navigate to your home directory (~ on linux, %USERPROFILE% on windows, not sure about Mac), and delete the .platformio folder. When you start VSCode up again, the extension will detect that PlatformIO is missing and reinstall it.


1 Like

I can not considered this answered. Have the same problem.

PlatformIO does not find the arduino esp32 libraries or any library since it is not explained!

  1. How do I find then ??? THe library module wants a specific name , HOW WHERE can I find all those required names (FULL ARDUINO ESP32 library )
    Nothing is explained here nor nowhere since in arduino IDE all is build in … Assitance is required

  2. in the case we know Where it is … ( i linked the full arduino library (
    lib_extra_dirs =c:\ArduinoIDE\libraries
    but that does not help a single litte bit …

i did : additionaly Build Clean
Build Check
library updates
platform updates
update all
upgrade PlatformIO CORE

and can compile my hello world example once to be forced to do everything over and over again

Reinstalling everything just works ONCE(very unclear why) , mainly ALL includepaths are not found ( not even root/include root/ lib for all versions all but that single run ,

only known probles cannot open ource file “*.h” Arduino.h WiFi.h …
because no one can explain how to force platformIO to look at any specific place
or the window file structure is corrupted after one run … (windows 10 user)

probles A) No way to know what area of arduino-Ide to share with platform IO
B) No way to know how (what keyword to use in platformIO library search
C) no way to know how to FORCE platform IO to look at places where I KNOW THEY ARE

if this is a bug or something to blame to Microsoft THe whole PLATFORMio sucks
it is far to basics to put the blame on someone else …

lib_extra_dirs =c:\archive\Arduino\Arduino\libraries
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
;          upload_speed = 921600
;debug_tool = minimodule

Which library? Please BE SPECIFIC, and less waffle!

If you wish to use any of the libraries provided with the ESP32 Arduino core, there is no need to use the lib_extra_dirs parameter, and no need to specify them via the lib_deps parameter. They are also included with PlatformIOs ESP32 platform support, and only required the correct #include line to be given in your main source file.

For example, I just created a new esp32 project (on Windows 10), using the following platformio.ini

platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
;          upload_speed = 921600
;debug_tool = minimodule

… i.e. the one you gave above, but I omitted the [env] block as neither of those options are needed. I then copied the WifiClient example code from the Arduino ESP32’s WiFi library examples, and replaced the contents of the defaultmain.cpp file, ensuring I kept the #include <Arduino.h> line. I then compiled the code successfully, and have no red underlines, nor any entries in the Problems tab. Compile log is also included below.

Are you able to do the same, and if not, what exact errors do you get, and what compile error messages do you get?

Addendrum: I do get two entries in the ‘Problems’ tab, and red squiggle underlines under #include <WiFi.h> if I switch to another project and then back again to this one, which is one of the symptoms of the known bug in the Microsoft C/C++ extension, which Ivan linked to earlier. It appears that as part of a major overhaul as to how the multi-root workspaces are handled this has finally been fixed, and will be available as part of the 0.27.0 release of the extension, which hopefully won’t be too far away. [Edit: Apparently scheduled for 30th March!!] Regardless, this has no impact whatsoever on the code actually compiling/uploading/functioning, so whilst it is an annoyance, it is not an issue preventing you from developing code.

> Executing task in folder forum_dreuzel_esp32_wifi: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run <

Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 1.11.2 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 26 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.0
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\ETH.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFi.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiAP.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiMulti.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiSTA.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiScan.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8b5\WiFi\WiFiUdp.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib8b5\libWiFi.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Indexing .pio\build\esp32doit-devkit-v1\lib8b5\libWiFi.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Indexing .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Linking .pio\build\esp32doit-devkit-v1\firmware.elf
Building .pio\build\esp32doit-devkit-v1\firmware.bin
Retrieving maximum program size .pio\build\esp32doit-devkit-v1\firmware.elf
Checking size .pio\build\esp32doit-devkit-v1\firmware.elf v2.6
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.8% (used 38720 bytes from 327680 bytes)
Flash: [=====     ]  48.9% (used 641250 bytes from 1310720 bytes)
======================================================= [SUCCESS] Took 66.79 seconds =======================================================

Terminal will be reused by tasks, press any key to close it.