My ESP32 based logger is showing problems displaying results on a web page, or connecting via FTP.
After reading this topic
I suspect the wifi is not being handled correctly, and the WiFI stack is getting corrupted.
Following a reset it works fine often for several weeks., then I get "The server at 192.168.1.34 is taking too long to respond."
//wifi handling
// event handlers from https://techtutorialsx.com/2019/09/22/esp32-soft-ap-station-disconnected-event/
void initWiFi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("initWiFi: Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
//Serial.println(WiFi.localIP());
}
...
void WiFiStationConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
Serial.println("Connected to AP successfully!");
WiFiState = 1;
digitalWrite(LED_WiFi, WiFiState); //indicate wifi connected - BLUE LED
}
void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
Serial.println("WiFi connected - hostname & IP address: ");
Serial.print(WiFi.getHostname());
Serial.println(WiFi.localIP());
}
void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
Serial.println("Disconnected from WiFi access point");
Serial.print("WiFi lost connection. Reason: ");
Serial.println(info.disconnected.reason);
Serial.println("Trying to Reconnect");
WiFiState = 0;
digitalWrite(LED_WiFi, WiFiState); //indicate wifi not connected - BLUE LED
WiFi.begin(ssid, password);
}
If I'm right the sketch needs a WiFi.disconnect(true); - to reset the stack; should I include that in the WiFiStationDisconnected() routine?
Also the program does housekeeping daily at midnight - should I also call the WiFiStationDisconnected() routine at that time?
Hi Larry, yes I assign fixed IP addresses to the MAC addresses in my router as I've foiund setting fixed addresses in the arduino code isnt always successful.
This does use the ESP-WROOM-32 (- the ESP8266FTP library works with both.)
Its early days as yet, but so far the web page connects instantly and the response to FTP is much better. I'll update again in a few weeks, especially if problems recur.