DS3231RTC Class Reference
DS3231RTC Class Reference
#include <DS3231RTC.h>
Returns true if the realtime clock is on the I2C bus; false if the time and date are simulated.
bool hasUpdates ()
Reads the current time from the realtime clock into value. More...
Reads the current date from the realtime clock into value. More...
Reads the details of the alarm with index alarmNum into value. More...
int readTemperature ()
Reads the value of the temperature sensor and returns the temperature in quarters of a degree
celcius. More...
void enableAlarmInterrupts ()
void disableAlarmInterrupts ()
int firedAlarm ()
Determines which of alarms 0 or 1 have fired since the last call. More...
void enable32kHzOutput ()
void disable32kHzOutput ()
Detailed Description
This class simplifies the process of reading and writing the time and date information in a DS3231 realtime
clock chip. The class also provides support for reading and writing information about alarms and other clock
settings.
If there is no DS3231 chip on the I2C bus, this class will fall back to the RTC class to simulate the current time
and date based on the value of millis().
Alarms 0 and 1 can be set to generate an interrupt when they fire using enableAlarmInterrupts().
The firedAlarm() function can be used to determine which alarm has fired.
The DS3231 uses a 2-digit year so this class is limited to dates between 2000 and 2099 inclusive.
The structure RTCAlarm is used to read and write the alarms. It has a flags field which is analogous to the
alarm mask bits found in the DS3231 manual. Bit 7 signals whether this is an alarm structure with settings for
alarm 0 or 1 (as these are different, see manual).
See Also
RTC, DS3232RTC, DS1307RTC
If oneHzPin is not 255, then it indicates a digital input pin that is connected to the 1 Hz square wave output on
the realtime clock. This input is used by hasUpdates() to determine if the time information has changed in a
non-trivial manner.
See Also
hasUpdates(), enableAlarmInterrupts()
void DS3231RTC::disable32kHzOutput ( )
See Also
enable32kHzOutput()
Parameters
void DS3231RTC::disableAlarmInterrupts ( )
See Also
enableAlarmInterrupts()
void DS3231RTC::enable32kHzOutput ( )
See Also
disable32kHzOutput()
Parameters
alarmNum The alarm to enable.
See Also
disableAlarm()
void DS3231RTC::enableAlarmInterrupts ( )
When the interrupt occurs, use firedAlarm() to determine which alarm has fired. The application is
responsible for implementing the interrupt service routine to watch for the interrupt.
Note: this function does nothing if the 1 Hz pin was enabled in the constructor, but firedAlarm() can still be
used to determine which alarm has fired when hasUpdates() reports that there is an update available.
See Also
disableAlarmInterrupts(), firedAlarm()
int DS3231RTC::firedAlarm ( )
Returns 0 if alarm 0 has fired, 1 if alarm 1 has fired, 2 if both alarms have fired, or -1 if neither alarm has fired.
The fired alarm state will be cleared, ready for the next call.
This function cannot be used to determine if alarms 2 or 3 have fired as they are stored in NVRAM and are
not handled specially by the DS3231.
See Also
enableAlarmInterrupts()
Reads the details of the alarm with index alarmNum into value.
Alarm details are stored at the end of the realtime clock's non-volatile memory.
See Also
writeAlarm(), alarmCount()
Reads the current date from the realtime clock into value.
The time should be read first with readTime() as the default implementation only advances the date when the
time is read and it crosses midnight.
See Also
writeDate(), readTime()
Reads the value of the temperature sensor and returns the temperature in quarters of a degree celcius.
Returns the value NO_TEMPERATURE if the realtime clock chip cannot determine the temperature.
Reads the current time from the realtime clock into value.
See Also
writeTime(), readDate()
Returns
Returns true if the alarm was set; false otherwise.
See Also
writeAlarm()
Updates the details of the alarm with index alarmNum from value.
Alarm details are stored at the end of the realtime clock's non-volatile memory.
See Also
readAlarm(), alarmCount()
See Also
readDate(), writeTime()
See Also
readTime(), writeDate()
DS3231RTC.h
DS3231RTC.cpp