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.
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
Download the library here.
Time setting code:
DS3231 rtc(SDA, SCL);
// 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)
Serial time tracking code:
DS3231 rtc(SDA, SCL);
// do not forget to set the BAUD rate to 115200 in Serial Monitor
// shows the day of the week
// shows the date
" -- "
// shows the time
// pause 1s
Products used in this tutorial
No products found