ESP8266在使用WiFi时发生看门狗复位。

huangapple go评论171阅读模式
英文:

ESP8266 watchdog reset when using WiFi

问题

我正在尝试在基于ESP8266EX的板子(XTVTX WEMOS D1 Mini Pro)上使用WiFi。

这个示例非常简单。

  1. #include <ESP8266WiFi.h>
  2. void setup() {
  3. Serial.begin(9600);
  4. WiFi.begin("<ssid>", "<password>");
  5. }
  6. void loop() {
  7. if (WiFi.status() == WL_CONNECTED)
  8. {
  9. Serial.println("Connected");
  10. }
  11. else
  12. {
  13. Serial.println("Not Connected");
  14. }
  15. yield();
  16. }

该板子一直因为看门狗复位(来源: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)。

以下是显示问题的日志。

  1. ets Jan 8 2013,rst cause:4, boot mode:(3,6)
  2. wdt reset
  3. load 0x4010f000, len 3424, room 16
  4. tail 0
  5. chksum 0x2e
  6. load 0x3fff20b8, len 40, room 8
  7. tail 0
  8. chksum 0x2b
  9. csum 0x2b
  10. v00044b80
  11. ~ld
  12. sp 0x3fffe9d0
  13. epc1=0x40204d1a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x04000102, depc=0x00000000
  14. 致命异常 (28):
  15. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  16. 致命异常 (28):
  17. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  18. 致命异常 (28):
  19. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  20. 致命异常 (28):
  21. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  22. 致命异常 (28):
  23. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  24. 致命异常 (28):
  25. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  26. 致命异常 (28):
  27. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  28. 致命异常 (28):
  29. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  30. [...]

我的设置:

  • 电源: USB 3.0供电集线器(5V 500mA)
  • IDE: Linux上的Arduino IDE v2.0.4
  • 库: 来自ESP8266 Communityesp8266 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.

  1. #include &lt;ESP8266WiFi.h&gt;
  2. void setup() {
  3. Serial.begin(9600);
  4. WiFi.begin(&quot;&lt;ssid&gt;&quot;, &quot;&lt;password&gt;&quot;);
  5. }
  6. void loop() {
  7. if ( WiFi.status() == WL_CONNECTED)
  8. {
  9. Serial.println(&quot;Connected&quot;);
  10. }
  11. else
  12. {
  13. Serial.println(&quot;Not Connected&quot;);
  14. }
  15. yield();
  16. }

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.

  1. ets Jan 8 2013,rst cause:4, boot mode:(3,6)
  2. wdt reset
  3. load 0x4010f000, len 3424, room 16
  4. tail 0
  5. chksum 0x2e
  6. load 0x3fff20b8, len 40, room 8
  7. tail 0
  8. chksum 0x2b
  9. csum 0x2b
  10. v00044b80
  11. ~ld
  12. sp 0x3fffe9d0
  13. epc1=0x40204d1a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x04000102, depc=0x00000000
  14. Fatal exception (28):
  15. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  16. Fatal exception (28):
  17. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  18. Fatal exception (28):
  19. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  20. Fatal exception (28):
  21. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  22. Fatal exception (28):
  23. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  24. Fatal exception (28):
  25. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  26. Fatal exception (28):
  27. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  28. Fatal exception (28):
  29. epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
  30. [...]

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 &lt;WiFi.h&gt; instead of #include &lt;ESP8266WiFi.h&gt;, 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建议(请参阅问题下面的评论),问题是该板的功耗。

我已经以以下方式修改了草图:

  1. #include <ESP8266WiFi.h>
  2. void setup() {
  3. Serial.begin(9600);
  4. // >>>
  5. // 设置最大的发射功率(值范围从0到20.5 [dBm],包括边界值)
  6. WiFi.setOutputPower(19.25);
  7. // <<<
  8. WiFi.begin("<ssid>", "<password>");
  9. }
  10. void loop() {
  11. if (WiFi.status() == WL_CONNECTED) {
  12. Serial.println("已连接");
  13. } else {
  14. Serial.println("未连接");
  15. }
  16. yield();
  17. }

当设置高于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:

  1. #include &lt;ESP8266WiFi.h&gt;
  2. void setup() {
  3. Serial.begin(9600);
  4. // &gt;&gt;&gt;&gt;&gt;
  5. // set the maximum tx power (Values range from 0 to 20.5 [dBm] inclusive)
  6. WiFi.setOutputPower(19.25);
  7. // &lt;&lt;&lt;&lt;&lt;
  8. WiFi.begin(&quot;&lt;ssid&gt;&quot;, &quot;&lt;password&gt;&quot;);
  9. }
  10. void loop() {
  11. if ( WiFi.status() == WL_CONNECTED)
  12. {
  13. Serial.println(&quot;Connected&quot;);
  14. }
  15. else
  16. {
  17. Serial.println(&quot;Not Connected&quot;);
  18. }
  19. yield();
  20. }

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连接建立。

  1. #include <ESP8266WiFi.h>
  2. void setup() {
  3. Serial.begin(9600);
  4. WiFi.begin("<ssid>", "<password>");
  5. while (WiFi.status() != WL_CONNECTED);
  6. delay(1000);
  7. }
  8. void loop() {
  9. if (WiFi.status() == WL_CONNECTED) {
  10. Serial.println("Connected");
  11. } else {
  12. Serial.println("Not connected");
  13. }
  14. delay(1000);
  15. }
英文:

Try adding a while loop in setup() to wait until the WiFi connection is established

  1. #include &lt;ESP8266WiFi.h&gt;
  2. void setup() {
  3. Serial.begin(9600);
  4. WiFi.begin(&quot;&lt;ssid&gt;&quot;, &quot;&lt;password&gt;&quot;);
  5. while (WiFi.status() != WL_CONNECTED);
  6. delay(1000);
  7. }
  8. void loop() {
  9. if (WiFi.status() == WL_CONNECTED) {
  10. Serial.println(&quot;Connected&quot;);
  11. } else {
  12. Serial.println(&quot;Not connected&quot;);
  13. }
  14. delay(1000);
  15. }

huangapple
  • 本文由 发表于 2023年3月12日 17:31:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75712199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定