一、代码讲解
第2行:包含ESP8266 WIFI库头文件
第4行:设置WIFI热点名称
第5行:设置WIFI热点密码
第15行:设置WIFI模式为接入点(热点)模式
第17行:开始启动WIFI热点
第19行:WIFI热点创建成功,打印相关信息
二、参考代码
#include <Arduino.h>
#include <ESP8266WiFi.h>
#define WIFI_AP_SSID "ESP8266"
#define WIFI_AP_PASS "00000000"
void setup() {
// put your setup code here, to run once:
// 设置波特率
Serial.begin(9600);
Serial.println("");
// 设置接入点模式
WiFi.mode(WIFI_AP);
// 配置接入点名称和密码
WiFi.softAP(WIFI_AP_SSID, WIFI_AP_PASS);
// 打印接入点信息
Serial.println("WIFI接入点创建成功");
Serial.println("WIFI接入点名称: " + WiFi.SSID());
Serial.println("IP地址: " + WiFi.softAPIP().toString());
}
void loop() {
// put your main code here, to run repeatedly:
}