完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我是 ESP8266 的新手,我试图从这个网站运行我的第一个程序:我安装了所有库,连接了 ESP8266 并安装了驱动程序。我得到这个错误:Arduino:1.8.16 (Windows 10), Płytka:"Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (平衡),对 IRAM/PROGMEM 使用 pgm_read 宏,dtr(aka nodemcu),26 MHz,40MHz,DOUT(兼容),1MB(FS:64KB OTA:~470KB),2,nonos-sdk 2.2.1 + 100( 190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
在包含的文件中 c:\users\marcin\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\assert .h:10, 来自 c:\users\marcin\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include \sys\reent.h:503, 来自 c:\users\marcin\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106 -elf\include\stdlib.h:18, 来自 c:\users\marcin\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa -lx106-elf\include\c++\10.3.0\cstdlib:75, 来自 c:\users\marcin\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3。 0\stdlib.h:36, 来自 C:\Users\Marcin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:27,来自 sketch\ 8266kod_v1.ino .cpp:1: C:\Users\Marcin\Documents\Arduino\libraries\WhareHauoraWiFiManager/WiFiManager.h:25:24: error: 'const char HTTP_HEAD []' 重新声明为不同类型的实体 25 | const char HTTP_HEAD[] PROGMEM = "{v}"; | ^~~~~~~ 在 C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino:5 中包含的文件中: C:\Users\Marcin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\ src/ESP8266WebServer.h:47:39: 注意:之前的声明 'HTTPMethod HTTP_HEAD' 47 | 枚举 HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS }; | ^~~~~~~~~ C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino: 在函数 'void callback(char*, byte*, unsigned int)': 8266kod_v1:11:13: error: ' D2' 未在此范围内声明 11 | #define LED D2 | ^~ C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino:40:20: 注意:在宏扩展中 ' 40 | 数字写入(LED,高); | ^~~ 8266kod_v1:11:13: 错误:'D2' 未在此范围内声明 11 | #define LED D2 | ^~ C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino:44:20: 注意:在宏“LED” 44 的扩展中 | 数字写入(LED,低); | ^~~ C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino: In function 'void setup()': 8266kod_v1:11:13: error: 'D2' 未在此范围内声明 11 | #define LED D2 | ^~ C:\Users\Marcin\Desktop\8266kod_v1\8266kod_v1.ino:57:11:注意:在宏“LED” 57 的扩展中 | 引脚模式(LED,输出); | ^~~ exit status 1 'D2' was not declared in this scope Ten raport powinien zawierać więcej informacji jeśli w File -> Preferencje zostanie włączona opcja "Pokaż szczegółowe informacje podczas kompilacji" 代码:全选#include //https://github.com/esp8266/Arduino //needed for library #include #include #include //https://github.com/tzapu/WiFiManager #include #include #define DHTPIN 5 // Digital pin connected to the DHT sensor #define LED D2 // Uncomment the type of sensor in use: #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); unsigned long previousMillis = 0; unsigned long interval = 10000; const char* mqttServer = "192.168.0.81"; const int mqttPort = 1883; void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived in topic: "); Serial.println(topic); Serial.print("Message:"); Serial.println(); String message = ""; for (int i = 0; i < length; i++) { Serial.print((char)payload); message+=(char)payload; } Serial.println("-----------------------"); if(String(topic)=="LED"){ if(message=="LED ON"){ digitalWrite(LED,HIGH); Serial.println("LED IS ON"); } else{ digitalWrite(LED,LOW); } } } WiFiClient espClient; PubSubClient client(mqttServer, mqttPort, callback, espClient); void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(LED,OUTPUT); digitalWrite(LED,LOW); //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around WiFiManager wifiManager; //reset saved settings // wifiManager.resetSettings(); //set custom ip for portal //wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); //fetches ssid and pass from eeprom and tries to connect //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" //and goes into a blocking loop awaiting configuration wifiManager.autoConnect("AutoConnectAP"); //or use this for auto generated name ESP + ChipID //wifiManager.autoConnect(); //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); dht.begin(); client.setServer(mqttServer, mqttPort); client.setCallback(callback); while (!client.connected()) { Serial.println("Connecting to MQTT..."); if (client.connect("ESP8266Client" )) { client.subscribe("LED"); Serial.println("connected"); } else { Serial.print("failed with state "); Serial.print(client.state()); delay(2000); } } } void loop() { client.loop(); unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) { // save the last time you updated the DHT values previousMillis = currentMillis; float t = dht.readTemperature(); float h = dht.readHumidity(); if(!isnan(h)&&!isnan(t)){ Serial.println("Temperature : " +String(t)); Serial.println("Humidity : " +String(h)); String toSend = String(t) + "," +String(h); client.publish("data",toSend.c_str()); } } } 是什么导致了这个问题?我该如何修复它? |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
524浏览 6评论
433浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
422浏览 5评论
414浏览 4评论
387浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-3 00:23 , Processed in 0.760279 second(s), Total 73, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号