Realistic for webserver to run on ESP32 24x7?

CoffeeBeans
Posts: 5
Joined: Thu Feb 17, 2022 3:18 am

Realistic for webserver to run on ESP32 24x7?

Postby CoffeeBeans » Sat Apr 02, 2022 11:11 pm

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

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Mon Apr 04, 2022 5:26 pm

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.

CoffeeBeans
Posts: 5
Joined: Thu Feb 17, 2022 3:18 am

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

Postby CoffeeBeans » Thu Apr 07, 2022 5:22 am

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.

alanesq
Posts: 86
Joined: Thu Dec 14, 2017 8:38 pm

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

Postby alanesq » Thu Apr 07, 2022 1:59 pm

Hi,

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

CoffeeBeans
Posts: 5
Joined: Thu Feb 17, 2022 3:18 am

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

Postby CoffeeBeans » Thu Apr 07, 2022 9:39 pm

I will definitely give that a try. I'm not running on batteries, so power usage is a lesser issue.

Who is online

Users browsing this forum: No registered users and 23 guests