英文:
ESP8266 watchdog reset when using WiFi
问题
我正在尝试在基于ESP8266EX的板子(XTVTX WEMOS D1 Mini Pro)上使用WiFi。
这个示例非常简单。
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
WiFi.begin("<ssid>", "<password>");
}
void loop() {
if (WiFi.status() == WL_CONNECTED)
{
Serial.println("Connected");
}
else
{
Serial.println("Not Connected");
}
yield();
}
该板子一直因为看门狗复位(来源:https://arduino-esp8266.readthedocs.io/en/latest/boards.html#rst-cause)而重新启动。
几秒钟后,会引发一个致命异常(28 = LoadProhibitedCause - 来源:https://arduino-esp8266.readthedocs.io/en/latest/exception_causes.html#exception-causes-exccause)。
以下是显示问题的日志。
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00044b80
~ld
sp 0x3fffe9d0
epc1=0x40204d1a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x04000102, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
致命异常 (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
[...]
我的设置:
- 电源: USB 3.0供电集线器(5V 500mA)
- IDE: Linux上的Arduino IDE v2.0.4
- 库: 来自ESP8266 Community的esp8266 v3.1.1库(也尝试过3.1.0和3.0.2)
- 程序设置:
- 板子: 通用ESP8266模块
- 上传速度: 115200
- 晶振频率: 26MHz
- 闪存大小: 4MB(FS:无 OTA:1MB)
- CPU频率: 80MHz
- MMU: 32KB缓存 + 32 KB IRAM
- lwip变种: v2较低内存
- NONOS SDK: nonos-sdk 2.2.1+100
- 擦除闪存: 所有闪存内容
- 闪存频率: 40MHz
除了涉及WiFi的其他示例都可以正常工作。
这个示例在非常相似的AzDelivery ESP8266MOD 12-F板上运行正常。
这块板子是新的,我看到WiFi在进入启动循环之前运行了几秒钟。
有些人遇到相同的问题,因为他们使用了#include <WiFi.h>
而不是#include <ESP8266WiFi.h>
,但这不是我的情况。
我不明白问题出在哪里。有人之前遇到过这个问题并找到解决方案吗?
谢谢你的时间。
英文:
I'm trying to use WiFi on a ESP8266EX based board (XTVTX WEMOS D1 Mini Pro).
The sketch is really simple.
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
WiFi.begin("<ssid>", "<password>");
}
void loop() {
if ( WiFi.status() == WL_CONNECTED)
{
Serial.println("Connected");
}
else
{
Serial.println("Not Connected");
}
yield();
}
The board keeps rebooting for a watchdog reset (source: https://arduino-esp8266.readthedocs.io/en/latest/boards.html#rst-cause).
After a few seconds a fatal exception is raised (28 = LoadProhibitedCause - source: https://arduino-esp8266.readthedocs.io/en/latest/exception_causes.html#exception-causes-exccause).
Here it is the log that shows the issue.
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00044b80
~ld
sp 0x3fffe9d0
epc1=0x40204d1a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x04000102, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
[...]
My setup:
- Power: USB 3.0 powered hub (5V 500mA)
- IDE: Arduino IDE v2.0.4 on Linux
- Library: esp8266 from ESP8266 Community v3.1.1 (tried also 3.1.0 and 3.0.2)
- Programmer settings:
- Board: Generic ESP8266 Module
- Upload speed: 115200
- Crystal Frequency: 26MHz
- Flash Size: 4MB (FS: none OTA: 1MB)
- CPU Frequency: 80MHz
- MMU: 32KB cache + 32 KB IRAM
- lwip variant: v2 lower memory
- NONOS SDK: nonos-sdk 2.2.1+100
- Erase flash: all flash content
- Flash frequency: 40MHz
Every other sketch which does not involve the use of WiFi is working without issues.
This sketch works fine on the AzDelivery ESP8266MOD 12-F board which is very similar.
The board is new and I've seen the WiFi working for a few seconds before entering in the boot loop.
Other people with the same behavior were using #include <WiFi.h>
instead of #include <ESP8266WiFi.h>
, so this is not my case.
I can't understand what is the problem. Has anyone faced this problem before and found a solution?
Thank you for your time.
答案1
得分: 0
如@Juraj建议(请参阅问题下面的评论),问题是该板的功耗。
我已经以以下方式修改了草图:
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
// >>>
// 设置最大的发射功率(值范围从0到20.5 [dBm],包括边界值)
WiFi.setOutputPower(19.25);
// <<<
WiFi.begin("<ssid>", "<password>");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
Serial.println("已连接");
} else {
Serial.println("未连接");
}
yield();
}
当设置高于19.25
的值时,每次与AP建立连接时,板都会复位。
请参阅此处的文档:https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html#setoutputpower。
感谢@Juraj的快速支持!
英文:
As suggested by @Juraj (see comments below the question) the problem is the power consumption of this board.
I've modified the sketch in this way:
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
// >>>>>
// set the maximum tx power (Values range from 0 to 20.5 [dBm] inclusive)
WiFi.setOutputPower(19.25);
// <<<<<
WiFi.begin("<ssid>", "<password>");
}
void loop() {
if ( WiFi.status() == WL_CONNECTED)
{
Serial.println("Connected");
}
else
{
Serial.println("Not Connected");
}
yield();
}
When values higher than 19.25
are set, the board resets every time a connection with the AP is established.
See the documentation here https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html#setoutputpower.
Thanks to @Juraj for the quick support!
答案2
得分: 0
尝试在setup()
函数中添加一个while
循环,等待WiFi连接建立。
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
WiFi.begin("<ssid>", "<password>");
while (WiFi.status() != WL_CONNECTED);
delay(1000);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Connected");
} else {
Serial.println("Not connected");
}
delay(1000);
}
英文:
Try adding a while loop in setup() to wait until the WiFi connection is established
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(9600);
WiFi.begin("<ssid>", "<password>");
while (WiFi.status() != WL_CONNECTED);
delay(1000);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Connected");
} else {
Serial.println("Not connected");
}
delay(1000);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论