我是arduino的新手。我的目标是制造一些基于esp01 dht11等的家庭自动化设备。
我写了一些草图并将其成功上传到板上。它可以正常工作,它们可以连接到WiFi和MQQT服务器。一段时间后,我根据工作草图编写了另一部分。而且有一个问题。我所有的ESP都不再连接到路由器。串行连接的波特率永远不会从74880升至115200。
#include <ESP8266WiFi.h>
#define STASSID "oooo_"
#define STAPSK "examplepasss"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "djxmmx.net";
const uint16_t port = 17;
void setup() {
Serial.begin(115200);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
would try to act as both a client and an access-point and could cause
network-issues with your other WiFi-devices on your WiFi-network. */
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
上传后显示的错误
no oooo_ found, reconnect after 1s
wifi evt: 1
STA disconnect: 201
.reconnect
.....scandone
我尝试使用arduino菜单中的示例。我尝试了两个路由器,更改了wifi通道,密码,上传了可工作的二进制文件并连接到wifi。怎么了?在WIFI_STA模式下建立wifi连接的正确方法是什么?谢谢。