ArduinoLibs - DS3231RTC Class Reference
ArduinoLibs - DS3231RTC Class Reference
#include <DS3231RTC.h>
bool hasUpdates ()
Returns true if there are updates.
int readTemperature ()
Reads the value of the temperature sensor and returns the temperature in quarters of a
degree celcius. More...
void enableAlarmInterrupts ()
Enables the generation of interrupts for alarms 0 and 1. More...
void disableAlarmInterrupts ()
Disables the generation of interrupts for alarms 0 and 1. More...
https://rweather.github.io/arduinolibs/classDS3231RTC.html 1/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
int firedAlarm ()
Determines which of alarms 0 or 1 have fired since the last call. More...
void enable32kHzOutput ()
Enables the 32 kHz output on the DS3231 chip. More...
void disable32kHzOutput ()
Disables the 32 kHz output on the DS3231 chip. More...
Detailed Description
Communicates with a DS3231 realtime clock chip via I2C.
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 2digit 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 nontrivial manner.
See Also
hasUpdates(), enableAlarmInterrupts()
void DS3231RTC::disable32kHzOutput ( )
See Also
enable32kHzOutput()
Parameters
alarmNum The alarm to disable.
See Also
enableAlarm()
https://rweather.github.io/arduinolibs/classDS3231RTC.html 3/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
void DS3231RTC::disableAlarmInterrupts ( )
See Also
enableAlarmInterrupts()
void DS3231RTC::enable32kHzOutput ( )
See Also
disable32kHzOutput()
Parameters
alarmNum The alarm to enable.
See Also
disableAlarm()
https://rweather.github.io/arduinolibs/classDS3231RTC.html 4/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
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()
https://rweather.github.io/arduinolibs/classDS3231RTC.html 5/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
Reads the details of the alarm with index alarmNum into value.
Alarm details are stored at the end of the realtime clock's nonvolatile 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.
https://rweather.github.io/arduinolibs/classDS3231RTC.html 6/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
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 nonvolatile memory.
See Also
readAlarm(), alarmCount()
https://rweather.github.io/arduinolibs/classDS3231RTC.html 7/8
19/5/2016 ArduinoLibs: DS3231RTC Class Reference
See Also
readDate(), writeTime()
See Also
readTime(), writeDate()
The documentation for this class was generated from the following files:
DS3231RTC.h
DS3231RTC.cpp
https://rweather.github.io/arduinolibs/classDS3231RTC.html 8/8