Introduction: How to Use DS1307 Using Arduino

About: someone who likes electronics

DS1307 is a Real Time Clock IC (RTC). This IC is used to provide time data. The time allotted starts from Seconds, Minute, Hours, Days, Date, Month, and Year.

This IC requires additional external components such as Crystal and 3.6V Batteries. Crystal is used for clock sources. Batteries are used for backup energy so that the time function is not stopped when the main supply is cut off.

I suggest to buy a DS1307 module that has been equipped with external components.

Components needed:

Library used:

Step 1: Connect DS1307 to Arduino

Connect DS1307 to Arduino Nano according to the picture or table below.

DS1307 to Arduino Nano

VCC ==> +5V

GND ==> GND

SCL ==> A5

SDA ==> A4

DS ==> NC

Then, connect Arduino to the Laptop / PC using Mini USB.

Step 2: Add the DS1307RTC Library

The DS1307 library can be downloaded here:

Library DS1307

After the download is complete,

Open "Skecth ==> Include Library ==> add .ZIp Library"

Find the library file that has been downloaded.

If it is successful, close Arduino and open it again.

Step 3: Choose Arduino Board

Open the tools and select the Arduino board according to the picture above.

Board "Arduino Nano"

Proccesor: "ATmega328P (Old Bootloader)"

Step 4: SetTime Sketch

There are two sketches that will be used. The first sketch is "SetTime" used to set the time on DS1307 to match the current time. the second is "ReadTest" used to display the time count.

Upload SetTime :

Open File > Examples > DS1307RTC > SetTime

After Sketch is open click upload and wait for a few moments.

If the upload process is complete, open the Serial Monitor to see the time set.

Step 5: ReadTest Sketch

Upload Sketch "ReadTes" to execute timed function.

Open File > Examples > DS1307RTC > ReadTest

Click upload and wait a few moments. After the upload process is complete open the serial monitor to see the results.

Step 6: Result

If successful, the serial monitor will display as shown in Figure 1.

If the DS1307 Module is not installed or not connected to an Arduino board, the serial monitor will display as shown in Figure 2.

Step 7: Other Articel About RTC

You can use the LCD or 7-Segment Module to display the time generated by the RTC.

If you don't know how to use it, you can see my next article on "How to display time on the LCD" or "How to display time in the 7-Segment Module" in my next article.

Thank you for reading this article, hopefully it's useful.

If there are questions, just write in the comments column.