i have a Wemos D1 mini with ESP8266 on it and can connect to my wifi with the following code:
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <string>
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
const char* SSID = "MYSSID";
const char* PSK = "MYPSK";
WiFiClientSecure espClient; /* Secure client connection class, as opposed to WiFiClient */
PublicKey key(pubkey);
void setup_wifi() {
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PSK);
Serial.println("Try to connect to wifi ");
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
Serial.println(WiFi.localIP());
espClient.setX509Time(timeClient.getEpochTime());
Serial.write(timeClient.getEpochTime());
}
void setup() {
// Serial Monitor
Serial.begin(115200);
// STATUS LED
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
// WIFI
setup_wifi();
}
void loop()
{
}
So far, everything is fine, it connects as expected and it. But when i turn off the power supply of the ESP and restart it a few hours (or a day) later then the only solution to get an wifi connection again is to go to my routers settings and change the wifi channel from 11 to 10 or something else below 11. After that channel change the ESP is properly connecting to wifi again. Without changing the wifi channel, there will no wifi connection be established.
Is this a known issue or can someone help me out?
Thanks and best regards from germany.