Core - sleep_mode_deep

Anyone running in the same problem:

My code shuts down the core at specific time, and if I understand the documentation correct after deep sleep the Core should be run exactly like I have pushed the reset button. Sadly my core resets and runs perfectly, expect the Digole OLED - the display stays black but I can see that the Core is running because I got the publish results on my website.
It must be a code problem because if I press reset or turn the Core off and back on the display initialize and works fine.

Docu:
When the Core awakens from deep sleep, it will reset the Core and run
all user code from the beginning with no values being maintained in
memory from before the deep sleep.

Code snippet

int funcSleep() {
    if (Time.hour() == sleepStart ) {
        digole.setScreenOff();
        Spark.sleep(SLEEP_MODE_DEEP,sleepTime);
    }
}

Hi @clyde,

Hmm, I think the ‘setup’ function doesn’t get run a second time when the core comes back from sleep, so you may need to reinitialize things after you come back in your loop?

Thanks,
David

Hi @Dave

did i misunderstood the documentation? Because it says “all user code from the beginning” Is setup() no user code? Maybe the Docu must be change to make it more clear.

Example (with problems):

if (coreRST == 1) digole.setScreenOn();

this will not work, because I cannot set a counter like coreRST while the Core starts with NO values in memory …

@Dave, @clyde, deep sleep mode on the Core retains nothing except the sleep timer and resets the Core upon timeout. So, based on my experience BOTH setup() and loop() get called.

@clyde, to understand why the digole does not work after sleep I would need to see your code and your hardware configuration (serial, I2C, SPI?). It IS possible to maintain inter-sleep values using the EEPROM emulation provided in the firmware.

http://docs.spark.io/firmware/#other-functions-eeprom

So you could store a coreRST flag in EEPROM though I would discourage that if you expect to sleep/reset very often. The Digole is not “aware” of the Core sleep and turning off the display essentially just turns off the OLED pixel power. You could simply run digole.setScreenOn() in setup() regardless of its previous state. Again, I would need to see your code to give you the best advice. :smile:

3 Likes

HI @peekay123

interesting thought with simply set digole.setScreenOn(); I will try that as soon as i am back home.

I´ll send you the link to my code via PM.
But in case that I am not going to waste your time, let me first try your suggestion.
There are more important things out there that my lousy code :blush:

Oops, my bad, thanks @peekay123 ! :slight_smile:

sry must be delayed - first I must fix my local :cloud:
As soon if it is up and running I wrote my report :wink: promise!

Ok another way - not really smooth but ok
Downloaded the firmware.bin file from :spark: CloudIDE and upload it to my raspberry. Now a spark flash --usb /…/firmware.bin is enough to get it running.

Tomorrow I let you know :wink: if it works.

2 Likes

LOL that really drives me nuts…
When I start the Core it blinks green - connecting to the network. Then short fast white and then red… I see

Connection from: 192.168.178.xxx, connId: 9
on ready { coreID: '123MYCOREID456',
  ip: '192.168.178.xxx',
  product_id: 0,
  firmware_version: 6,
  cache_key: undefined }
Core online!

Then it restarts and after X of that tries it start with the program. Sometimes a bit earlier, sometimes a bit later… that is really crazy…fingers crossed…

1 Like

OK seems to work :sunny:

When I came back home today the Digole OLED is on. Hope this is not due to a reset but let´s think positive!
Thanks a lot @peekay123! Kudos to you!

1 Like

@clyde, keep me posted :wink:

2 Likes

update: works like a charm since 3 days now!

2 Likes