HOME    PROJECTS    LIBRARIES    RESOURCES    LINKS    CONTACT  
Select category:
Arduino
  DS1302
  DS1307
  DS3231
  DS3234
  KeyPad
  LCD5110_Basic
  LCD5110_Graph
  LCD5110_SPIflash
  LEDmatrix7219
  MCP4725
  MGLCD
  OLED_I2C
  OLED_SPIflash
  OLED_StatusIcons
  relay8
  SPIflash
  tinyFAT
  URTouch
  UTFT
  UTFT_Buttons
  UTFT_Geometry
  UTFT_SPIflash
  UTFT_tinyFAT
  WiiChuck
chipKit
TI LaunchPad

IF YOU LIKE,
and use any of my projects or libraries, and would like to encourage further development you can donate through PayPal here:

Rather donate hardware directly? Then click here.




Library: DS3231

This library has been made to easily interface and use the DS3231 RTC with an Arduino or chipKit. The library will also work with the DS3232 RTC chip but you will not be able to use the internal SRAM.

DS3231DS3231 pinoutDS3231 connection example

The DS3231 is a low-cost, extremely accurate I2C realtime clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line. The DS3231 is available in commercial and industrial temperature ranges, and is offered in a 16-pin, 300-mil SO package.

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. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially through an I2C bidirectional bus.

A precision temperature-compensated voltage reference and comparator circuit monitors the status of VCC to detect power failures, to provide a reset output, and to automatically switch to the backup supply when necessary. Additionally, the RST pin is monitored as a pushbutton input for generating a μP reset.

Please note that this library only makes use of the 24-hour format, and that alarms are not implemented.

 IMPORTANT: 

The library has not been tested in combination with the Wire library and I have no idea if they can share pins. Do not send me any questions about this. If you experience problems with pin-sharing you can move the DS3231/DS3232 SDA and SCL pins to any available pins on your development board. This library will in this case fall back to a software-based, TWI-/I2C-like protocol which will require exclusive access to the pins used.

Download:

DS3231.zip
(Filesize is 378.70 KiB. Downloaded 58313 times)


Some demos are included to demonstrate most of the functions.
This is a multi-platform library that will work with several different development board types.

Changes:
v1.017 Aug 2014initial release
v1.0125 Aug 2014small bugfix

Nice to know:

This library will default to I2C Fast Mode (400 KHz) when using the hardware I2C interface.

I highly recommend using the DS3231 (or DS3232) instead of the DS1307. While the DS3231/DS3232 may be slightly more expensive than the DS1307 it is much more accurate due to the internal TCXO (temperature-compensated crystal oscillator) and crystal. This also means that you don’t have to use an external crystal like you have to with the DS1307.

Datasheet:

CLICK HERE TO VIEW

Compatibility:

WorkingArduino Duemilanove w/ATmega328
WorkingArduino Uno
WorkingArduino Leonardo
WorkingArduino Mega
WorkingArduino Mega2560
WorkingArduino Due
WorkingBobuino
Not tested, UnsupportedTeensy 3.1
Working = Working   Not working: Not working
Not tested, Unsupported = Not tested, Unsupported

Manual:

CLICK HERE TO VIEW
The manual is included in the download

License:

By downloading the library you accept the following license:
Creative Commons BY-NC-SA Logo
Creative Commons (CC BY-NC-SA 3.0)
View SummaryView Legal