PlatformIO on VS Code does not find Libraries

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

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
upload_port=COM4
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
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
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)
PACKAGES:
 - 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 -> http://bit.ly/configure-pio-ldf
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
esptool.py 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.
2 Likes