Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9197
    SteveD
    Participant

    Hello all,
    I’m probably making a mountain out of a mole hill but I’m at wits end so I thought I’d reach out for some assistance. I’m using a 32u4 Feather with LORA for use as a remote motion detection alarm. I’ve been able to incorporate the low power library along with a DS3231 real time clock and can successfully wake by either either elapsed time (to send current battery voltage and alarm is still in operation) or interrupt on motion (alarm triggered) but not both in the same code. I could punk out and just send the voltage anytime an alarm as tripped but the routine check in is a great “reassurance” feature to have.
    I dug up a long ago question/response (2013) where someone asked about a similar setup and the response by Administrator was
    “You can do that. By pushing it to power down mode with the sleep interval you desire. At the same time, attach the external interrupt.
    In this case, your board could wake up on either of the source. To check the wake up source, use a semaphore flag in your external interrupt handler function and check it upon waking up.”

    For the life of me, I can’t figure out what would seem to be the “simple” use a semaphore flag in your external interrupt handler function and check it upon waking up. Could someone please save my sanity by providing a simple bare bones example? Many thanks in advance for your time and consideration!!!

    #9223
    LIM PHANG MOH
    Keymaster

    Hi SteveD,

    Here’s a skeleton code for your application:

    volatile bool pirTrip = false;
    loop()
    {
      .....
      attachInterrupt(0, pirTripEvent, LOW);
      LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
      if (pirTrip)
      {
        pirTrip = false;
       // Send data, etc
      }
    }
    
    void pirTripEvent(void)
    {
      pirTrip = true;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.