8000 Esp8266 Wifi connection often disconnects (bcn_timout) · Issue #5083 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content
Esp8266 Wifi connection often disconnects (bcn_timout) #5083
Closed
@stefanodelbosco

Description

@stefanodelbosco

Platform

  • Hardware: NodeMCU 1.0 (ESP12E-Module)
  • Core Version: latest git 2.4.2 && 2.2.1
  • Development Env: Arduino IDE (last git) && Platformio 2.2.1
  • Operating System: Ubuntu

Settings in IDE

  • Module: Nodemcu
  • Flash Size: 4MB
  • CPU Frequency: 80Mhz
  • Upload Using: OTA && SERIAL
  • Upload Speed: [115200 (Serial)]

Problem Description

I looked for a solution between the various issues but none worked right now.
I have updated sdk to the latest version with git
The connection to the WiFi remains active for a time ranging from 30 seconds to 6 hours.
The module disconnects and reconnects by the connectDeviceToWiFi () function.

I tried to lower the time beecon in the router. Now it's every 30 ms (default 100ms).

I've been trying for three days to find a solution but the situation is not changing.
I tried with two different modules near the router and both give problems.

The RSSI signal is always between -70 and -78. I did a -68 signal tests but the problem persists.

I hope someone can help me.

MCVE Sketch

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266CustomTools.h>
#include "ota.h"
#include <ArduinoOTA.h>

ESP8266WebServer server(80);
ESP8266CustomTools device("SensorTest", D7, "sensor");

String IP_SERVER = "192.168.1.5";


void setup() {
  Serial.begin(9600);
  pinMode(D7, INPUT);
  device.connectDeviceToWiFi();
  device.syncCurrentTimestamp();
  device.generateOTPSecret();
  server.on("/info", handleInfo);
  server.begin();
  Serial.println(ESP.getCoreVersion());
  Serial.println(ESP.getSdkVersion());

  ota_setup("Esp8266", "PASSWORD");
}

void loop() {
    server.handleClient();
    //Check if connection is alive
    device.connectDeviceToWiFi();
    //Update IP/MAC
    device.checkAndUpdateConnectionInfo();
    if(digitalRead(D7) == 0){
      Serial.println("Change state");
    }
    device.checkAndUpdateTimestampOTP();
    //OTA Check
    ArduinoOTA.handle();
    delay(10);
}

ESP8266CustomTools::connectDeviceToWiFi()

void ESP8266CustomTools::connectDeviceToWiFi(){
  while(WiFi.status() != WL_CONNECTED){
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(200);
    WiFi.begin(ssid, password);
    long timewait = 0;
    long timeout = 10000;
    while(WiFi.status() != WL_CONNECTED && timewait < timeout){
       delay(1000);
       timewait = timewait + 1000;
    }
    if(WiFi.status() == WL_CONNECTED){
      String IP = WiFi.localIP().toString();
      String MACADDRESS = WiFi.macAddress();
      MACADDRESS.toLowerCase();
      Serial.println(IP);
      HTTPClient http;
      http.begin("http://" + IP_SERVER + "/api/device/connected_wifi_device?ip=" + IP + "&mac=" + MACADDRESS + "&type=" + TYPE);
      int httpCode = http.GET();
      String payload = http.getString();
      if(httpCode == 200){
        Serial.println("Message sent");
        last_server_update = millis();
      }
      http.end();
    }
  }
}

Debug Messages

SDK:2.2.1(cfd48f3)/Core:2.4.2/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:6d1cefc
scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt 

connected with dlink-XXXX, channel 10
dhcp client start...
ip:192.168.1.4,mask:255.255.255.0,gw:192.168.1.1
192.168.1.4
    SyncIpServer httpCode: 200
    SyncTimestamp httpCode: 200
    SyncOTP httpCode: 200
    COREVersion: 2_4_2
    SDKVerison: 2.2.1(cfd48f3)

bcn_timout,ap_probe_send_start
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt 

connected with dlink-XXXX, channel 10
dhcp client start...
ip:192.168.1.4,mask:255.255.255.0,gw:192.168.1.1
192.168.1.4
....

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0