ESP AsyncWebServer & ESP8266WiFi problem

Hi.
I am trying to build this ESPAsyncServer example (for Wemos D1) on PlatformIO IDE. (Win10)
The program is copied from techtutorialsx.com (and builds & Compiles/Run with no problem in Arduino IDE).

But in PlatformIO, (when building) I get a lot of errors related to the ESP8266WiFi module i.e.

lib\ESP8266WiFi\src/BearSSLHelpers.h:149:34: error: 'virtual const unsigned char*     BearSSL::HashSHA256::oid()' marked override, but does not override

lib\ESP8266WiFi\src/BearSSLHelpers.h:149:34: error: 'virtual const unsigned char* BearSSL::HashSHA256::oid()' marked override, but does not override

etc.

Program code

//**************************************************
#ifdef ESP32
  #include <WiFi.h>
  #include <ESPAsyncWebServer.h>
#else
 #include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <Hash.h>
 #include <ESPAsyncTCP.h>
 #include <ESPAsyncWebServer.h>
#endif

const char* ssid = "xxx";
const char* password =  "xxx";

AsyncWebServer server(80);

void setup() {
Serial.begin(115200);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) 
 {
  delay(1000);
  Serial.println("Connecting to WiFi..");
}

Serial.println(WiFi.localIP());

server.on(
     "/post",
HTTP_POST,
[](AsyncWebServerRequest * request){},
NULL,
[](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) {

  for (size_t i = 0; i < len; i++) {
    Serial.write(data[i]);
  }

  Serial.println();

  request->send(200);
});

server.begin();
}

void loop() {}

//**************************************************

I am using Platform IO 2.2.0 Core 4.0.1b3

I have manually installed the libraries
ESP8266WiFi
ESPAsyncTCP
ESPAsyncWebServer
in the lib folder of the project.

The ESP8266WiFi folder is downloaded today from

Iā€™m no PlatformIO pro, so I am grateful for all the help I can getā€¦

/Gurra

There is no need to install ESP8266WiFi locally. Itā€™s part of the basic Arduino libraries and therefore part of the PlatformIO. In fact, it might even be the cause of the problem (a conflict between installed and downloaded version),

Furthermore, you donā€™t need to manually download the other libraries. You can just copy the GitHub link and add it to platform.ini. PlatformIO will take care of the rest. Iā€™ve successfully built the code with these settings (and with an empty lib directory):

[env:d1_mini_lite]
platform = espressif8266
board = d1_mini_lite
framework = arduino

lib_deps =
    https://github.com/me-no-dev/ESPAsyncTCP.git
    https://github.com/me-no-dev/ESPAsyncWebServer.git
1 Like

OK, thank you for a fast reply.

I removed all three locally installed libraries and added the lib_deps section to platform.ini.
After that I got a complaint that I was missing Git.
I downloaded Git and accepted all default settings.
After restart the program seems to accept ESPAsyncTCP & ESPAsyncWebServer
but it complains that it cant find ESP8266WiFi.h

>Executing task in folder ESP_AsyncWebServer-POST: 
    C :\Users\gunna\.platformio\penv\Scripts\platformio.exe run <


Processing d1_mini (framework: arduino; platform: espressif8266; board: d1_mini)
    ------------------------------------------------------------------------------------------------------------------------------------- 
   ---------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 2.2.2 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: toolchain-xtensa 2.40802.190218 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 
1.20600.0 (2.6.0), framework-arduinoespressif8266 2.20502.0 (2.5.2)    
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESPAsyncTCP> 1.2.0 #7e9ed22
|-- <ESP Async WebServer> 1.2.2 #b0c6144
|   |-- <ESPAsyncTCP> 1.2.0 #7e9ed22
|   |-- <Hash> 1.0
|-- <Hash> 1.0
Compiling .pio\build\d1_mini\src\main.cpp.o
Archiving .pio\build\d1_mini\lib14e\libHash.a
Compiling .pio\build\d1_mini\lib16c\ESP Async WebServer\AsyncEventSource.cpp.o
src\main.cpp:21:27: fatal error: ESP8266WiFi.h: No such file or directory
Compiling .pio\build\d1_mini\lib16c\ESP Async WebServer\AsyncWebSocket.cpp.o

*********************************************************************
* Looking for ESP8266WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ESP8266WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:ESP8266WiFi.h
*
*********************************************************************

   #include <ESP8266WiFi.h>
                       ^
