DEEP_SLEEP wakeup stopped working?

Hi all,

I have a simple piece of code to monitor a door opening, wake up the Photon, send an event, and then bo back to deep sleep. The device wakes up via a reed switch opening, causing the WKP pin to go high (pulled up via 14k resistor to 3.3V). It also wakes up once an hour via timer to push battery status (I am using the SparkFun battery shield with a solar panel).

It was working fine for a few days, but then I noticed I stopped getting updates. I went and checked it out and it seems like the device simply doesn’t wake up anymore from deep sleep unless I hit the reset button. Neither the RTC timer or WKP pin seems to cause it to wake. I didn’t change any software, it just stopped working on its own.

The device is put to sleep via:
System.sleep(SLEEP_MODE_DEEP, 3600);

Is there any explanation as to why it would suddenly stop waking up?


If the WKP pin was still HIGH when the device went to sleep, this would cause future interrupts (from WKP or RTC) to be blocked.

Thanks! That seems to be it. I think I just got lucky in my brief initial testing and it always went to sleep with the door shut.

One simple workaround would seem to be to not go into deep sleep when the door is open, only the more limited sleep. This has a significant impact on my power draw but since the door being open for long times isn’t normal, may be acceptable.

Is there any other easy workaround since I don’t have a true wakeup “pulse” to work with here?

You could use a system timer IC on the door signal - these produce a pulse (length can be varied by external components) when the input signal changes. I use this to “wake” a photon from sleep when the mains power supply is restored - it works off the 5VDC from the AC:DC converter. Something like a TPL5111DDCT. The output then goes to the WKP pin.

1 Like

A less professional take on that might be using an RC differentiator circuit like this

(D1 is there to protect against the negative spike on the falling edge)

Thanks for both of your suggestions! However, if I’m not mistaken, both will only let me generate a pulse on a level change in a single direction. I’d really like to generate a pulse when the level changes either direction. My current hacky solution works because on non-deep-sleep I can wake on either edge. When I was originally testing deep sleep I thought it could wake on either edge as well, but I imagine it is just the reed switch bouncing.

Our answers were addressing your original question about waking from deep sleep and you also said you wouldn’t go to deep sleep while the door was open.

However, you see D1 in my suggestion. This is there to cut off the negative spike caused by a falling edge. So the pulse would be there to work with, you’d just need to flip its polarity for the negative part.

I am unclear as to what you mean - let me test my understanding - you want to have the photon most of the time in deep sleep, and wake when the door is opened or closed? You can achieve this using an OR gate with one pulse generated when the door is closed and another pulse when the door is opened. Ideally, you wake up the device and then immediately check the state (High or Low) of each signal so that you can know if the door is now open or closed. Is this what you meant?