Skip to content

Commit 3dda9bb

Browse files
committed
Add RTC get example
1 parent a107dea commit 3dda9bb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Breakout Carrier - BreakoutRTCGet
3+
4+
The sketch shows how to read the RTC of the PortentaH7 using the Breakout Carrier.
5+
6+
The circuit:
7+
- Portenta H7
8+
- BreakOut Carrier
9+
- CR2032 Battery
10+
11+
This example code is in the public domain.
12+
*/
13+
#include <Arduino_PortentaBreakoutCarrier.h>
14+
15+
Timestamp utcTime;
16+
17+
void setup() {
18+
Serial.begin(9600);
19+
while (!Serial);
20+
}
21+
22+
void loop() {
23+
// Read the current timestamp from the RTC
24+
utcTime = Breakout.RTClock.getTime();
25+
26+
// Print the data
27+
Serial.println(utcTime.getUnixTimestamp());
28+
Serial.print("year: ");
29+
Serial.println(utcTime.year() + 1900);
30+
Serial.print("month: ");
31+
Serial.println(utcTime.month() + 1);
32+
Serial.print("day: ");
33+
Serial.println(utcTime.day());
34+
Serial.print("hours: ");
35+
Serial.println(utcTime.hour());
36+
Serial.print("minutes: ");
37+
Serial.println(utcTime.minute());
38+
Serial.print("seconds: ");
39+
Serial.println(utcTime.second());
40+
41+
delay(1000);
42+
}

0 commit comments

Comments
 (0)