Low-Power icon indicating copy to clipboard operation
Low-Power copied to clipboard

Using Low-Power with a hardware watchdog?

Open Bambofy opened this issue 5 years ago • 3 comments

Hi, i need to ping a watchdog frequently to keep the Arduino running.

Am i ok to loop say, 10 times, and perform a SLEEP_60MS multiple times, pinging the watchdog after each sleep?

Bambofy avatar Jun 03 '19 15:06 Bambofy

Like this:

 int numberOfLoopsToPerform = (int)numberOfLoopsInDelay;
  
  for (int i = 0; i < numberOfLoopsToPerform; i++)
  {
    Pin_Interface_WatchdogHeartbeat();
    
    LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  }

Bambofy avatar Jun 03 '19 15:06 Bambofy

Related to #89 ?

robervaltaylor avatar Aug 30 '20 12:08 robervaltaylor

Yes, that will work, I use similar code with external watchdog timers (like the TPS3828 or a second MCU). I just would just make sure the external watchdog signal is send not only before sleeping but also on wake up, so your code would be:

  int numberOfLoopsToPerform = (int)numberOfLoopsInDelay;
  for (int i = 0; i < numberOfLoopsToPerform; i++)
  {
    Pin_Interface_WatchdogHeartbeat();
    LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  }
  Pin_Interface_WatchdogHeartbeat();

mariovaldez avatar Jan 02 '21 18:01 mariovaldez