Random STA_DISCONNECTED

Espe21
Posts: 8
Joined: Sat May 19, 2018 6:38 am

Random STA_DISCONNECTED

Postby Espe21 » Thu Feb 10, 2022 11:52 am

I am using an ESP32 Chip model = ESP32-D0WDQ6 Rev 1
i want to use the esp32 for wled https://github.com/atuline/WLED
All works fine but one problem occurs.
when wled is running it sometimes happens that i can't connect to the esp32 ip adress.
no matter whether from the pc or from the smartphone. or from the android wled app.
i must reset the esp32. then all works finde until the next hanging.

For testing I used the HelloServer example available in the arduino ide.

Code: Select all

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>

const char* ssid = "myssid";
const char* password = "mypassword";

WebServer server(80);

const int led = 2;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp32!");
  digitalWrite(led, 0);
}

void handleNotFound() {
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }
This program also loses the connection to the esp32.
often this happens after 7-10 minutes. But sometimes later.
and sometimes not at all.
a colleague tested the program on his esp32 and it worked continuously there.

sometimes i get the following messages from the debug log:

Code: Select all

20:07:32.888 -> [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 5 - STA_DISCONNECTED
20:07:32.941 -> [W][WiFiGeneric.cpp:391] _eventCallback(): Reason: 6 - NOT_AUTHED
20:09:32.905 -> [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 8 - STA_LOST_IP
but not always.
I do not know if this also occurs with wled
i use a good power supply or a good and short usb cable. I connected an electrolytic capacitor parallel to the power supply.
I also programmed a blinking led into the HelloServer code. if the connection is disconnected, the led continues to flash. So the esp32 is not hanging.

I have used many esp modules ESP01, ESP12, Wemos D1, but i never had this problem.

I don't know what to do with this problem. maybe someone can help me here.

Who is online

Users browsing this forum: No registered users and 127 guests