Can't get my photon out of Sleep

So in an attempt to read the current of my photon during sleep I did the following:

void setup() 
{
Spark.sleep(10);
}

void loop() {

}

Once I uploaded this the LED showed white and I can’t download anything. I have since tried to hard reset with no luck. I’m hoping that I didn’t somehow -brick- the photon.

Any help would be greatly appreciated

It is currently blinking Dark blue

Sounds like you reset it successfully and now it’s in Listen mode. Have you tried to setup the WiFi again?

Also, isn’t it System.sleep?

System.sleep(long seconds) does NOT stop the execution of user code (non-blocking call). User code will continue running while the Wi-Fi module is in standby mode.
1 Like

You can try the safe mode, which should allow you to update your user firmware without needing a factory reset.

Thanks @tjp. Actually, we were just discussing this internally today. Right now only Spark.sleep() works on the Core, and only System.sleep() works on the Photon. Sorry about that — shouldn’t be that way. We’ll be updating the docs soon to reflect reality, and an update to the Core firmware in the coming couple weeks will make System.sleep() work there.

Thanks Zachary, so, I should be able to just run the same code except use System.sleep(10);
and it should sleep and come back?

So I did

void setup() 
{
System.sleep(10);
}

void loop() {

}

And still cannot get the Photon to come out of sleep. @tjp, When you say that the code still runs, do you mean it is also looping through “void setup()” as well? I would assume that when it sleeps it continues to run the “void loop()” and then turns the WIFI back on? I’m getting the slow blinking white LED right now

@tgirard Sorry for obscuring the good advice of @Moors7 above — your current code will always immediately go to sleep, running setup() again each time it wakes up. Safe mode is the way to get your device back online so you can deliver an OTA firmware update with different code.

@Zachary, Thanks. I did use safe mode and was, in fact, able to get my photon back to a normal state :smile:
So the bigger question is how can I test System.sleep and simply have the photon sleep for a specified period of time and then come back to life without re-reading the System.sleep command upon waking?

Excellent! :smile: Try this:

int setupMillis;

void setup() {
  pinMode(D7, OUTPUT);
  setupMillis = millis();
}

void loop() {
  if (millis() - setupMillis > 30000) {
    System.sleep(10);
  }
  digitalWrite(D7, HIGH);
  delay(50);
  digitalWrite(D7, LOW);
  delay(700);
}

You should see blinking D7 for 30 seconds after setup runs, then the device should go to sleep for ten seconds.

2 Likes

OMG, I got so caught up in the whole sleep thing I wasn’t even thinking about encasing it in a time event… ok Tim, ssslow down… breathe…

Thanks again Zachary et all

1 Like