Error: 'class SystemClass' has no member named 'Sleep'


I can’t get my sketch to compile when I use: System.sleep(SLEEP_MODE_DEEP, 60);
With System.sleep(60); it does not compile too.
I was the last few weeks really busy so I don’t know if there were any changes made to the firmware.
I am building online with Firmware 0.3.4
The error seems to be in each sketch I try to use System.sleep…
I would be very grateful if you could help me :smile:

Core or Photon?

Sorry, I forgot to mention I am using a Core

Use Spark.sleep() until the new firmware update is released :smile:

Thank you very much! :smile:
I didn’t notice the change in the documentation.

@kennethlimcp What is the difference between Spark.sleep and System.sleep? I see that the documentation has only System.sleep and no spark.sleep(). Is Spark.sleep deprecated?

1 Like

It is deprecated with the new firmware to something that makes more sense --> System.sleep()

1 Like


I would like to understand the following (I am using Spark Core):

  1. When I use wi-fi sleep (Spark.sleep(seconds)), I understand that it switches off the wi-fi for the specified number of seconds. If I call this inside a Spark function, does it continue executing the rest of the function code after it comes out of wi-fi sleep, or it goes back to setup() and loop() again? Also, if my external function call depends on wi-fi availability, does it make sense to add a delay() so there’s enough time for wi-fi to come up and get connected before the rest of the function code gets executed successfully?

  2. When I use deep sleep (Spark.sleep(SLEEP_MODE_DEEP, seconds)), I understand that the whole Spark chip gets into sleep/hibernate mode consuming very less current (in the range of micro amp). When it comes out of the sleep, do setup() and loop() get executed, as if the system is being reset? Also, where would be the best place to put sleep call - inside setup() or inside my Spark function call (i.e. the local method that gets called from the Spark function over the net). My requirement is to keep the system idle for user-controlled duration.

  3. Since my basic requirement is to save my battery power, without interrupting my service (i.e. Spark functions to execute from cloud whenever I want), I realize that #1 and 2 above won’t help much (but I would still like to know the answers to #1 and 2 :smile:). What I think makes sense is to use the interrupt-driven sleep (Spark.sleep(pin, triggerCond)), so when I send a command on a particular pin (let’s say I attach a servo with A0, and rotate it) via cloud (Spark Function call), it should come out of sleep and start execution.
    Here also, I have the same question as in #2: once it comes out of deep sleep (after interruption, i.e. my command to pin A0), does it execute setup() and loop() again, as if the system is reset? If that’s the case, my rest of the function code won’t be executed if I place my sleep code inside the function, right? Where should I typically put this sleep call?

Basic use case/requirement is this:

During initial boot up, I would like Spark Core to do the init stuff in the setup() call (btw, there’s nothing in my loop()), and then get into interrupt-driven deep sleep - so it’s in lowest power consumption mode. Now if I send a command to rotate my servo x degree, the deep sleep should get interrupted and come out and execute my command (on pin A0…I believe I can use CHANGE as the 2nd parameter?). Once my command is executed successfully, I would like this again going into a deep sleep (interrupt mode).
I am little confused with where should I put my sleep call - if I put this inside setup(), and if setup() gets called after it comes out of sleep, this will go into a forever loop! How do I make sure that my function call invocation always ends its deep sleep mode and still my rest of the command proceeds with the intended action?

I am new to Core, so would really appreciate if you could clarify the above.