下面的代码很简单:使用esp8266 的 nodemcu 建立一个wifi AP,并且在loop函数中使用analogRead 从A0读取值
下面的代码其实看起来确实没有问题,也能编译通过,实际运行起来好像也不报错。
但是,你是找不到“I am Wifi” 这个SSID的,建议你先试试下面这段代码。
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>
#define led 2
ESP8266HTTPUpdateServer httpUpdater;
ESP8266WebServer WifiServer(80);
bool isDisplayFromCell = false;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAP("I am Wifi", "3.1415926"); //设立softAP
Serial.println("Soft ap is start.");
delay(200);
Serial.print("IP Address:");
Serial.println(WiFi.softAPIP());
WiFi.printDiag(Serial);
httpUpdater.setup(&WifiServer);
WifiServer.onNotFound([]() {
WifiServer.send(404, "text/html", "File not found");
});
WifiServer.begin();
Serial.println("Wifi Server is started..");
}
int light = 0;
void loop() {
/

博客讲述了作者在使用ESP8266的nodemcu创建WiFi AP并读取A0引脚模拟值时遇到的问题。当调用analogRead函数时,WiFi AP的SSID无法显示。通过实验发现,延迟函数delay的加入或注释掉analogRead可以解决这个问题。作者虽然找到了解决方案,但对具体原因仍不清楚。
最低0.47元/天 解锁文章
3945

被折叠的 条评论
为什么被折叠?



