-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
Hardware
Hardware: wemos d1 mini
Core Version: 2.4.0-rc1
Description
I'm testing timed light-sleep on 2.4.0-rc1, I need to sleep about 15 seconds, which works, but then the board wakes up and delays an additional 15 seconds with the CPU active.
I am using a high precision usb power monitor (from yzx studio) to monitor when the board is truely in light sleep mode vs powered up. With a stopwatch I can verify the board goes into light-sleep mode for 15 seconds (about 7ma draw), then wakes up and delays an additional 15 seconds (about 22ma draw).
Seems this could be a bug in the delay procedure perhaps?
Settings in IDE
Module: Wemos d1 r2 & mini
Flash Size: 4m (3m spiffs)
CPU Frequency: 80Mhz
Flash Mode: (not sure where this setting is)
Flash Frequency: (not sure where this setting is)
Upload Using: Serial
Reset Method: (not sure where this setting is)
Sketch
/*
ESP8266 Blink by Simon Peter
Blink the blue LED on the ESP-01 module
This example code is in the public domain
The blue LED on the ESP-01 module is connected to GPIO1
(which is also the TXD pin; so we cannot use Serial.print() at the same time)
Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/
extern "C" {
#include "user_interface.h"
}
#include <ESP8266WiFi.h>
// only if you want wifi shut down completely (doesn't seem to work)
// RF_MODE(RF_DISABLED);
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
Serial.begin(115200);
//WiFi.mode(WIFI_OFF);
wifi_set_sleep_type(LIGHT_SLEEP_T);
WiFi.forceSleepBegin();
delay (1000);
// ~22ma
}
void wake_cb() {
Serial.println("wakeup");
wifi_fpm_close();
WiFi.forceSleepBegin();
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
wifi_set_opmode_current(NULL_MODE);
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
wifi_fpm_open();
wifi_fpm_set_wakeup_cb(wake_cb);
wifi_fpm_do_sleep(15000000);
delay (15001);
// ~7ma for 15 seconds, then ~22ma for 15 seconds (75ma for 15 seconds without forcesleepbegin in callback)
Serial.println("loop");
}