Skip to content

Instantly share code, notes, and snippets.

@dzonesasaki
Created May 19, 2021 07:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzonesasaki/dbccc2981e9169d7edd548ad1e3f3e3f to your computer and use it in GitHub Desktop.
Save dzonesasaki/dbccc2981e9169d7edd548ad1e3f3e3f to your computer and use it in GitHub Desktop.
sample of sleep and wakeup on RTC using seeeduino xiao and Arduino-IDE
// sleep and wake test using RTC
// for seeeduino xiao
#include "RTC_SAMD21.h" //install seeed_arduino_RTC : https://github.com/Seeed-Studio/Seeed_Arduino_RTC
#include "DateTime.h"
#include <EnergySaving.h>
EnergySaving myPowSave;
RTC_SAMD21 myRtc;
#define PIN_LED 13
void setup()
{
myRtc.begin();
Serial.begin(115200);
pinMode(PIN_LED,OUTPUT);
digitalWrite(PIN_LED,HIGH);//LED off (active LOW)
myRtc.adjust(DateTime(2030, 4, 1, 8, 30, 0) );
myRtc.attachInterrupt(dummyfunc);
myPowSave.begin(WAKE_RTC_ALARM);
myRtc.disableAlarm();
DateTime timeNow = myRtc.now();
const uint16_t uiAlmNextSec = 10;
DateTime timeAlarm = DateTime(timeNow.year(), timeNow.month(), timeNow.day(), timeNow.hour(), timeNow.minute(), timeNow.second() + uiAlmNextSec);
myRtc.setAlarm(timeAlarm);
myRtc.enableAlarm(myRtc.MATCH_SS);
}
void loop()
{
for(uint16_t uilp=0; uilp<3; uilp++)
{
digitalWrite(PIN_LED,HIGH);
delay(1000);
digitalWrite(PIN_LED,LOW);
delay(1000);
}
digitalWrite(PIN_LED,HIGH);
myPowSave.standby();
//proceed after wakeup
}
void dummyfunc()
{}
@debungle-it
Copy link

Hi XIAO BLE Sense runs on a Nordic CPU core and throws
Arduino: 1.8.19 (Mac OS X), Board: "Seeed XIAO BLE Sense - nRF52840"

WARNING: library Seeed_Arduino_RTC claims to run on samd architecture(s) and may be incompatible with your current board which runs on nrf52 architecture(s).

@dzonesasaki
Copy link
Author

Sorry, I don't have any answers. The document for RTC of nRF52 is here.
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Frtc.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment