Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By Walter
#66249 Hi Guys,

I'm having some troubles with ESP8266 power saving mode.
I'm working with ESP-v12 and Arduino IDE v1.8. I'd like to reduce power consumption using lightSleep. In particular the ESP should sleep until external interrupt event occurs (on GPIO).

The main issue is that, while ligthSleep, the current can assume different values.
For instance, after initialization (current= 70mA) the ESP goes to lightSleep and I measure 0.2mA. After wake-up, when the ESP goes back to lightSleep, I measure
1.6mA (or sometimes 3.8mA).
In some cases, after initialization the current is just equal to 3.8mA and it stays equal to 3.8mA for each sleep cycle.

The problem is that current consumption changes are unpredictable.

Here my Sketch

//include files ****************************************************************************************

//WiFi
#include <ESP8266WiFi.h>
//WakeUp
extern "C" {
#include "user_interface.h"
#include "gpio.h"
}
//******************************************************************************************************

//const
const char* ssid = "mySSID";
const char* password = "myPassword";


//var
#define INPUT_PIN 2
int count = 0;
//******************************************************************************************************

void setup() {
//Serial
Serial.begin(115200);
Serial.println("Initialization");

//WiFi
initWifi();

//GPIO2
pinMode(INPUT_PIN, INPUT);

//Sleep Mode
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); //select sleep type
wifi_fpm_open(); //enable force sleep function
gpio_pin_wakeup_enable(2, GPIO_PIN_INTR_HILEVEL);
ESP.wdtEnable(20000);

}//setup


void loop() {

ESP.wdtFeed();
Serial.println("I'm ready to Detect => going to lightSleep");
wifi_fpm_do_sleep(268435455); //force sleep forever
delay(1000); //delay to allow esp sleep

count ++;
Serial.printf(("Detection_%d\n"), count);
delay(5000);
}//loop


NOTE: I've aslo tried to force WiFi disable, adding lines as:
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE); // set WiFi mode to null mode.
or
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
But with the same issue on consumption behavior as described above.

Do someone have similar issue?
If yes, any suggestions on how to fix it? Thanks in advance.

Kind Regards,
Walter