Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ESP32 webserver not reachable after random number of days #6900

basementmedia2 started this conversation in General
Discussion options

Hi,

i have the following Problem

I run an ESP32 in WIFI_STA_AP mode.
After a few days (sometimes 5, sometimes 6) the webserver is not responding anymore.
The ESP is still listed in the WIFI-Network but i can't connect.

Is this a known issue?
By the way: Do i have to set

esp_wifi_set_ps(WIFI_PS_NONE);

or is this set by default?

Goal is, that the webserver is always and always reachable.

Here is a snipped (short part) of my actual code:

#include <WiFi.h>
#include <WiFiAP.h>
#include <WebServer.h>
WebServer server(80);
#include <ESPmDNS.h>
unsigned long connTimer=0;
unsigned long dauer = 5000;
const char ssid[10] = "MySSID";
const char password[7] = "MyPW";
const char apssid[12] = "MyAPSSID";
const char appassword[15] = "MyAPPasswort";
const char host[9] = "myhost";
const char indexPage[] PROGMEM = R"=====(
 <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
 <meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="Expires" content="0">
 </head>
 <body>
 Hello World
 </body>
 </html>
)=====";
void setup() {
 Serial.begin(115200);
 xTaskCreatePinnedToCore(
 keepWiFiAlive,
 "Keep Wifi Alive",
 5000,
 NULL,
 2,
 NULL,
 CONFIG_ARDUINO_RUNNING_CORE
 ); 
 
 WiFi.mode(WIFI_AP_STA);
 WiFi.disconnect();
 WiFi.begin(ssid, password);
 
 connTimer = millis();
 while (WiFi.status() != WL_CONNECTED && (millis() - connTimer < dauer)) {
 Serial.print(".");
 delay(500);
 }
 if (WiFi.status() == WL_CONNECTED) {
 Serial.println("Connected...");
 MDNS.begin(host);
 } else {
 Serial.println("Not connected");
 }
 
 WiFi.softAP(apssid, appassword);
 
 server.on("/", display_root);
 server.begin();
 
 MDNS.addService("http", "tcp", 80);
}
void loop() {
 server.handleClient();
}
void display_root() {
 const char * httpType PROGMEM = "text/html";
 server.send_P(200, httpType, indexPage);
}
void keepWiFiAlive(void * parameters) {
 for (;;) {
 
 if (WiFi.status() == WL_CONNECTED) {
 Serial.println("Still connected!");
 vTaskDelay(10000 / portTICK_PERIOD_MS);
 continue;
 }
 // Not connected --> New connection attempt
 WiFi.begin(ssid, password);
 unsigned long startAttemptTime=millis();
 while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 5000) {
 
 }
 
 if (WiFi.status() != WL_CONNECTED) {
 Serial.println("Not connected...!");
 continue;
 } else {
 MDNS.begin(host); 
 continue;
 }
 
 }
}

I actually use core 1.0.6 cause with 2.0.3 i hav other problems (related to SD library).

Thank you for support.

Best wishes

Daniel

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /