Main Content

Interface DS1307 RTC Module With Arduino  Display Date/Time on OLED

In this tutorial, we will explore how to interface the DS1307 RTC module with an Arduino UNO. We will begin by addressing several key questions: What exactly is an RTC (Real-time clock)? Why is an RTC module used? How does an RTC module communicate with Arduino through the I2C communication bus? Additionally, we will delve into the process of creating a digital clock using Arduino and the DS1307 RTC module. In the second part of the tutorial, we will cover the pinout and pin configuration details, as well as the circuitry required for interfacing the module with Arduino. Finally, we will provide an example code to further illustrate the concepts discussed.

- Arduino UNO
- DS1307 RTC
- OLED module
- Breadboard
- Jumper Wire

Step 1: What Is RTC or Real Time Clock?
As the name implies, a real-time clock is employed to accurately keep track of time and display it. It finds applications in various digital electronic devices such as computers, digital smartwatches, and data loggers, as well as situations where precise timekeeping is essential. One of the significant advantages of a real-time clock is its ability to continue keeping track of time even when the power supply is unavailable or interrupted.

The operation of an electronic device like a real-time clock without a continuous power supply is made possible through the use of small coin-sized lithium coin cells. These cells, typically CR2032, are capable of providing power to the RTC module for extended periods, often spanning several years. By utilizing these long-lasting coin cells, RTC modules can maintain their functionality and keep accurate time even when the primary power source is disconnected or unavailable.

Step 2: DS1307 RTC IC
The DS1307 RTC module is centered around an 8-pin DS1307 chip, which serves as the core component. This chip provides the functionality of a real-time clock, enabling the tracking of seconds, minutes, hours, days, months, and years. To communicate with other devices, such as Arduino in our case, the DS1307 utilizes the I2C communication protocol. Arduino reads the time and date values from the DS1307 module by utilizing this I2C communication protocol.

Additionally, the DS1307 module features a backup battery system, which allows it to retain the accurate time even in the event of a power failure. This backup battery ensures that the real-time clock remains functional and continues to keep track of time, providing a reliable timekeeping solution. Consequently, this module can be effectively used in conjunction with other electronic components to create a fully functional real-time clock.

The following figure shows the pinout diagram of DS1307 IC.

Now let’s see the functionality of each pin one by one.

X1 and X2 are used for crystal oscillators. The crystal oscillator value usually used with DS1307 is 32.768k Hz.
VBAT: Connect a CR2032 coil cell as backup power. Its value should be between 3-5 volt. voltage more than 5 volts may burn DS1307 permanently. A backup battery is used to keep track of time in case of power failure.
Vcc and GND are power supply pins
SDA and SCL are used to communicate with other devices over of I2C communication bus.
SQW pin provides square waves of different frequencies such as 1Hz, 4kHz, 8kHz, or 32kHz. The frequency of output wave can be selected by sending a signal to DS1307 over an I2C bus.
If you want to use this IC directly with Arduino, you need to use external components to connect with DS1307. The following circuit diagram shows the connections of all required components with DS1306:

Instead of going through the process of using the DS1307 chip alone and designing your own PCB, you have the option to acquire a readily available DS1307 RTC module at a significantly low cost. These modules come pre-assembled and provide a convenient and affordable solution for incorporating real-time clock functionality into your projects. By opting for a ready-to-use RTC module, you can save time and effort in the development process while still enjoying the benefits of accurate timekeeping.”

Link to article