Controlling sleep mode through input

Hello Spark community,

Was wondering if there is a simple way to come out of sleep mode with a trigger (via an input)? I can successfully put it to a timed sleep, but would be excellent to wake it back up manually rather than waiting (as it goes to wifi off and I can't sync or read data off during that time, also cannot figure out when that time is over because it goes back to sleeping...)

Kind of rough sketch of what I'm doing now, but would like to get it off sleep state or wifi back on with a trigger

Thank you so much!

const int button = 5;
const int blitz = 7;

int stroke = 0;

void setup() {

pinMode(button, INPUT);
pinMode(blitz, OUTPUT);
}

void loop() {

int strokes = digitalRead(button);
if(strokes==HIGH) {
    //Spark.sleep(60); //sleep for min
    digitalWrite(blitz, HIGH);
    delay(50);
}
else {
    Spark.sleep(60);
    digitalWrite(blitz, LOW);
    delay(10);
    digitalWrite(blitz, HIGH);
}

}

If you mean this:

this:

Or this:

Then no, that's not yet implemented. Since there are a lot of people eagerly waiting for it, including the famous "elites", I'm sure one of these days a notification will pop up somewhere telling us that it's finally here :wink:

As far as this goes:

You can disable the WiFi using code, but still let the Core run. This way, power is reduced, but data can be transmitted if your code deems it nescesarry (it's nescesarry it you program it to be...). Then again, it seems as if you already knew that :wink:

Let's hope it's released rather sooner then later!

1 Like

The firmware release that will allow full control of the connection to the cloud will be released next week!

1 Like

@zach and @Moors7, again this is a case of an event driven sleep mode which the STM32 can do but is not currently in the firmware.

1 Like

@zach and/or @peekay123, could this be done via the interrupt function under other functions?

There is another thread happening simultaneously that might be helpful: