Skip to content

Commit cd38d7f

Browse files
committed
Add rtcTimeTemp example sketch.
1 parent f305352 commit cd38d7f

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Arduino DS3232RTC Library
2+
// https://github.com/JChristensen/DS3232RTC
3+
// Copyright (C) 2019 by Jack Christensen and licensed under
4+
// GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html
5+
//
6+
// Simple example sketch that should work on any architecture.
7+
// For the AVR architecture, instantiating the DS3232RTC object
8+
// is redundant, but this is only for testing purposes.
9+
//
10+
// Jack Christensen 24Sep2019
11+
12+
#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
13+
DS3232RTC myRTC;
14+
15+
void setup()
16+
{
17+
Serial.begin(115200);
18+
myRTC.begin();
19+
}
20+
21+
void loop()
22+
{
23+
display();
24+
delay(10000);
25+
}
26+
27+
// display time, date, temperature
28+
void display()
29+
{
30+
char buf[40];
31+
time_t t = myRTC.get();
32+
float celsius = myRTC.temperature() / 4.0;
33+
float fahrenheit = celsius * 9.0 / 5.0 + 32.0;
34+
sprintf(buf, "%.2d:%.2d:%.2d %.2d%s%d ",
35+
hour(t), minute(t), second(t), day(t), monthShortStr(month(t)), year(t));
36+
Serial.print(buf);
37+
Serial.print(celsius);
38+
Serial.print("C ");
39+
Serial.print(fahrenheit);
40+
Serial.println("F");
41+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DS3232RTC
2-
version=1.2.8
2+
version=1.2.9
33
author=Jack Christensen <jack.christensen@outlook.com>
44
maintainer=Jack Christensen <jack.christensen@outlook.com>
55
sentence=Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks.

0 commit comments

Comments
 (0)