If you use SYSTEM_THREAD(ENABLED)
in conjunction with SYSTEM_MODE(SEMI_AUTOMATIC)
your Photon should be ready to digitalRead()
the PIR pin in less than a second.
Why would you do digitalWrite(_pin, LOW)
as first action after wake and not immediately digitalRead(PIR)
to catch the state of the interrupt pin when this is held HIGH for 30sec?
If it was HIGH, then you have been woken by an interrupt, if it’s not, it’s most likely due to a timed wake.
Also what do you expect to get as result from that?
digitalWrite(_pin, LOW);
_detected = digitalRead(_pin);
How would you ever read anything else from _pin
than LOW
?
Some related threads (search term “wake pin time”)
Electron Detect Wakeup from Pin Vs. Timer
Photon WKP Pin Interupt Flag Question