compilation terminated.
*** [.pio\build\d1_mini\src\main.cpp.o] Error 1
In file included from .pio\libdeps\d1_mini\ESP Async WebServer\src\AsyncEventSource.h:29:0,
             from .pio\libdeps\d1_mini\ESP Async WebServer\src\AsyncEventSource.cpp:21:
.pio\libdeps\d1_mini\ESP Async WebServer\src/ESPAsyncWebServer.h:35:25: fatal error: 
ESP8266WiFi.h: No such file or directory

*********************************************************************
* Looking for ESP8266WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ESP8266WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:ESP8266WiFi.h
*
*********************************************************************

 #include <ESP8266WiFi.h>
                     ^
compilation terminated.
*** [.pio\build\d1_mini\lib16c\ESP Async WebServer\AsyncEventSource.cpp.o] Error 1
In file included from .pio\libdeps\d1_mini\ESP Async WebServer\src\AsyncWebSocket.h:32:0,
             from .pio\libdeps\d1_mini\ESP Async WebServer\src\AsyncWebSocket.cpp:22:
.pio\libdeps\d1_mini\ESP Async WebServer\src/ESPAsyncWebServer.h:35:25: fatal error: 
ESP8266WiFi.h: No such file or directory

*********************************************************************
* Looking for ESP8266WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ESP8266WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:ESP8266WiFi.h
*
*********************************************************************

#include <ESP8266WiFi.h>
                     ^
compilation terminated.
*** [.pio\build\d1_mini\lib16c\ESP Async WebServer\AsyncWebSocket.cpp.o] Error 1
*** [.pio\build\d1_mini\lib16c\ESP Async WebServer\AsyncEventSource.cpp.o] Error 1
*** [.pio\build\d1_mini\lib16c\ESP Async WebServer\SPIFFSEditor.cpp.o] Error 1
=========================================================================== 
[ERROR] Took 4.18 seconds 
===========================================================================
The terminal process terminated with exit code: 1

I have tried different locations when saving the sourcefile, ( as I struggled with a lot of problems earlier, when trying to be smart & save the file to a folder that is synced via OneDrive). (That caused a lot of problems with locked CS Code files etc.)
But the error persists, even when I save the file to my own local folderā€¦

Any ideas what to do ??

/Kind regards : Gurra

I get a different result. The dependency finder identifies ESP8266WiFi as a dependency and includes into the dependency graph. Are you using the latest PlatformIO version?

Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 2.2.2 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: toolchain-xtensa 2.40802.190218 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20600.0 (2.6.0), framework-arduinoespressif8266 2.20502.0 (2.5.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESPAsyncTCP> 1.2.0 #7e9ed22
|   |-- <ESP8266WiFi> 1.0
|-- <ESP Async WebServer> 1.2.2 #b0c6144
|   |-- <ESPAsyncTCP> 1.2.0 #7e9ed22
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <Hash> 1.0
|-- <ESP8266WiFi> 1.0
Compiling .pio/build/d1_mini/src/main.cpp.o
Generating LD script .pio/build/d1_mini/ld/local.eagle.app.v6.common.ld
Compiling .pio/build/d1_mini/libb6d/ESP8266WiFi/BearSSLHelpers.cpp.o
Compiling .pio/build/d1_mini/libb6d/ESP8266WiFi/CertStoreBearSSL.cpp.o
...

Hi again.

I am using PlatformIO Home 2.2.0 Core 4.0.1b3

(The Windows error Message (in the enclosed output), is ā€œAccess Deniedā€ in English)ā€¦

I have even tried deleting the .pio folder tree so the compiler can recreate it but with the same resultā€¦

It creates the whole catalogue structure under .pio\libdeps\d1_mini\ESPAsyncServerā€¦etc.
but the problem remains

  git version 2.22.0.windows.1
  Cloning into 'c:\Users\gunna\Documents\ESP_AsyncWebServer- 
 POST\.pio\libdeps\d1_mini\_tmp_installing-mec816-package'...    
 WindowsError: [Error 5] ā”¼tkomst nekad: 'c:\\Users\\gunna\\Documents\\ESP_AsyncWebServer- 
POST\\.pio\\libdeps\\d1_mini\\_tmp_installing-mec816- 
package\\.git\\objects\\07\\07d4a3a7a121a3d36b7a540c5affe09276b04f':

Kind regardsā€¦
/Gurra

Did some more troubleshootingā€¦

I Stopped my OneDrive Sync (which synchronizes ā€œMy Documentsā€ folder, plus other folders),
I uninstalled VS Code, and manually uninstalled the folders in My Documents (.platformio, Apps/Local/programs/Microsoft VS Code etc. etc.), restarted the PC & reinstalled VS Code.

but the problem persisted (compile errors regarding a missing ESP8266WiFi.h file etc.)

I tried deleting the .pio folder in my project & started a new build, but no change,

BUT when I deleted the .vscode folder in my project and started a new build, the compiler errors about a missing ESP8266WiFi.h etc. disappearedā€¦

I dont know if this is a bug in VS Code / PlatformIO, or if I caused the problem by installing VS Code with OneDrive sync runningā€¦

Maybe someone who has more experience of VS Code/PlatformIO than me, can sort this outā€¦

/Gurra

1 Like

Whatā€™s in your platform.ini?

Permissions errors are something on your end, but if youā€™ve gotten rid of them, itā€™s now hopefully down to something easily fixed.

Are you referring to my
platformio.ini ? If so, its very simple

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
upload_port = COM[3]
monitor_speed = 115200
monitor_port = COM3
lib_deps =
https://github.com/me-no-dev/ESPAsyncTCP.git
https://github.com/me-no-dev/ESPAsyncWebServer.git

After the disappearance of the ESP8266WiFi.h error , Build & Upload works just fine (no compile errors at all)ā€¦

(so iā€™m happy again :grinning: )

(Many thanks to you & the community for helping me with my problems.

/Gurra

1 Like

Sorry, yes platformio.ini ā€¦ :slightly_smiling_face:

File look fine. You donā€™t need the square brackets around the 3 for the com port unless you want to specify a range. And the lines after lib_deps should be indentedā€¦ but thatā€™s probably something that was lost in the copy 'n pasteā€¦ as you canā€™t even build a project until the indent is correct :wink:

It could have been something out of sync with one drive, or perhaps the compiler needed a kick in the backside so that it updated the include pathsā€¦ removing the .vscode folder can often liven that part of it upā€¦ Anyway, itā€™s workingā€¦ so all good! :smiley:

Yes thank you for your comments.

As you say the indentation in platformio.ini disappeared during copy/paste hereā€¦

Does anybody know if there are any problems regarding installing VS Code /PlatformIO in its default location (C:\users\billy\Documentsā€¦etc.), if you also have OneDrive installed and OneDrive is set to synchronize your C:\users\billy\Documentsā€¦ tree ??)

This has given me a lot of strange problems.

It seems like OneDrive and the VS Code/platformio database .browse.c_cpp.db (that is created in every project), is not a good combo.

Any ideas how to avoid this problem ??
.
/Regards: Gurra

I would suspect since the .browse.c_cpp.db C++ IntelliSense database is constantly updated by the C++ extension whilst youā€™re working on your code, itā€™s not good to have it somewhere where any ā€˜realtimeā€™ file sync (Dropbox, Google Drive, OneDrive) operates on it whilst VSCode is open. You could use selective sync and ignore the entire .vscode folder, as neither it or the .pio/.piolibdeps folders are needed, nor should be synced onto another machineā€¦ and will be rebuild on other machines as needed.

Note: when I say .vscode shouldnā€™t be synced, itā€™s predominatley because platformio auto-generates the c_cpp_properties.json and launch.json files, extensions.json would only change if you had workspace specific extensions, and settings.json if you had workspace specific settings. Unless there is something else Iā€™ve missed, I donā€™t know of a good reason to sync that folder onto other machines.

Thats what I suspected, tooā€¦

The problem is if I want a partial sync of the default folder where my projects are created,
to get a backup of the src folder of the projects, but no backup of the subfolders ( .pio, .vscode etc.).
It will be a real pain if I have to change settings of OneDrive sync folder settings, every time I create a new projectā€¦(so the sync includes the projects src folder & excludes the subfolders for the project).

I hope the PlatformIO developers (or Microsoft) will find a solution to this as both VS Code/PlatformIO & OneDrive are quite popular programsā€¦

1 Like

Trueā€¦ and itā€™s a problem Microsoft as the developers of VSCode and the C++ extension will need to determine if itā€™s worth doing something about (as all sync software will be prone to issues, doubly so if you use git source control as well) or stating itā€™s not a supported use case. There are configuration options that make IntelliSense used a different/common folder, which is the subject of a github issue as I believe that doesnā€™t work due to how PlatformIO hooks into the C++ extension to configure it.