MKR WiFi 1010 with two interrupts

I have a project using a MKR WiFi 1010 with an external interrupt on pin 8 from a PIR sensor to wake it up from low power sleep mode. Then I connect to the WiFi network and issue a push notification through Pushsafer to my iPhone. The MKR 1010 is powered by a 2,500 mAh LiPo battery. I would like to be able to wake up the MKR 1010 using the internal real time clock about every 4 hours, check the battery voltage and issue a push notification if it needs to be charged. That way I wouldn't have to manually check a network of these devices to see if their batteries are in need of charging.

I'm using the Arduino LowPower library sleep() method and putting the WiFiNINA module in low power mode. LowPower.attachInterruptWakeup(8, dummy, RISING) works fine for the PIR interrupt. I tried adding LowPower.sleep(14400). in the main loop but it blocked the PIR interrupt.

I'm guessing that the LowPower.sleep() method takes priority but I can't really tell from looking at the ArduinoLowPower.cpp file in the library. They are not overloading the same method. Does anyone know how I could use these two different interrupts to wake the MKR 1010 up? Attached is my sketch.

ExternalWakeup-ajm2.ino (6.08 KB)

Update Jan 25, 2021: I think I figured this out. There was a problem in my sketch. Using LowPower.sleep(sleeptime) to wake up periodically and check the battery level works with LowPower.attachInterruptWakeup(pin, ISR, RISING) which wakes the MKR 1010 when the external PIR sensor is tripped. If the battery level is lower than the threshold, a Pushsafer push notification is sent to the phone with sound off and a visual message containing the LiPo battery voltage. If the PIR sensor wakes up the MKR 1010, the sound is on and a different title and message are in the notification. No help is needed.

Attached is the revised sketch.

arduinoPIR-1.txt (6.07 KB)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.