Arduino library for the DS3231 real-time clock (RTC). Abstracts functionality for clock reading, clock setting, and alarms for the DS3231 high-precision real-time clock. This is a splice of Ayars' and Jeelabs/Ladyada's libraries.
- In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries
- Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
- Then search for DS3231 using the search bar.
- Click on the text area and then select the specific version and install it.
- Navigate to the Releases page.
- Download the latest release.
- Extract the zip file
- In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library
This library depends on the wire header file. To use this library functions, the user has to include wire.h (header) file.
-
DS3231 library has a very easy to use interface
-
DS3231 is a low-cost module
-
DS3231 is an extremely accurate I2C realtime clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal.
-
The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.
-
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year.
- date2days()
- time2long()
- conv2d()
- unixtime()
- bcd2bin()
- bin2bcd()
- now()
- getSecond()
- getMinute()
- getHour()
- getDoW()
- getDate()
- getMonth()
- getYear()
- setSecond()
- setMinute()
- setHour()
- setDoW()
- setDate()
- setMonth()
- setYear()
- setClockMode()
- getTemperature()
- getA1Time()
- getA2Time()
- setA1Time()
- setA2Time()
- turnOnAlarm()
- turnOffAlarm()
- checkAlarmEnabled()
- checkIfAlarm()
- enableOscillator()
- enable32kHz()
- oscillatorCheck()
- decToBcd()
- bcdToDec()
- readControlByte()
- writeControlByte()
There are many examples implemented where this library is used. You can find other examples from Github-DS3231
-
Test/demo of oscillator routines for a DS3231 RTC.
#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;
byte j;
bool on = false;
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
for (j=0;j<4;j++) {
on = !on;
Clock.enable32kHz(on);
Clock.enableOscillator(true, false, j);
delay(4000);
}
}
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell others about this library
- Contribute new protocols
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
The authors of this library are A. Wickert [email protected], E. Ayars, J. C. Wippler, N. W. LLC [email protected] and it is maintained by A. Wickert. This library is released into the public domain by Jeelabs, Ladyada, and E. Ayar.
Based on previous work by:
- S. T. Andersen
- SimGas
- Per1234
- Glownt
DS3231 is licensed under The Unlicense.