ESP32 handling GET requests and sending GET requests at the same time?

Hey, sorry I have no idea where to put this..

I spent HOURS on Google and there is Absolutely NOTHING about this subject..

I'm running an ESP32 system, and an ESP8266 system. I need to communicate with the ESP8266.
I need to send GET requests like "123.123.2.12/LEDON" to the ESP8266 from my ESP32. BUT at the same time the ESP32 need's to respond to GET requests from my phone or others.

HOW???

I found AsyncWebServer but I think this is different. I need something to send GET requests to a specific URL / IP like "123.123.2.12/LEDON" I can't find that in AsyncWebServer. I only find stupid things like "request->send(200, "text/plain", "Hello, GET: " + message);"

use HttpClient library to send a GET request.

and either to espwebserver or aSyncWebserver to respond to request.

Deva_Rishi:
and either to espwebserver or aSyncWebserver to respond to request.

You mean I should use httpClient to SEND the requests to the ESP8266
AND in the same sketch use AsyncWebServer to read the requests coming in? Will that work together?

Here is what I understand on the subject.

  • On the ESP8266, you need to run a web server, and receive request to light on or off your led.
  • On the ESP32, you need to run a web server (async or not) to receive the requests from internet AND run a client that will send the commands to the ESP8266.

Here is a tutorial fro ESP32 to learn to parse incoming requests. Another one here for ESP8266.

For the client, just look at the examples of the library.

juniq:
You mean I should use httpClient to SEND the requests to the ESP8266
AND in the same sketch use AsyncWebServer to read the requests coming in? Will that work together?

yes

Juraj:
use HttpClient library to send a GET request.

That is not helpful man.. Read my question before you answer.

lesept:
Here is what I understand on the subject.

  • On the ESP8266, you need to run a web server, and receive request to light on or off your led.
  • On the ESP32, you need to run a web server (async or not) to receive the requests from internet AND run a client that will send the commands to the ESP8266.

Here is a tutorial fro ESP32 to learn to parse incoming requests. Another one here for ESP8266.

For the client, just look at the examples of the library.

lesept:
Here is what I understand on the subject.

  • On the ESP8266, you need to run a web server, and receive request to light on or off your led.
  • On the ESP32, you need to run a web server (async or not) to receive the requests from internet AND run a client that will send the commands to the ESP8266.

Here is a tutorial fro ESP32 to learn to parse incoming requests. Another one here for ESP8266.

For the client, just look at the examples of the library.

lesept:
Here is what I understand on the subject.

  • On the ESP8266, you need to run a web server, and receive request to light on or off your led.
  • On the ESP32, you need to run a web server (async or not) to receive the requests from internet AND run a client that will send the commands to the ESP8266.

Here is a tutorial fro ESP32 to learn to parse incoming requests. Another one here for ESP8266.

For the client, just look at the examples of the library.

You don't seem to understand the problem.. I know how to build a server and a client.
BUT they don't work together in one sketch. Either one of them (server or client) fails.

What sketch exactly? I don't see it...
I have done this already (server and client on ESP32) and it works.

Juraj:
yes

I owe u a beer man. Thanks!! it works like a charm! :smiley: So basically what this AsyncWebServer does is running on the second cpu core? Or why is it running in background letting me do anything I want in the void loop?

Juraj:
yes

I owe u a beer man. Thanks!! it works like a charm! :smiley: So basically what this AsyncWebServer does is running on the second cpu core? Or why is it running in background letting me do anything I want in the void loop?

Thanks a lot!

So basically what this AsyncWebServer does is running on the second cpu core? Or why is it running in background letting me do anything I want in the void loop?

as far as i know it runs on any single cores esp8266 just as well. It may run on the second core i don't know, but the main difference with the ordinary espWebServer is that you don't need to call .handleClient() , it sort does that for you, i think it makes use of events, the normal webserver let's you do whatever you want as well, as long as you call .handleClient() You probably understand that that has both advantages & disadvantages (you may not always want any process to be interrupted)

