我正在尝试将Wemos D1 R2连接到我家中的wifi。它会连接并仅显示板的MAC地址,但在路由器上已连接设备的列表中没有显示IP。串行监视器除了点外也不会打印任何东西。
我希望串行监视器可以打印我的IP地址,而Wemos可以保持与互联网的连接
#include <ESP8266WiFi.h>
const char *ssid = "SSID";
const char *password = "Pass";
void setup() {
Serial.begin(115200);
delay(3000);
Serial.print("Connecting to ");
Serial.println(ssid);
Serial.println(password);
// ---------------This was the magic WiFi reconnect fix for me
WiFi.persistent(false);
WiFi.mode(WIFI_OFF); // this is a temporary line, to be removed after SDK
// update to 1.5.4
WiFi.mode(WIFI_STA);
// ---------------END - WiFi reconnect fix
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
Serial.println(WiFi.localIP());
}
void loop() {
}