How to Use DS1307 Using Arduino

by MrSottong in Circuits > Arduino

1901 Views, 2 Favorites, 0 Comments

How to Use DS1307 Using Arduino

IMG_6911.JPG
IMG_6912.JPG

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:

Connect DS1307 to Arduino

Skema.png
photo_2019-09-09_21-13-39.jpg

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.

Add the DS1307RTC Library

ADD LIB 1.png
ADD LIB 2.png
image6664.png

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.

Choose Arduino Board

board.png

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

Board "Arduino Nano"

Proccesor: "ATmega328P (Old Bootloader)"

SetTime Sketch

SET TIME.png
Untitled.png

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.

ReadTest Sketch

reat test.png

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.

Result

hasil benar.png
gagal baca.png

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.

Other Articel About RTC

IMG_6907.JPG
IMG_6915.JPG

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.