Skip to content

ESP8266 lags every 10-15min for a moment - evt: 7 error #7808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ShineHunter opened this issue Jan 4, 2021 · 4 comments
Open

ESP8266 lags every 10-15min for a moment - evt: 7 error #7808

ShineHunter opened this issue Jan 4, 2021 · 4 comments

Comments

@ShineHunter
Copy link

ShineHunter commented Jan 4, 2021

Platform

  • Hardware: [ESP-12|
  • Core Version: [latest git date]
  • Development Env: [Arduino IDE|
  • Operating System: [Windows|

Settings in IDE

  • Module: |Nodemcu|
  • Flash Mode: [qio|
  • Flash Size: [4MB]
  • lwip Variant: |v2 Lower Memory|
  • Reset Method: [ck]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200]

Problem Description

Every10-15 time the ESP stops answering to my smartphone. Debugging on Android says "connection refused". Then, after 1-2min it starts spamming connection info to the serial port and answering to phone and after maybe 10s works normally. I am also getting wifi evt: 7 - WIFI_EVENT_SOFTAPMODE_PROBEREQRECVED on serial port.
According to #2735 - it's a "[AP]err on recieved request"

... New data every 300ms ... evt: 7 ... Then updates very fast (every 50ms, not 300) for a moment.

The ESP is in AP mode.

Newest libraries.

MCVE Sketch

#include <ESP8266WiFi.h>
//#include <Ticker.h>
//#include <Wire.h>
//#include "PCF8574.h"
//#include <ESP8266WiFiGratuitous.h>


const char* ssid = "testwifi2";
const char* password = "esp8266";
IPAddress ip(192,168,0,1);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);


WiFiServer server(80);
//Ticker timer;

const byte interruptPin = 13;
int czas2 = 0;
int czas = 0;
int a=1;
boolean auto_manual = 0;
unsigned long currentTime=0;
unsigned long previousTime=0;
const long Timeout=200;

//PCF8574 PCF_01(0x20);


void setup()
{
  delay(10);
  //pinMode(interruptPin, INPUT_PULLUP);
  //attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING);
  
  Serial.begin(115200);
  Serial.println();
  //PCF_01.begin();

  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid, password,10,true,1);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  server.begin();
  //experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();
  

  //timer.attach_ms(1,zegar);
}

// prepare a web page to be send to a client (web browser)
String prepareAnswer()
{
  String htmlPage;
  htmlPage.reserve(1024);               // prevent ram fragmentation
  htmlPage = F("HTTP/1.1 200 OK\r\n"
               "Content-Type: text/html\r\n"
               "Connection: close\r\n"  // the connection will be closed after completion of the response
               "\r\n"
               "<!DOCTYPE HTML>"
               "<html>");
  htmlPage += F("@"
              "300"
              "#" 
              "200"
              "$");
  htmlPage += F("</html>"
                "\r\n");
  return htmlPage;
}



void loop()
{
  WiFiClient client = server.available();
  // wait for a client (web browser) to connect
  if (client)
  {
    Serial.println("\n[Client connected]");
    while (client.connected())
    {
      yield();
      // read line by line what the client (web browser) is requesting
      if (client.available())
      {
        String line = client.readStringUntil('\r');
        Serial.print(line);
        // wait for end of client's request, that is marked with an empty line
        if (line.length() == 1 && line[0] == '\n')
        {
          client.println(prepareAnswer());
          break;
        }
      }
      
    }

    while (client.available()) {
      
      // but first, let client finish its request
      // that's diplomatic compliance to protocols
      // (and otherwise some clients may complain, like curl)
      // (that is an example, prefer using a proper webserver library)
      client.read();
      yield();
    }

    // close the connection:
    client.stop();
    Serial.println("[Client disconnected]");
  }
}
 

Debug Messages

[Client]
19:48:09.950 -> 0 HTTP/1.1
19:48:09.950 -> [Client disconnected]

19:48:58.765 wifi evt: 7 
19:49:00.627 wifi evt: 7 
19:49:00.627 wifi evt: 7 
19:49:12.179 wifi evt: 7

19:49:13.470 -> [Client]
19:49:13.470 -> 0 HTTP/1.1
19:49:13.470 -> [Client disconnected]

All program now. I have changed it, but still the same problem. I know only, that wifi ext 7 isnt connected with this lag.

@svdrummer
Copy link

As there is only part of the program here, it is hard to simulate.
A lot of problems show in the INCLUDE section and global setups.
It is hard to simulate your problem

@d-a-v
Copy link
Collaborator

d-a-v commented Jan 30, 2021

@ShineHunter please enable debug mode, and show the serial output when your issue occurs.
Also try to add WiFi.setSleepMode(WIFI_NONE_SLEEP);.

@TD-er
Copy link
Contributor

TD-er commented Feb 19, 2021

@ShineHunter please enable debug mode, and show the serial output when your issue occurs.
Also try to add WiFi.setSleepMode(WIFI_NONE_SLEEP);.

Should that make any difference?
The ESP is in AP mode according to the issue starter.

@ShineHunter
Copy link
Author

No, I tried this, but it isn't make any difference. But... I solved this problem by changed http request to standard TCP protocole.

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

No branches or pull requests

4 participants