lesept:
What sketch exactly? I don't see it...
I have done this already (server and client on ESP32) and it works.

I got it running now. But I face a new problem. My Watchdog get's triggered.

##E (12693) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in ##time:
##E (12693) task_wdt: - async_tcp (CPU 0/1)
##E (12693) task_wdt: Tasks currently running:
##E (12693) task_wdt: CPU 0: IDLE0
##E (12693) task_wdt: CPU 1: loopTask
##E (12693) task_wdt: Aborting.

Here is the code: (I marked the point of the WDT with "========================="

Ok sry the code is too long to post.
Check the code here: http://peerless-records.de/public_share/code.txt

Deva_Rishi:
as far as i know it runs on any single cores esp8266 just as well. It may run on the second core i don't know, but the main difference with the ordinary espWebServer is that you don't need to call .handleClient() , it sort does that for you, i think it makes use of events, the normal webserver let's you do whatever you want as well, as long as you call .handleClient() You probably understand that that has both advantages & disadvantages (you may not always want any process to be interrupted)

Hey check my latest reply on this subject. Maybe you can help me out with this? It's working but my watchdog gets triggered and I don't know why. I could disable it with the ESP-IDF Tools but downloading these tools would take like 5 hours.. (slow internet here).

my watchdog gets triggered and I don't know why.

If your wdt gets triggered it is because it doesn't get reset within 2.5s The best way to prevent this is to add yield();in your code where there are long (or infinite) loops.
yield(); tells the processor to executed scheduled tasks (FI task related to your wifi connection that are happening in the background) Normally at the end of loop() a yield() is executed automatically, delay() also executes a yield() (delayMicroseconds() does not ! ) I haven't checked you code, you should post it here (within </> code-tags ), not somewhere else if you want it looked at.

Deva_Rishi:
If your wdt gets triggered it is because it doesn't get reset within 2.5s The best way to prevent this is to add

yield();

in your code where there are long (or infinite) loops.
yield(); tells the processor to executed scheduled tasks (FI task related to your wifi connection that are happening in the background) Normally at the end of loop() a yield() is executed automatically, delay() also executes a yield() (delayMicroseconds() does not ! ) I haven't checked you code, you should post it here (within </> code-tags ), not somewhere else if you want it looked at.

I can't post my code here. It's too long :confused: (more than 9000 lines :D)

I still don't understand what yield actually does.. and where I should put it. Before my delay's?
I can not use delay more than 2.5 seconds in my script ?? that's stupid...

Deva_Rishi:
If your wdt gets triggered it is because it doesn't get reset within 2.5s The best way to prevent this is to add yield();in your code where there are long (or infinite) loops.
yield(); tells the processor to executed scheduled tasks (FI task related to your wifi connection that are happening in the background) Normally at the end of loop() a yield() is executed automatically, delay() also executes a yield() (delayMicroseconds() does not ! ) I haven't checked you code, you should post it here (within </> code-tags ), not somewhere else if you want it looked at.

I can't find a way.. I downloaded the ESP-IDF with my mobile network now, I had to walk like 2km to get a signal..

ONLY to realize that the installation fails and hangs up while "setting up an exclusion on Windows Defender".

I'm googling and googling. Nothing works.
yield() doesn't do a shit. I've put it EVERYWHERE in my code.

I still don't understand what yield actually does.. and where I should put it. Before my delay's?
I can not use delay more than 2.5 seconds in my script ?? that's stupid...

delay() includes yield(), so you can put delay as long as you like, you should put yield(); where you don't want delay() but do have a long long loop (or code that takes a long time) like waiting for user input. You can post your long code either as attachment or in 2 or 3 posts.

It is possible to disable the watchdog in your code:

#include "soc/rtc_wdt.h"
...
rtc_wdt_protect_off();
rtc_wdt_disable();

I don't know if it works. I have found another way that worked for me but cannot find it again...

EDIT: It was the brownout detector. This disables the brownout detector of the ESP32 which may be also
helpful for you.

#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

void setup(){
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
...
}
1 Like