ChronoDot V2 - Precision Real Time Clock Module RTC DS3231 I2C
-
RM18.00
- Product Code: DS3231 ChronoDot
- Availability: In Stock
The ChronoDot RTC is an extremely accurate real time clock module, based on the DS3231 temperature compensated RTC (TCXO). It includes a CR1632 battery, which should last at least 8 years if the I2C interface is only used while the device has 5V power available. No external crystal or tuning capacitors are required.
The top side of the Chronodot now features a battery holder for 16mm 3V lithium coin cells. It pairs particularly well with CR1632 batteries.
Features
Specifications
Package Include
Pin-out:
SCL - I2C clock pin, connect to your microcontrollers I2C clock line. This pin has a 10K pullup resistor to Vin
SDA - I2C data pin, connect to your microcontrollers I2C data line. This pin has a 10K pullup resistor to Vin
BAT - this is the same connection as the positive pad of the battery. You can use this if you want to power something else from the coin cell, or provide battery backup from a different seperate batery. VBat can be between 2.3V and 5.5V and the DS3231 will switch over when main Vin power is lost
32K - 32KHz oscillator output. Open drain, you need to attach a pullup to read this signal from a microcontroller pin
SQW - optional square wave or interrupt output. Open drain, you need to attach a pullup to read this signal from a microcontroller pin
RST - This one is a little different than most RST pins, rather than being just an input, it is designed to be used to reset an external device or indicate when main power is lost. Open drain, but has an internal 50K pullup. The pullup keeps this pin voltage high as long as Vin is present. When Vin drops and the chip switches to battery backup, the pin goes low
The sketch for this tutorial shows how to request time from the ChronoDot and display it over Serial.
RTClib.h
The libraries are needed for the ChronoDot: RTClib.h and Wire (Wire comes with the IDE).
Download the RTClib zip file, extract and if necessary rename to "RTClib" before moving a copy into /arduino-1.0.3/libraries/. Having the correct name is important.
Arduino Sketch
You can find an explanation for each part in the comments.
// Date and time functions using a DS3231 RTC connected via I2C and Wire Lib #include <Wire.h> #include "RTClib.h" // Credit: Adafruit RTC_DS1307 RTC; void setup() { // Begin the Serial connection Serial.begin(9600); // Instantiate the RTC Wire.begin(); RTC.begin(); // Check if the RTC is running. if (! RTC.isrunning()) { Serial.println("RTC is NOT running"); } // This section grabs the current datetime and compares it to // the compilation time. If necessary, the RTC is updated. DateTime now = RTC.now(); DateTime compiled = DateTime(__DATE__, __TIME__); if (now.unixtime() < compiled.unixtime()) { Serial.println("RTC is older than compile time! Updating"); RTC.adjust(DateTime(__DATE__, __TIME__)); } Serial.println("Setup complete."); } void loop() { // Get the current time DateTime now = RTC.now(); // Display the current time Serial.print("Current time: "); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); delay(10000); }
Tags: RTC