-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Epoch Bug fixes * Added Examples
- Loading branch information
Showing
12 changed files
with
709 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
#include <Wire.h> | ||
#include <RTC.h> | ||
|
||
static DS3231 RTC; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
RTC.begin(); | ||
|
||
//RTC.stopClock(); | ||
|
||
Serial.print("Is Clock Running: "); | ||
if (RTC.isRunning()) | ||
{ | ||
Serial.println("Yes"); | ||
Serial.print(RTC.getDay()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getMonth()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getYear()); | ||
Serial.print(" "); | ||
Serial.print(RTC.getHours()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getMinutes()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getSeconds()); | ||
Serial.print(""); | ||
if (RTC.getHourMode() == CLOCK_H12) | ||
{ | ||
switch (RTC.getMeridiem()) { | ||
case HOUR_AM: | ||
Serial.print(" AM"); | ||
break; | ||
case HOUR_PM: | ||
Serial.print(" PM"); | ||
break; | ||
} | ||
} | ||
Serial.println(""); | ||
delay(1000); | ||
} | ||
else | ||
{ | ||
delay(200); | ||
|
||
Serial.println("No"); | ||
Serial.println("Setting Time"); | ||
RTC.setHourMode(CLOCK_H12); | ||
//RTC.setHourMode(CLOCK_H24); | ||
RTC.setDateTime(__DATE__, __TIME__); | ||
Serial.println("New Time Set"); | ||
Serial.print(__DATE__); | ||
Serial.print(" "); | ||
Serial.println(__TIME__); | ||
RTC.startClock(); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <Wire.h> | ||
#include <RTC.h> | ||
|
||
static DS3231 RTC; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
RTC.begin(); | ||
|
||
//RTC.setHourMode(CLOCK_H24); | ||
RTC.setHourMode(CLOCK_H12); | ||
|
||
//RTC.setEpoch(1622904335); | ||
} | ||
|
||
void loop() | ||
{ | ||
Serial.println(); | ||
Serial.print("UnixTime : "); | ||
Serial.println(RTC.getEpoch()); | ||
|
||
Serial.print(RTC.getDay()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getMonth()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getYear()); | ||
|
||
Serial.print(" "); | ||
|
||
Serial.print(RTC.getHours()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getMinutes()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getSeconds()); | ||
Serial.print(" "); | ||
|
||
if (RTC.getHourMode() == CLOCK_H12) | ||
{ | ||
if(RTC.getMeridiem() == HOUR_AM) | ||
Serial.println(" AM"); | ||
if (RTC.getMeridiem() == HOUR_PM) | ||
Serial.println(" PM"); | ||
} | ||
|
||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <Wire.h> | ||
#include <RTC.h> | ||
|
||
static PCF8563 RTC; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
RTC.begin(); | ||
|
||
//RTC.setEpoch(0); | ||
} | ||
|
||
void loop() | ||
{ | ||
Serial.print("UnixTime : "); | ||
Serial.println(RTC.getEpoch()); | ||
|
||
Serial.print(RTC.getDay()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getMonth()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getYear()); | ||
|
||
Serial.print(" "); | ||
|
||
Serial.print(RTC.getHours()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getMinutes()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getSeconds()); | ||
Serial.println(" "); | ||
|
||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <Wire.h> | ||
#include <RTC.h> | ||
|
||
static PCF8563 RTC; | ||
|
||
void setup() { | ||
|
||
Serial.begin(9600); | ||
RTC.begin(); | ||
|
||
/* | ||
RTC.setDay(13); | ||
RTC.setMonth(05); | ||
RTC.setYear(2020); | ||
RTC.setWeek(7); // Always Set weekday after setting Date | ||
RTC.setHours(9); | ||
RTC.setMinutes(47); | ||
RTC.setSeconds(56); | ||
*/ | ||
|
||
RTC.setDate(05, 06, 25); //SetDate(Day,Month,Year) | ||
RTC.setTime(12, 14, 00); //SetTime(Hours,Minutes,Seconds) | ||
RTC.setWeek(7); // Always Set weekday after setting Date | ||
|
||
//RTC.setEpoch(0); | ||
} | ||
|
||
void loop() { | ||
switch (RTC.getWeek()) { | ||
case 1: | ||
Serial.print("SUN"); | ||
break; | ||
case 2: | ||
Serial.print("MON"); | ||
break; | ||
case 3: | ||
Serial.print("TUE"); | ||
break; | ||
case 4: | ||
Serial.print("WED"); | ||
break; | ||
case 5: | ||
Serial.print("THU"); | ||
break; | ||
case 6: | ||
Serial.print("FRI"); | ||
break; | ||
case 7: | ||
Serial.print("SAT"); | ||
break; | ||
} | ||
Serial.print(" "); | ||
Serial.print(RTC.getDay()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getMonth()); | ||
Serial.print("-"); | ||
Serial.print(RTC.getYear()); | ||
|
||
Serial.print(" "); | ||
|
||
Serial.print(RTC.getHours()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getMinutes()); | ||
Serial.print(":"); | ||
Serial.print(RTC.getSeconds()); | ||
Serial.print(" "); | ||
|
||
Serial.println(""); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=RTC | ||
version=1.0.1 | ||
version=1.0.2 | ||
author=Manjunath CV | ||
maintainer=Manjunath CV <[email protected]> | ||
sentence=Library for I2C based RTCs (DS1307, DS3231, PCF8563). | ||
|
Oops, something went wrong.