Interrupt function that does not wake up from sleep?

hey there,

I'm hoping someone can shed some light or offer some advice on how best to achieve the following:

  • I have a rain and wind sensor that are connected to my arduino - I've attached external interrupts to get he data as follow:
  // attach external interrupt pins to IRQ functions
  attachPinChangeInterrupt(RAIN, rainIRQ, FALLING);
  attachPinChangeInterrupt(WSPEED, wspeedIRQ, FALLING);

the arduino sends the data to a server every 15min through some radio - things work fine and my rain and wind volatile vars are incremented correctly.

Now, here is my question:

  • I'd like to sleep the arduino for say 15m (put radio to sleep) - I'm using a function around the lines of
void sleepXMinutes(int nbIterations)
{
for (int i = 0; i < nbIterations; i++) { //75 for 10m, 90 for 12m
     currentSleepIterations=i;
     sleepDurationForCycle=millis();
     LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
  }
}

Unfortunately (and if I understand interrupts correctly) - when my rain or wind interrupt is called it will interrupt the powerDown function, call my interrupt and then go to the next iteration in the loop - and if it rains a lot (like today :slight_smile: pretty much the sleep function becomes a 2 sec loop and then we're back in the main loop().

I tried to get some vars in my sleepXMinute function to keep track if we got interrupted while sleeping but the code is quite ugly and then then even my delay functions get stopped during the interrupts so long story short I dont think this is the right way to approach the problem.

Any suggestions on how I can put the arduino in sleep mode but still get interrupt to fire without completely waking up the power down cycle?

Thanks in advance!

X

Maybe I need to rethink my program flow and have the loop always sleep and have an other interrupt with a timer that would fire every 15min and then send the data to my server.... Just detach the interrupts during that time and sample wind for 20s then send the data. time to try this out...