How to use AP_STADISCONNECTED to reset ESP

ESP32

after I get this 2 massage:
22:52:38.302 -> [212495][V][WiFiGeneric.cpp:412] _arduino_event_cb(): AP Station Disconnected: MAC: 00:45:e2:9c:a3:d1, AID: 1
22:52:38.349 -> [212495][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 13 - AP_STADISCONNECTED
my program was stuck and I have to press the reset button to Run normally, how to use that event to trigger reset ESP?

thankyou

I’ve been trying to solve this for ages.

Can you post the code and hardware setup that gives a masssage.

#include "WiFi.h"
#include "ESPAsyncWebServer.h"

/* Put your SSID & Password */
const char* ssid = "ESP32";  // Enter SSID here
const char* password = "12345678";  //Enter Password here

/* Put IP Address details */
IPAddress local_ip(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

AsyncWebServer server(80);

void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/plain", "Not found");
}

String processor(const String& var) {}

void setup() {
  // Serial port for debugging purposes
  Serial.begin(115200);



  // Initialize SPIFFS
  if (!SPIFFS.begin(true)) {
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }

  // Starting Wi-Fi
  WiFi.softAP(ssid, password);
  WiFi.softAPConfig(local_ip, gateway, subnet);
  Serial.println("");
  Serial.println("WiFi Started");

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/web.html", String(), false, processor);
  });

  server.onNotFound(notFound);

  // Start server
  server.begin();
  Serial.println("HTTP server started");

}

void loop() {

}

have you try, if _eventCallback(): == AP_STADISCONNECTED then reset esp?

how to lisent to _eventCallback() ?
Screenshot (36)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.