Skip to content

Commit

Permalink
Rename files to match library rename
Browse files Browse the repository at this point in the history
goertzel committed Mar 15, 2019
1 parent 1d47b1a commit 36cd1ad
Showing 5 changed files with 70 additions and 65 deletions.
2 changes: 1 addition & 1 deletion RTClibExtended.cpp → OPEnS_RTC.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
// Released to the public domain! Enjoy!

#include <Wire.h>
#include "RTClibExtended.h"
#include "OPEnS_RTC.h"
#ifdef __AVR__
#include <avr/pgmspace.h>

File renamed without changes.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# FabioCuomo-DS3231
# OPEnS_RTC-DS3231-PCF8523
A fork of https://github.com/FabioCuomo/FabioCuomo-DS3231 with added support for PCF8523 interrupts by incorporating [radikalbytes](https://github.com/radikalbytes) [PCF8523 library](https://github.com/radikalbytes/PCF8523).



A modified arduino library for DS3231 RTC

This is a fork of the Adafruit library https://github.com/adafruit/RTClib, which I extended for DS3231 only by integrating some additional commands found in Jack Christensen's library https://github.com/JChristensen/DS3232RTC.
115 changes: 58 additions & 57 deletions examples/wakeup_alarm/wakeup_alarm.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <Wire.h>
#include <RTClibExtended.h>
#include <OPEnS_RTC.h>
#include <LowPower.h>

#define wakePin 2 //use interrupt 0 (pin 2) and run function wakeUp when pin 2 gets LOW
#define ledPin 13 //use arduino on-board led for indicating sleep or wakeup status

RTC_DS3231 RTC; //we are using the DS3231 RTC
RTC_DS3231 RTC_Inst; //we are using the DS3231 RTC

byte AlarmFlag = 0;
byte ledStatus = 1;
@@ -19,66 +19,67 @@ void wakeUp() // here the interrupt is handled after wakeup
//------------------------------------------------------------

void setup() {
//Set pin D2 as INPUT for accepting the interrupt signal from DS3231
pinMode(wakePin, INPUT);

//switch-on the on-board led for 1 second for indicating that the sketch is ok and running
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
delay(1000);

//Initialize communication with the clock
Wire.begin();
RTC.begin();
RTC.adjust(DateTime(__DATE__, __TIME__)); //set RTC date and time to COMPILE time
//clear any pending alarms
RTC.armAlarm(1, false);
RTC.clearAlarm(1);
RTC.alarmInterrupt(1, false);
RTC.armAlarm(2, false);
RTC.clearAlarm(2);
RTC.alarmInterrupt(2, false);

//Set SQW pin to OFF (in my case it was set by default to 1Hz)
//The output of the DS3231 INT pin is connected to this pin
//It must be connected to arduino D2 pin for wake-up
RTC.writeSqwPinMode(DS3231_OFF);

//Set alarm1 every day at 18:33
RTC.setAlarm(ALM1_MATCH_HOURS, 33, 18, 0); //set your wake-up time here
RTC.alarmInterrupt(1, true);
//Set pin D2 as INPUT for accepting the interrupt signal from DS3231
pinMode(wakePin, INPUT);

//switch-on the on-board led for 1 second for indicating that the sketch is ok and running
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
delay(1000);

//Initialize communication with the clock
Wire.begin();
RTC_Inst.begin();
RTC_Inst.adjust(DateTime(__DATE__, __TIME__)); //set RTC date and time to COMPILE time
//clear any pending alarms
RTC_Inst.armAlarm(1, false);
RTC_Inst.clearAlarm(1);
RTC_Inst.alarmInterrupt(1, false);
RTC_Inst.armAlarm(2, false);
RTC_Inst.clearAlarm(2);
RTC_Inst.alarmInterrupt(2, false);

//Set SQW pin to OFF (in my case it was set by default to 1Hz)
//The output of the DS3231 INT pin is connected to this pin
//It must be connected to arduino D2 pin for wake-up
RTC_Inst.writeSqwPinMode(DS3231_OFF);

//Set alarm1 every day at 18:33
RTC_Inst.setAlarm(ALM1_MATCH_HOURS, 33, 18, 0); //set your wake-up time here
RTC_Inst.alarmInterrupt(1, true);
}

//------------------------------------------------------------

void loop() {

//On first loop we enter the sleep mode
if (AlarmFlag == 0) {
attachInterrupt(0, wakeUp, LOW); //use interrupt 0 (pin 2) and run function wakeUp when pin 2 gets LOW
digitalWrite(ledPin, LOW); //switch-off the led for indicating that we enter the sleep mode
ledStatus = 0; //set the led status accordingly
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); //arduino enters sleep mode here
detachInterrupt(0); //execution resumes from here after wake-up

//When exiting the sleep mode we clear the alarm
RTC.armAlarm(1, false);
RTC.clearAlarm(1);
RTC.alarmInterrupt(1, false);
AlarmFlag++;
}

//cycles the led to indicate that we are no more in sleep mode
if (ledStatus == 0) {
ledStatus = 1;
digitalWrite(ledPin, HIGH);
}
else {
ledStatus = 0;
digitalWrite(ledPin, LOW);
}

delay(500);
//On first loop we enter the sleep mode
if (AlarmFlag == 0) {
attachInterrupt(0, wakeUp, LOW); //use interrupt 0 (pin 2) and run function wakeUp when pin 2 gets LOW
digitalWrite(ledPin, LOW); //switch-off the led for indicating that we enter the sleep mode
ledStatus = 0; //set the led status accordingly
// LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); //arduino enters sleep mode here
LowPower.standby();
detachInterrupt(0); //execution resumes from here after wake-up

//When exiting the sleep mode we clear the alarm
RTC_Inst.armAlarm(1, false);
RTC_Inst.clearAlarm(1);
RTC_Inst.alarmInterrupt(1, false);
AlarmFlag++;
}

//cycles the led to indicate that we are no more in sleep mode
if (ledStatus == 0) {
ledStatus = 1;
digitalWrite(ledPin, HIGH);
}
else {
ledStatus = 0;
digitalWrite(ledPin, LOW);
}

delay(500);
}

12 changes: 6 additions & 6 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=RTClibExtended
name=OPEnS_RTC
version=1.0.0
author=FabioCuomo
maintainer=FabioCuomo
sentence=A fork of Adafruit RTC library and Jack Christensen's library
paragraph=A fork of Adafruit RTC library and Jack Christensen's library
author=OPEnS
maintainer=OPEnS
sentence=A fork of FabioCuomo-DS3231 and Adafruit RTC library and Jack Christensen's library
paragraph=A fork of FabioCuomo-DS3231 and Adafruit RTC library and Jack Christensen's library
category=Timing
url=https://github.com/FabioCuomo/FabioCuomo-DS3231/
url=https://github.com/OPEnSLab-OSU/OPEnS_RTC
architectures=*

0 comments on commit 36cd1ad

Please sign in to comment.