Waking up after sleep with WiFi creds for another network

@mdma @BDub

I am using a P1 module on version 0.5.2.

I’ve run into an issue with the sleep mode. After waking up from sleep, the P1 tries to reconnect to wifi and blocks, this should not be the expected behavior based on the below code. Please see the below for the minimal code.

1st clear all WiFi creds and enter new wifi creds for another network. This is to simulate that the device is portable and leaves a network.

The expected behavior of the below code should be.
-Wifi turns on and trys to connect after 4 sec all attempts are stopped by disconnecting from the cloud or wifi trying to connect.
-then the wifi module is turned off.
-then the P1 is put into sleep mode.
-expected to be once the P1 wakes up the wifi module should be off and the led flashes white, no wifi connections should be attempted
-actual behavior is that P1 wakes up then turns on wifi module then trys to connect to wifi. this also blocks the code for a while.

do you have any thoughts why this is happening?

I’m trying to implement a battery mode for my product but this behavior eats up battery quickly.

#include "application.h"

void setup() {
    if (WiFi.ready() && Particle.connected()) {


void loop() {
    System.sleep(D4, FALLING, 4);
1 Like

It’s unclear from the documentation if setup() is run after coming out of stop mode or if the device goes directly to loop(). Have you tried putting debug into your setup() function and seeing if it’s run again?

@Undergrid with stop mode sleep, the Photon wakes and starts from the line after the sleep function call. Only when selecting deep sleep does the processor do a reset.