Hi Rui
I’m following the eBook “Build WebServers with ESP32 and ESP8266” and I got stuck on a problem which I subsequently got around but I don’t know if my solution is correct…
I’m attempting the 1_1_Hello_World_WS project and I installed the libraries of AsyncTCP and ESPAsyncWebServer using the method you describe in Module 1. [BTW, I think there’s a library missing from the code extract on page 157: there’s no ASyncTCP mentioned – but I put it in myself] And then the problems began…
I kept getting errors in these two include calls:
#include <ASyncTCP.h> #include <ESPAsyncWebServer.h>
It was then that I changed the < > to ” ” and it worked! It now reads
#include "ASyncTCP.h" #include "ESPAsyncWebServer.h"
Have I done something wrong by using ” ” instead of < > around the libraries? Can you explain what’s going on?
Hi Sean.
PlatformIO handles libraries different than Arduino IDE.
When you include the ESPAsyncWebServer, PlatformIO will automatically search for any dependencies.
How did you include it in the platformio.ini file?
Library names are case sensitive. The library name is “AsyncTCP” and not “ASyncTCP”. That’s why you’ve got the error.
When you change the <> to “”, it assumes that you’re searching for a local library. See the differences here: https://www.arduino.cc/reference/en/language/structure/further-syntax/include/
That’s probably why you stopped getting the error, but I’m not certainly sure.
Change the name to “AsyncTCP” and tell me what you got.
Regards,
Sara
Hi Sara In the .ini file, the libraries have been entered by PlatformIO as
lib_deps = me-no-dev/AsyncTCP@^1.1.1 me-no-dev/ESP Async WebServer@^1.2.3
And in the main.cpp, I’ve included them with the following:
#include "AsyncTCP.h" #include "ESPAsyncWebServer.h"
Seemed to be the only combination that worked. I’ve moved onto project 1_2 and have immediately hit similar problems… any idea, is it perhaps something I’ve not installed in PlatformIO? Cheers Sean
Also, on closer investigation (and trial and error), I discovered AsyncTCP installed in the Built-in library of PlatformIO, and after deleting the .ini ref to the AsyncTCP library the main.cpp file works with the < >
#include <AsyncTCP.h>
And the following library (the most popular in the PIO libraries register) works fine. See .ini and main.cpp:
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
#include "ESPAsyncWebServer.h"
Still getting errors in Rui’s code for 1_2 (“cannot open source SPIFFS.h”) … but I’ll keep trying to figure that one out.
Cheers
Sean
Sara
I think I found the answer: The issue was I had Rui’s code in a different folder than the ‘projects’ folder for PlatformIO. Once I moved them into the ‘projects’ folder the errors went away. Even
ESP Async WebServer
worked (I didn’t need
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
)
All seems right now, sorry to waste your time.
Great course BTW, I’m enjoying it as a Christmas Gift to myself!
Cheers
Sean
Hi Sean.
I’m glad you’re enjoying the course.
Just to clarify, is everything working as explained in the eBook or did you need to make some modifications to make it work for you?
Just to know if we need to make any changes to our instructions.
Regards,
Sara
Hi Sara
I did need to make a change from the eBook, in order to get it to compile reliably I had to use the following library:
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
I’ve made the same change throughout the subsequent modules and it has compiled every time (and the ESP Async Webserver library has rarely worked reliably).
Overall I found the procedures for loading libraries in PIO to be a source of frustration; I was eventually able to find a reliable method, but it doesn’t seem to be straight forward. My method is:
- Create Project in PIO -> close PIO -> copy files from eBook zip -> close windows file explorer -> reopen PIO -> go to PIO libraries and search for ESP -> find ottowinter version and save to project -> close PIO -> reopen PIO -> delete ESP Async Webserver from .ini file -> save -> close/reopen PIO -> errors from main.cpp should have disappeared (fingers crossed).
I know that sounds convoluted, but hey it works for me, and keeps me moving forward.
If I had to guess, I would say the problems seems to be in PIO or maybe even in my files structure (I have my suspicions about oneDrive’s role in this).
Anyway, I certainly wouldn’t recommend updating the code in the eBook based on my experience; I’ve got a solution personalised for my situation and it works reliably now.
Keep up the great work.
Cheers
Sean
Hi Sean.
That’s very weird.
When I load a project folder provided in the course, it works straight away without having to make any modifications.
Anyway, if you have to use that library, I don’t think you need to follow that process you describe. I think, you can simply go to the platformio.ini file, delete the old library and replace it with the new one. Then, just save the platformio.ini file.
I may be wrong. And I have not idea why your projects are behaving that way.
Regards,
Sara