Arduino与NodeMCU——联网

我们现在要使用Arduino IDE来配置您的ESP8266芯片。这是使用该芯片的好方法,因为您可以使用着名的Arduino IDE对其进行编程,并重复使用几个现有的Arduino库。
如果尚未完成,请安装最新版本的Arduino IDE。您可以从http://www.arduino.cc/en/main/software获取它。
现在,您需要执行以下步骤才能使用Arduino IDE配置ESP8266:
1.启动Arduino IDE并打开“首选项”窗口。
2.在其他Board Manager URL中输入以下URL:http://arduino.esp8266.com/stable/package_esp8266com_index.json
3.从Tools |中打开Boards Manager Board菜单并安装esp8266平台,如下所示:

将模块连接到Wi-Fi网络
现在,我们将检查ESP8266和Arduino IDE是否正常工作,并将芯片连接到本地Wi-Fi网络。
为此,让我们执行以下步骤:
1.首先,我们需要编写代码然后将其上传到电路板。 代码很简单; 我们只想连接到本地Wi-Fi网络并打印电路板的IP地址。这是连接到网络的代码:

#include <ESP8266WiFi.h>
void setup() {
// put your setup code here, to run once:
const char* ssid = "203";
const char* password = "203forever";
// Start Serial
Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP(http://www.my516.com));
}
void loop() {
// put your main code here, to run repeatedly:

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

1

---------------------

posted on 2019-06-28 15:08  激流勇进1  阅读(2216)  评论(0编辑  收藏  举报