HUM: RTC – REAL TIME CLOCK DS1307

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.
WHAT IS RTC?
Real-Time Clock is an electronic device which closely monitors time. In this tutorial we will deal with a newer DS3231SN.
RTC modules mainly use 32.768 kHz frequency crystal oscillator, which is also used in quartz watches. In comparison to the DS1307, the model DS3231 has a built-in TCXO (Temperature Compensated Crystal Oscillator), which brings stability that could not be achieved with a regular oscillator, while changing temperature. Together, they make up a whole which allows long-term and precise time monitoring.
Characteristics:
Voltage:Â 3.3V – 5.5V
Current:Â 170uAÂ (stand-by 5.5V)
Communication:Â 400kHz I2CÂ (default address 0x68)
Temperature: -40°C do +85°C (for the SN model which is on the breakout in our offer)
Dimensions:Â 38mm x 22mm x 14mm
WHAT, AND HOW DOES IT WORK ?
RTC follows seconds, minutes, hours, days of the week, date: days of the month, months and years. Once we set the time we can follow the calendar up until 2100. This means that the date at the end of the month is automatically transferred, the same goes for the leap years. The clock works in both 24 and 12 hour format, and two programmable alarms are installed. The module and controller are connected via two-way I2C communication. All you need for this communication is on the breakout. If you have the need to change the I2C address, you can do this by connecting the A0, A1 and A2 falls to the breakout of the module.
The battery is used with the module for the purpose of preserving the set time. When the system within the DS3231 detects that a permanent power supply is interrupted, it is switched to the battery. The battery corresponding to the breakout is CR2032, and its capacity is 240mAh. The same thing is automatically done in the opposite direction.
CONNECTING IT TO DASDUINO
ARDUINO CODE
Download the library here.
Time setting code:
#include "DS3231.h"
DS3231Â rtc(SDA, SCL);
void
setup
()
{
 Â
rtc.begin();
 Â
 Â
rtc.setDOW(WEDNESDAY);Â Â Â Â
// set the day of the week
 Â
rtc.setTime(9, 17, 0);Â Â Â Â
// set the time, 24h format (hour, minute, second)
 Â
rtc.setDate(17, 2, 2016);Â
// set the date (day, month, year)
}
void
loop
()
{
}
Serial time tracking code:
Products used in this tutorial
No products found