System.sleep(seconds) broken in 0.6.0?

My Photon never wakes up with this simple code,

void setup() {
    Time.zone(-8);
    Serial.begin(9600);
    delay(3000);
    Serial.println("Starting");
}

void loop() {
    
    if (Time.hour() == 18 && Time.minute() == 0 && Time.second() == 0) {
        Serial.printlnf("Min: %d   Sec: %d", Time.minute(), Time.second());
        delay(2000);
        System.sleep(15);
    }
}

I get a single print out, and the Photon breathes white. Is this broken, or did I miss some change in the way this sleep mode works?

Your code appears to only print once a day at exactly 18:00:00.
Try removing the Time.hour() == 18 from your code and see what it does. The sleep mode you are using keeps running code and turns off your wifi for 15 seconds. Try changing to

System.sleep(wakeUpPin, edgeTriggerMode, seconds);

if you want to treat sleep as a delay() or use

`System.sleep(SLEEP_MODE_DEEP, seconds);`

if you want the device to reset after sleeping.

That's what I wanted it to do. It's just a test. The problem is, when I ran this just before 6PM, the Wi-Fi never came back on after 15 seconds.

I did see that same behaviour, but I never really saw any use in this (crippled, not deserving the name) “sleep()” mode anyway, so I never investigated further :wink:

Apparently, other people don't either, since this has gone unnoticed for a while. It did work back in march when this was posted. I was just testing it in response to another question I was responding to; I don't think I've ever used it before. Maybe it's time to retire this function.

1 Like

I’ve had the same problem.
WiFi.off helpped save power, but then I found Deep Sleep works which is good enough for me.

A fix for this issue is slated for 0.7.0