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
Realistic for webserver to run on ESP32 24x7?
-
- Posts: 5
- Joined: Thu Feb 17, 2022 3:18 am
-
- Posts: 826
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Realistic for webserver to run on ESP32 24x7?
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.
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.
-
- Posts: 5
- Joined: Thu Feb 17, 2022 3:18 am
Re: Realistic for webserver to run on ESP32 24x7?
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?
Hi,
I have had similar issues in the past and it was resolved by including the command: WiFi.setSleep(false);
may be worth trying?
I have had similar issues in the past and it was resolved by including the command: WiFi.setSleep(false);
may be worth trying?
-
- Posts: 5
- Joined: Thu Feb 17, 2022 3:18 am
Re: Realistic for webserver to run on ESP32 24x7?
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 51 guests