Juraj:
your RF settings on the esp8266 flash are lost or wrong. it can happen if you erase the flash or if you upload a sketch or firmware build with different version of Espressif SDK
What RF settings?
To troubleshoot this, I downloaded the IDE to a laptop that never had the Arduino IDE installed. I installed the ESP8266 boards and ran WiFiscan.ino from the ESP8266WiFi Examples in the IDE. The scan finds my AP: "Kaywinnet (-58)". Next, I ran my WiFi_Test.ino that just connects to the WiFi. Instead of printing dots while waiting for the WiFi.status() to connect, I print WiFi.status(). Here I see a few "6 WL_DISCONNECTED" followed by "1 WL_NO_SSID_AVAIL" forever.
Here is my test sketch:
#include <ESP8266WiFi.h> // Include the Wi-Fi library
char ssid[] = "Kaywinnet";
const char* password = "806194xxxx"; // The password of the Wi-Fi network
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
WiFi.disconnect();
delay(100);
//Serial.setDebugOutput(true); // Watch the connection attempts
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(WiFi.status()); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
Serial.println();
WiFi.printDiag(Serial);
Serial.println();
}
void loop() { }