-->
Page 1 of 1

Getting Light-Sleep to work

PostPosted: Sat Jul 25, 2020 7:34 pm
by OzGrant
G'Day,
Have attached a basic Light-Sleep sketch that blinks the Led OK but then stops randomly.
Often blinks 10 times other times 50. (Hardware is a WeMos mini)
Anyone got any clues.

#include <ESP8266WiFi.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
wifi_set_sleep_type(NONE_SLEEP_T); // Disable light sleep
delay(2000);
digitalWrite(LED_BUILTIN, HIGH);
wifi_set_sleep_type(LIGHT_SLEEP_T); // Enable light sleep
delay(2000);
}

Re: Getting Light-Sleep to work

PostPosted: Sun Jul 26, 2020 2:01 am
by OzGrant
I solved my problem.
The sketch was timing out. After adding a yield(); to the last line all ok.

Re: Getting Light-Sleep to work

PostPosted: Sun Jul 26, 2020 4:40 am
by OzGrant
G'day,
I spoke too soon, still not working....