Hi All -
I'm working on a project using Arduino IDE on Adafruit's Huzzah ESP8266. I've successfully implemented code that can put the Huzzah into light sleep and wake it up again when the PIR senses movement. When the PIR senses movement, it resets a global timer (volatile int timer) and initiates some wake-up code that is is defined in an additional header file (gpio.h). However, this callback is only able to be called while the Huzzah is in light sleep mode - it doesn't get called any other time. So in reality, this creates a not-so-ideal cycle where the huzzah decrements its timer until it enters sleep mode, goes into sleep, gets woken up with movement, and immediately starts to decrement the timer again. If you're in front of the device while it's not in sleep mode, it can't actually sense movement to reset the timer until its asleep.
So to fix this design issue, I attempted to run another jumper from the PIR to another pin and attached an interrupt to this new pin. I created a super simple interrupt service routine that just sets the timer back to its full value. The idea here is that the PIR is doing two jobs: one to set the timer back anytime movement is sense during the loop and two, to wake up the huzzah once it's entered sleep mode.
The issue is that it seems to be one or the other. I can either have the interrupt and issue the ISR when movement is sensed or I can have the PIR be used for the wake-up portion. Can you not monitor the same sensor through two different pins? Am I just not getting enough current through both? Is there a better way to achieve what I'm aiming for? I'd be grateful for any insight!
Note: I'm using a pull down resistor (22K) on the pin that monitors the wake-up portion.