C++
#include "ESP8266WiFi.h"
const char* ssid = "xxxx";
const char* password = "xxxxx";
void setup() {
// initialize serial and wait for the port to open:
Serial.begin(115200);
Serial.println("connecting to ");
Serial.println(ssid);
// attempt to connect using WEP encryption:
WiFi.persistent(false); // solution found on a forum but does not work
WiFi.setAutoReconnect(true); // solution found on a forum but does not work
WiFi.mode(WIFI_OFF); // solution found on a forum but does not work
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
///network search
Serial.println("network search ");
int n = WiFi.scanNetworks();
Serial.println("start done ...");
if (n == 0) {
Serial.println("no network found ...");
} else {
Serial.print(n);
Serial.println("network found");
for (int i = 0; i < n; i++) {
Serial.print(i + 1);
Serial.println(":");
Serial.print(WiFi.SSID(i));
Serial.println(" (");
Serial.print(WiFi.RSSI(i));
Serial.println(")");
if (WiFi.encryptionType(i) == ENC_TYPE_NONE) {
Serial.println(" ");
} else {
Serial.println("*");
}
}
}
/// end of network search
}
Serial.println("");
Serial.println("WIFI connected ");
Serial.println("Local IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
}