Page 1 of 1

Realistic for webserver to run on ESP32 24x7?

Posted: Sat Apr 02, 2022 11:11 pm
by CoffeeBeans
I am running web server (ESPAsyncWebServer) for a coffee machine application on an ESP32 that I would like to run 24x7.

What I'm finding at present is that it runs for a few days and then the web server stops receiving requests, and I have to push the reset button on the chip. I have looked at all of my string handling and am using .reserve(BUFFER_SIZE) to try to avoid fragmentation.

Is it just unrealistic to hope that my code can run continuously on a device like this? Are there any housekeeping routines I could add to help? I would prefer not to load my whole code because it contains a lot of other files for scales, thermocouples, PIDs, pressure sensors, etc.

One options which I have considered is a hard reset via the RTS pin say at 3 AM every morning. This seems like a sledgehammer approach, but would have the advantage of simpilicity.

Any help would be appreciated

Re: Realistic for webserver to run on ESP32 24x7?

Posted: Mon Apr 04, 2022 5:26 pm
by lbernstone
I have ESP32 based devices that run months between reboots.
If you think it is a memory problem, then track down the leak. If you already have a web server set up, then it shouldn't be a big effort to add a handler that returns the available memory (ESP.getFreeHeap()) and then poll that from a PC and log it. If you see it continuously trending downwards, that's bad. Isolate which routines are not returning memory, and then we can help you figure out why.
Note that passing String variables between functions can consume far more memory than needed. Use pointers to pass variables, not the actual data.

Re: Realistic for webserver to run on ESP32 24x7?

Posted: Thu Apr 07, 2022 5:22 am
by CoffeeBeans
Thanks for that. I will definitely try watching the memory usage and seeing if it goes down, and look to pointers instead of strings. I have done some further reading on other people having similar issues of the web server not responding and it seems there may be a timeout I can use to drop connections which may help things as well.

Re: Realistic for webserver to run on ESP32 24x7?

Posted: Thu Apr 07, 2022 1:59 pm
by alanesq
Hi,

I have had similar issues in the past and it was resolved by including the command: WiFi.setSleep(false);
may be worth trying?

Re: Realistic for webserver to run on ESP32 24x7?

Posted: Thu Apr 07, 2022 9:39 pm
by CoffeeBeans
I will definitely give that a try. I'm not running on batteries, so power usage is a lesser issue.