Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Froghut
#65659 Hi,

I'm trying to get my ESP8266 into light sleep state, but as soon as it enters light sleep it disconnects from the wifi. From the documentation it sounds like it should stay connected to the AP. I got my code from a github issue discussion and it loks like this:

Code: Select allvoid callback() {
  Serial << "a"<<endl;
  Serial.flush();
}

void loop() {
  //wifi_station_disconnect(); //not needed
  uint32_t sleep_time_in_ms = 2000;
  wifi_set_opmode(NULL_MODE);
  wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
  wifi_fpm_open();
  wifi_fpm_set_wakeup_cb(callback);
  wifi_fpm_do_sleep(sleep_time_in_ms *1000 );
  delay(sleep_time_in_ms + 1);
}