Skip to content

Can't re-enable WiFi after ESP.deepSleep(uS, WAKE_RF_DISABLED) ? #3072

Closed
@sheffieldnikki

Description

@sheffieldnikki

Basic Infos

Hardware

Hardware: WeMos D1 mini
Core Version: v2.2.0

Description

My sketch spends most of its time in deep sleep, just using the WiFi when it first powers up. This works fine from a full power-cycle, but not if is reset (reset button, or new sketch uploaded over serial). In that case I can't seem to switch the WiFi back on? I presume the RF is disabled from the deep sleep, even through a reset, and WiFi.mode(WIFI_STA) isn't enough to switch it back on?

I get:

add if0
f r0, 
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
....
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
scandone
reconnect
f 0, error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
....
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
scandone
reconnect
f -180, error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
....
error: pll_cal exceeds 2ms!!!
error: pll_cal exceeds 2ms!!!
scandone
del if0
usl
mode : null

Settings in IDE

Module: WeMos D1 R2 & mini
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: SERIAL
Reset Method: ?ck / nodemcu?

Sketch

#include <ESP8266WiFi.h>
extern "C" {
#include <user_interface.h>
}

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  // Connect to WiFi if we have just powered on (*not* if waking from deep sleep)
  rst_info *resetInfo = ESP.getResetInfoPtr();
  if (resetInfo->reason != REASON_DEEP_SLEEP_AWAKE) {
    WiFi.mode(WIFI_STA);
    WiFi.begin(WLAN_SSID, WLAN_PWD);
    WiFi.setAutoConnect(false);
    WiFi.setAutoReconnect(false);
    WiFi.waitForConnectResult();
    // do some networky stuff


    WiFi.disconnect();
    WiFi.mode(WIFI_OFF);
  }
}

void loop() {
  // do regular non-networking stuff

  // enter deep sleep, with radio off upon waking
  unsigned int sleep_secs = 10;
  ESP.deepSleep(sleep_secs*1000000, WAKE_RF_DISABLED);
}

NB: I'm using WiFi.setAutoConnect(false)/setAutoReconnect because otherwise the board was always trying to connect to the WiFi immediately upon waking from deep sleep, even if WiFi.disconnect(), WiFi.mode(WIFI_OFF) and WAKE_RF_DISABLED had been called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions