Seeed Arduino RTC is a Arduino library for RTC Moudle. At present, samd21 is supported and samd51 has built-in RTC module.
please refer here.
#include "RTC_SAMD21.h"
#include "DateTime.h"
RTC_SAMD21 rtc;
void setup()
{
rtc.begin();
Serial.begin(115200);
while (!Serial)
{
;
}
DateTime now = DateTime(F(__DATE__), F(__TIME__));
Serial.println("adjust time!");
rtc.adjust(now);
now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
void loop()
{
now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
- begin(void) : bool
rtc.begin()
- now(void) : DateTime
DateTime now = rtc.now();
- adjust(const DateTime) : void
DateTime now = DateTime(F(__DATE__), F(__TIME__));
rtc.adjust(now);
DateTime now = DateTime(2020, 7, 15, 0, 0, 0);
rtc.adjust(now);
- setAlarm(const DateTime) : void
DateTime alarm = DateTime(2020, 7, 15, 18, 0, 0);
rtc.setAlarm(now);
- alarm(void) : DateTime
DateTime now = rtc.alarm();
- disableAlarm(uint8_t) : void
rtc.disableAlarm(0);
- enableAlarm(uint8_t) : void
rtc.enableAlarm(0);
- attachInterrupt(rtcCallBack) : void
rtc.attachInterrupt(rtcCallBack);
- detachInterrupt(void) : void
rtc.detachInterrupt();
This software is written by seeed studio
and is licensed under The MIT License. Check License.txt for more information.
Contributing to this software is warmly welcomed. You can do this basically by
forking, committing modifications and then pulling requests (follow the links above
for operating guide). Adding change log and your contact into file header is encouraged.
Thanks for your contribution.
Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
Benefiting from local manufacture power and convenient global logistic system,
we integrate resources to serve new era of innovation. Seeed also works with
global distributors and partners to push open hardware movement.