Skip to content

Commit 6ae1208

Browse files
committed
Create Example1_Get_Time.ino
1 parent 69cc615 commit 6ae1208

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Author: Nathan Seidle
2+
Created: Septempter 27th, 2019
3+
License: MIT. See SparkFun Arduino Apollo3 Project for more information
4+
5+
This example demonstrates how to initialize and read from the on board RTC.
6+
Most SparkFun Artemis boards have the necessary external 32kHz crystal to
7+
enable the RTC. If you are using the Artemis module bare you will either
8+
need an external 32kHz xtal or use the internal LFRC. Read the datasheet
9+
section 12.1 for more information.
10+
11+
This example is based on the Ambiq SDK EVB2 RTC example.
12+
*/
13+
14+
#include "RTC.h" //Include RTC library included with the Aruino_Apollo3 core
15+
APM3_RTC myRTC; //Create instance of RTC class
16+
17+
void setup()
18+
{
19+
Serial.begin(115200);
20+
Serial.println("SparkFun RTC Example");
21+
22+
myRTC.setToCompilerTime(); //Easily set RTC using the system __DATE__ and __TIME__ macros from compiler
23+
//myRTC.setTime(0, 51, 28, 7, 21, 10, 15); //Manually set RTC back to the future: Oct 21st, 2015 at 7:28.51 AM
24+
}
25+
26+
void loop()
27+
{
28+
myRTC.getTime();
29+
30+
Serial.printf("It is now ");
31+
Serial.printf("%d:", myRTC.hour);
32+
Serial.printf("%02d:", myRTC.minute);
33+
Serial.printf("%02d.", myRTC.seconds);
34+
Serial.printf("%02d", myRTC.hundredths);
35+
36+
Serial.printf(" %02d/", myRTC.month);
37+
Serial.printf("%02d/", myRTC.dayOfMonth);
38+
Serial.printf("%02d", myRTC.year);
39+
40+
Serial.printf(" Day of week: %d =", myRTC.weekday);
41+
Serial.printf(" %s", myRTC.textWeekday);
42+
43+
Serial.println();
44+
45+
delay(1000);
46+
}

0 commit comments

Comments
 (0)