Feasibility of using Sleepydog for longer sleeps?

Hi,

I’m looking to use a sleep function to save battery on a remote logger. I’ve tried a few sleep libraries, and have been having issues. One of the primary issues, I think, is that I’m using an Adafruit 32u4 Adalogger with a featherwing RTC as a shield, and a lot of the RTC interrupt methods seem to rely on the RTC being truly external, sending an interrupt to wake the unit up, which doesn’t seem to work. Other people have written that sleep functions are problematic on this setup.

I’ve just been looking at the feasibility of using the Adafruit Sleepydog library, and it seems to work, but given my history I’m worried I’m overlooking something. I’ve just got a simple bit of code that checks to see the time, and if the minute is between x and y it goes into a sleep loop, sleeping for 10000, then waking up, checking the time, and going back to sleep. In practice I’d change this to x and y hours.

/*

*/
#include "RTClib.h"
RTC_DS3231 rtc; //add clock chip
#include <Adafruit_SleepyDog.h>//sleep library

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  
}

void loop() {
  DateTime now = rtc.now();
  Serial.println(now.minute());
  if (now.minute()>= 20 and now.minute()<=21)
{
   int sleepMS = Watchdog.sleep(10000); //sleep for 10 seconds
    #if defined(USBCON) && !defined(USE_TINYUSB)
     USBDevice.attach();//reattach USB 
    #endif
  }
  
  else {
   
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on 
  delay(500);                       // wait 
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off 
  delay(500); 
  Serial.println(now.minute());
  }     
  
}

It seems to work. The current draw drops from 10mA to 0.6mA for the duration of the ‘sleep’ period, and doesn’t seem to spike significantly after each mini ‘sleep’ period that I can see on the multimeter.

Am I missing something?

Thanks

A quick look at the FeatherwingRTC and the Adalogger and you would need to connect the INT output of the FeatherwingRTC to one of the hardware interrupt pins of the Adalogger to be able to use the RTC to wake the logger from sleep. You can google several examples, one being this project.

AFAIK the 32U4 MCU in the Adalogger can only sleep for a max of 8 seconds using the watchdog timer.
To save a tiny bit more power you could just increment a counter every time you wake instead of reading the RTC and just read the RTC every 8 (or more) wakes to check the time.

Riva:
A quick look at the FeatherwingRTC and the Adalogger and you would need to connect the INT output of the FeatherwingRTC to one of the hardware interrupt pins of the Adalogger to be able to use the RTC to wake the logger from sleep. You can google several examples, one being this project.

Thanks, it’s the connecting of the INT pin to the adalogger that I’m missing. I’m not sure how to connect it with it being stacked? The INT pin on the RTC has a duplicate hole, but the logger doesn’t.

AFAIK the 32U4 MCU in the Adalogger can only sleep for a max of 8 seconds using the watchdog timer.
To save a tiny bit more power you could just increment a counter every time you wake instead of reading the RTC and just read the RTC every 8 (or more) wakes to check the time.

Ok, thanks for the tip, that makes sense. I upped the sleep time to see what happens, and it didn’t go the distance. I’ve got counters for other things in there, so I know how to do it.

As it is, do you think, other than not being completely optimised, it’ll cause problems?

Nazaar--:
Thanks, it's the connecting of the INT pin to the adalogger that I'm missing. I'm not sure how to connect it with it being stacked? The INT pin on the RTC has a duplicate hole, but the logger doesn't.
You might need to solder a wire between the INT pin and a suitable EXTINT pin on the feather.

As it is, do you think, other than not being completely optimised, it'll cause problems?
Should be fine, I use sleepydog on Lora32U4 boards and power them from battery. Have been using this system for a couple of years+ now.

Thanks. I can get, I think, 30ish days on one battery with the current sleep set-up, so if I need more I'll work on connecting the INT properly for a more efficient sleep.

Thanks for the help.

Nazaar--:
Thanks. I can get, I think, 30ish days on one battery with the current sleep set-up, so if I need more I'll work on connecting the INT properly for a more efficient sleep.

Not knowing your setup means it's difficult to say if that's a good battery life or not. Writing to SD card is a lengthy and power hungry task and maybe the sensors your using also consume power.

As an example I have the 32U4Lora board with BME280 sensor & MAX44009 sensor. I take readings every 10 minutes and transmit the average results every 30 minutes and get just over a year of use from a single 18650 battery.

It's a logger for looking at light at night, underwater, using the adafruit 2591.

I'm using one of the 3.7V 4400mAh LiPo batteries. It's running at 10mA normally, then 27 when the SD card saves, 0.5 when it's sleeping. The sensor is read every second or so, but saves it to SD every 90 readings. I could lengthen the gap between readings to probably every minute (I need to see short term changes), and then make it sleep between them, and that'd significantly reduce battery use. At this point someone has to visit the logger regularly anyway to clear the fouling off the acrylic covering the sensor, and to check it's still there. Once I figure out a solution to the fouling issue then setting to sleep more would make sense.

Thanks for the ideas, you've pointed I can do a lot more to optimise.