esp8266 / esp8266/Arduino

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

Open
#7,808 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

#### 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 https://github.com/esp8266/Arduino/issues/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](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include
//#include
//#include
//#include "PCF8574.h"
//#include

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"
""
"");
htmlPage += F("@"
"300"
"#"
"200"
"$");
htmlPage += F(""
"\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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.