SLEEP_MODE_DEEP not working with SYSTEM_MODE(SEMI_AUTOMATIC)

I did some testing on a Photon, and I’m getting weird results, but I’m not sure whether it’s the same thing @markjones.cpe is seeing. I have one Photon that I can use to set a pin HIGH or LOW with a particle function. That pin is connected to my other Photon’s WKP pin. This is the code on that Photon,

bool shouldSleep = false;

void setup() {
    Particle.function("rdmSleep", rdmSleep);
    pinMode(WKP, INPUT);
    pinMode(D7, OUTPUT);
    digitalWrite(D7, HIGH);
    delay(500);
    digitalWrite(D7, LOW);
}

void loop() {
    if (shouldSleep == true) {
        shouldSleep = false;
        delay(500);
        System.sleep(SLEEP_MODE_DEEP,30);
    }
}

int rdmSleep(String cmd) {
    shouldSleep = true;
    return 5;
}

As long as I have the WKP pin connected to the other Photon, whether that pin is HIGH or LOW, the Photon with the above code will not go to sleep. In fact, what it does is reset (the flash of the D7 LED confirms that).

@Ric, just to make sure, the GND pins are connected between the two Photons?

And waking from DeepSleep does behave just like a reset.
So it might actually go to sleep but immediately wake again.

What system version are you runnning?

pinMode(WKP, INPUT) is irrelevant as System.sleep(SLEEP_MODE_DEEP) does implicitly set the pin mode as needed.

1 Like

No, the ground pins were not connected together. When I do that, the Photon does go to sleep as it should. Why should that be? I did measure the voltage on that pin, and it was only a few millivolts when set to LOW.

You need a common reference (common ground) since the 3.3V of the on Photon will have no meaning to the other Photon, unless they have a common basis to “measure” the voltage difference against.
Try measuring the votage between two non connected batteries (irrespective of the poles you choose + vs. + or + vs. - or - vs. - )

That’s what we call a floating potential - you need to tie both floating sources (Photons or batteries) to the same point to get a valid reading.

1 Like

Ok, that makes sense then. If I measure the LOW output from the one Photon against the ground of the one I’m trying to put to sleep, the values are very unsteady. I never see anything higher than about 100 mv, but that might be just the slowness of the meter. So, I am just seeing the sleep being instantly cancelled by this fluctuating value.