Sleep_n0m1 Library Questions

Hello!
I have a few questions about the Sleep_n0m1 library found in the playground.
The example at Sleep_n0m1/Sleep_n0m1_simple.ino at master · n0m1/Sleep_n0m1 · GitHub sets the sleep mode to Power Down mode (the best power saving mode), then automatically wakes up every 5 seconds without an external interrupt! I experimented with disabling peripherals using the avr/power.h library, and realized that function sleepDelay() relied on Timer 0. I looked at the source code (CPP and H files) here: GitHub - n0m1/Sleep_n0m1: A library that sets the Arduino into sleep mode for a specified length of time, or until an interrupt. In the sleepDelay() function, I see the sleep mode being set to Idle (least power savings) mode! I can’t find any lines of code after that that sets the sleep mode back to Power Down. It seems to be using the WDT to wake up.
Question 1: Is the example actually putting the Arduino to Power Down sleep mode for 5 seconds, or is it constantly in Idle mode?
Question 2: Can you teach me how to get the most power savings using the sleepDelay() method (help improve my code here)?

#include <Sleep_n0m1.h>
#include <avr/power.h>
Sleep sleep;
unsigned long sleepTime; //how long you want the arduino to sleep

void setup()
{
  Serial.begin(9600);
  sleepTime = 5000; //set sleep time in ms, max sleep time is 49.7 days
}

void loop()
{
  delay(100); ////delays are just for serial print, without serial they can be removed
  //Serial.flush();
  Serial.println("execute your code here");
  Serial.print("sleeping for ");
  Serial.println(sleepTime); 
  //Serial.flush();
  delay(100); //delay to allow serial to fully print before sleep
  power_adc_disable();
  power_spi_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_twi_disable();
  MCUCR = _BV (BODS) | _BV (BODSE);  // turn on brown-out enable select
  MCUCR = _BV (BODS);        // this must be done within 4 clock cycles of above
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepDelay(sleepTime); //sleep for: sleepTime
  power_all_enable();
}

Thanks!

Having just taken a cursory look at that library, the only place I see set_sleep_mode(SLEEP_MODE_IDLE); is in the calibrateTime() function. Looks like the library uses the WDT to wake the MCU. The maximum period for the WDT is 8 sec., so for long sleep intervals the MCU will need to wake briefly, check where it is, then go back to sleep if the interval has not yet expired. Since the WDT is clocked by its own, separate oscillator, the library calibrates it against Timer0 so that the sleep intervals will more closely correspond to the values returned by millis().

To address your questions, I have not tried this library myself, but I would assume that it works as advertised: (1) I would expect the example actually is going into power down mode as opposed to idle mode. I might check it with a multimeter. (2) Does the code need improving? How much power savings is seen? Measuring results is important. I've done a fair amount of fiddling with sleep modes, and the multimeter is never far away. When experimenting with sleep modes, my preference is to use a standalone MCU on a breadboard, so that I can directly measure its current consumption while not having to worry about that of ancillary circuitry.

dkl65: In the sleepDelay() function, I see the sleep mode being set to Idle (least power savings) mode!

What I see is:

set_sleep_mode(sleepMode_);

Where 'sleepMode_' is set in:

void Sleep::pwrDownMode() {setSleepMode(SLEEP_MODE_PWR_DOWN);}
void Sleep::setSleepMode(int mode) { sleepMode_ = mode; }

dkl65:
Can you teach me how to get the most power savings using the sleepDelay() method (help improve my code here)?

Read this, whilst sleep mode is important there are other considerations, quite a few of them:

http://www.gammon.com.au/power