Author Topic: LowPower.PowerDown, Interrupts and sketch lockup  (Read 980 times)


  • Jr. Member
  • **
  • Posts: 65
LowPower.PowerDown, Interrupts and sketch lockup
« on: September 19, 2016, 07:01:47 PM »

I am using some Moteinos with the LowPower lib for power saving. The moteinos transmit around every minute using calls to LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF) to sleep.

Sometimes it receives also some interrupts from a reed switch installed on a tipping bucket, to measure rain. I had nodes in the field for a few months, but one of them during a rainy day has become stucked somewhere in the code, drowning the batteries. This might have occurred due to the interrupts associated with the rain, because it only occurred during a rain period, after months working without problems and only with a small impact on the battery capacity.

When the sketch locked up, the batteries (3xAA) droped from 4.4V to 3.8V in about 3 days (during these 3 days the node seems dead, not transmitting, but using battery). After disconecting and reconecting the batteries, the moteino started again to transmit normally, even with the bateries at 3.8V. So it seems the node was really locked, and the watchdog wasn't reseting the node.

My doubts are the following:

Is it possible to have the watchdog active to reset the node if something go wrong, and still use the LowPower.PowerDown? From what i saw in the LowPower lib, in the Watchdog interrupt callback the only thing that is done is to disable the watchdog. Is there any example of powerDown and wdog for protection at the same time?

Is there any side effect of using interrupts at the same time we use LowPower.powerDown?

Thanks in advance!



  • Administrator
  • Hero Member
  • *****
  • Posts: 6608
  • Country: us
    • LowPowerLab
Re: LowPower.PowerDown, Interrupts and sketch lockup
« Reply #1 on: September 20, 2016, 07:31:18 AM »
Do you have any potential never-ending loops in your code? Maybe something to investigate.
Anyhow you can look at the power down function, it takes a parameter to leave the BOD on or off:

Code: [Select]
void	LowPowerClass::powerDown(period_t period, adc_t adc, bod_t bod)
Is there any side effect of using interrupts at the same time we use LowPower.powerDown?
Yes, it wakes your CPU when the enabled interrupts trigger.