简体   繁体   English

ESP32 为什么 WiFi 连接导致深度睡眠后“Brownout detector was triggered”

[英]ESP32 Why WiFi connection causes "Brownout detector was triggered" after deep sleep

When reconnecting to WiFi after waking up from deep sleep, an error "Brownout detector was triggered" is thrown causing the partial restart of the ESP.当从深度睡眠中醒来后重新连接到 WiFi 时,会抛出“Brownout detector was triggered”错误,导致 ESP 部分重启。 The setup phase is then done again, but now WiFi succeed to connect.然后再次完成设置阶段,但现在 WiFi 成功连接。

How to properly reestablish a WiFi connection after a deep sleep?深度睡眠后如何正确重新建立 WiFi 连接?

    #include <WiFi.h>
    #include "esp_wifi.h"
    
    #define SSID    "myssid"
    #define PASS    "ssidpass"
    
    #define uS_TO_S_FACTOR 1000000ULL   /* Conversion factor for micro seconds to seconds */
    #define TIME_TO_SLEEP  10           /* Time ESP32 will go to sleep (in seconds) */
    
    RTC_DATA_ATTR int boot_count = 0;
    
    void setup() {
      Serial.begin(115200);
      delay(200);
      
      print_wakeup_reason();
      Serial.print("Boot count: "); Serial.println(boot_count);
    
      Serial.println("WiFi connection");
      WiFi.begin(SSID, PASS);
      int try_count = 0;
      while (WiFi.status() != WL_CONNECTED && try_count < 10) {
          try_count++;
          delay(1000);
          Serial.println("Connection...");
      }
      Serial.println("WiFi connected");
    
      WiFi.disconnect();
      esp_wifi_stop();
      Serial.println("Sleeping in 1s ...");
      delay(1000);
    
      esp_deep_sleep(TIME_TO_SLEEP * uS_TO_S_FACTOR);  
    }
    
    void loop() {
    }
    
    void print_wakeup_reason(){
      esp_sleep_wakeup_cause_t wakeup_reason;
    
      wakeup_reason = esp_sleep_get_wakeup_cause();
    
      switch(wakeup_reason)
      {
        case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
        case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
        case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
        case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
        case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
        default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
      }
    }

Corresponding serial monitor message:相应的串行监视器消息:

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup was not caused by deep sleep: 0
Boot count: 0
WiFi connection
Connection...
WiFi connected
Sleeping in 1s ...
ets Jun  8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup caused by timer
Boot count: 0
WiFi connection

Brownout detector was triggered

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup was not caused by deep sleep: 0
Boot count: 0
WiFi connection
Connection...
WiFi connected
Sleeping in 1s ...
ets Jun  8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Wakeup caused by timer
Boot count: 0
WiFi connection

Brownout detector was triggered

I'm using a ESP-WROOM-32 (Chip is ESP32D0WDQ6 (revision 1)), on GNU Linux, with Arduino IDE 1.8.13, card library: Espressif System 1.0.4我在 GNU Linux 上使用 ESP-WROOM-32(芯片是 ESP32D0WDQ6(修订版 1)),带有 Arduino IDE 1.8.13,卡片库:Espressif System 1.0.4

This is a power problem.这是一个电源问题。 You need a more capable power supply to feed the ESP32.您需要一个功能更强大的电源来为 ESP32 供电。 If using a USB-powered dev board, try replacing the USB cable and connecting it directly to a USB port on your computer.如果使用 USB 供电的开发板,请尝试更换 USB 电缆并将其直接连接到计算机上的 USB 端口。 A powered USB hub might also help.供电的 USB 集线器也可能有帮助。

As my cable is undoubtedly good, I persevered and found this solution on the Net.由于我的电缆无疑是好的,我坚持下来并在网上找到了这个解决方案。 Does the fault come from the component which is a copy and not an genuine?故障是否来自复制而非正品的组件? Mystery.神秘。

#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

void initialize() {
    WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
}

I was having the same problem, has it has been mentioned that it is a power related problem I changed my power source from 2.0 to 3.0 and the problem was sorted out.我遇到了同样的问题,是否有人提到这是一个与电源相关的问题?我将电源从 2.0 更改为 3.0,问题得到解决。

So I'm seeing this problem too.所以我也看到了这个问题。 "Brownout detector was triggered" on my ESP32-S2-WROOMD (DevKit).我的 ESP32-S2-WROOMD (DevKit) 上出现“掉电检测器被触发”。 It happens when WiFi.Begin is called but only when my ESP32 DevKit is loaded: meaning I am using the 3.3V rail for powering some GPIOs and I'm also using a 5V sensor.它在调用 WiFi.Begin 时发生,但仅在加载我的 ESP32 DevKit 时发生:这意味着我正在使用 3.3V 电源轨为某些 GPIO 供电,并且我还在使用 5V 传感器。

Thinking the USB(2 and 3) ports weren't driving enough voltage/current I moved from the USB source to a separate regulated 5V power supply.考虑到 USB(2 和 3)端口没有驱动足够的电压/电流,我从 USB 电源转移到一个单独的稳压 5V 电源。 This seemed to drive both the MCU and the peripheral lines well but I was still getting intermittent brown-outs.这似乎可以很好地驱动 MCU 和外围线路,但我仍然遇到间歇性断电。

Then I added a polarized 220uF capacitor across the 5V positive/negative source and that all but eliminated the issue for me.然后我在 5V 正/负电源上添加了一个极化的 220uF 电容器,这几乎消除了我的问题。 BUT is still happens occasionally and unfortunately randomly.但不幸的是,它仍然偶尔会随机发生。

My rig includes an EPROG/JTAG debugger board with PlatformIO.我的装备包括带有 PlatformIO 的 EPROG/JTAG 调试器板。 Thinking the board might also be contributing I disconnected the debug board and that seems to have solved my problem (I didn't want to try to disable the brownout detector btw).考虑到该板也可能有所贡献,我断开了调试板的连接,这似乎解决了我的问题(顺便说一句,我不想尝试禁用掉电检测器)。

So, my thinking candidly is that the ESP32-S2 is very sensitive and finicky to power fluctuations which don't normally occur when the MCU is standing alone or simply connected with a sensor or two, but when you "load" it and there are power fluctuations (even when powered externally and not via USB) the chip has issues.所以,我坦率地认为,ESP32-S2 对电源波动非常敏感和挑剔,当 MCU 单独放置或仅与一两个传感器连接时通常不会发生这种情况,但当你“加载”它时,就会有电源波动(即使在外部供电而不是通过 USB 供电时)芯片有问题。 BTW, I even dialed up the regulated power source to 5.5V to see if additional juice would solve the problem and still didn't 100% cure.顺便说一句,我什至将稳压电源调到 5.5V 以查看额外的果汁是否可以解决问题,但仍然没有 100% 治愈。

Thinking of moving to the newer S3....考虑转移到较新的 S3 ....

In the search for the lowest consumption, I finally proceeded to various optimizations.在寻找最低消耗的过程中,我最终进行了各种优化。 And I came to deep sleep the ESP after disabling WiFi, and I take the ESP out of deep sleep with the WiFi still disabled.我在禁用 WiFi 后让 ESP 进入深度睡眠状态,然后在 WiFi 仍处于禁用状态时将 ESP 从深度睡眠状态中取出。 I reactivate the WiFi before using it.我在使用之前重新激活了 WiFi。 The ESP wake-up time is not a problem, low consumption is my priority. ESP唤醒时间不是问题,低功耗是我的首要任务。 And it works without a problem, without even using the first solution I posted.它没有问题,甚至没有使用我发布的第一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM