Core doesn't like waking up after sleep

Hi,

I’m trying to get sleep mode to work to lower the power usage, however it appears that the core doesn’t like waking up after I put it to sleep.

Without sleep mode, the core stays connected, makes regular POST requests to a server, I can flash it, no issues. When I use sleep mode, the core will come out of sleep periodically and reconnect, although this fails most of the time (usually with slow fading white). I cannot reflash the core in this mode (I need to use USB). Deep sleep doesn’t seem to work either, although I’ll have to retest it again.

Any ideas what’s going on? Thanks.

Could you describe your setup, e.g. any pheripherals connected to the core, and share the code you are using, and anything else someone might need to reproduce your problem.

1 Like

Yep - I’m using a uFL core with a 2.4ghz antenna, and I’m using I2C, some digital inputs, and some analog inputs.

The code I’m using is here - I haven’t figured out an easy way to get code in or out of the web IDE without copy and pasting:

Things go downhill if I uncomment the Spark.sleep(40); line.

I think you won’t see much of a gain if you’re sleeping for 40 milliseconds at a time. You might have more success if you say, wake up for 1 out of every 10 minutes, etc:

http://docs.spark.io/firmware/#spark-sleep

I hope that helps!

Thanks,
David

1 Like

Per the documentation, Spark.sleep() takes int seconds, not milliseconds.

Hi @mhenstell,

Hah, my bad :slight_smile: I would bake in a pre-sleep cycle delay, so you can still flash your core, generally I do something like: wake up for ~2 minutes (enough time to get online and for a flash to start), then start sleep / wake cycle.

Have you tried deep sleep instead, does that work better in your scenario?

Thanks,
David

Hi @dave,

I can’t use deep sleep because I’m aggregating data once a second, although when I tried it, the results were no better. What I’ve been doing is sleeping for 40 seconds every 60 seconds. The 20 seconds is more than enough time for the core to get online and the POST action seems to succeed, however the core will never flash (except over USB). I assumed that the first thing the Core would do upon connecting every time would be to check if there’s new firmware, however it seems that the core never gets new firmware after going into sleep mode, even after reconnecting.

Hi @mhenstell,

Ahh, the OTA flash process right now is just like sending any other message to your core, like checking a variable or calling a function, it currently requires your core be online at that moment ready to receive new firmware. Although, that’s a great feature suggestion, queuing up a flash for the next time the core is online… Lemme stew on that one :slight_smile:

Thanks,
David

You could add a button to prevent sleeping while pressed.

Yeah, queued flash updates would be super awesome. Without them, it’s hard to make a remotely upgradeable & low power system.

I think I can probably poll for the spark to be online and then push the update

1 Like

I also think this is a good idea, if an update is pending, do it when the core connects. Not really possible to do remote firmware updates unless the core is always in full power mode otherwise.

The button override method is another possible solution but not nearly as nice for end users.