ds1307 rtc module

DS1307 RTC Module With Arduino | Arduino clock project

Arduino Tutorial


Hey geeks, welcome back to Techatronic. We are sure that you all have seen analog clocks near you all which tells us time but from these clocks, a machine cant read the time.

For reading the time a machine required a clock that generates output data in machine language. In this article, we are going to discuss the working of a DS1307 RTC module with Arduino.

DS1307 RTC

Basically, Arduino is a microcontroller development board that operates using ATmega328p ic. You can check more similar projects on Arduino and also check out our E-book on Arduino at once

which contains 10+ projects with well-label diagrams. We have also made a Digital clock with an LCD display and a Digital clock with a 4-digits display previously,

you can check both of them if you want. Complete the connections first and then upload the given code.

How Does it Work? / Working

  • We are using a DS1307 RTC module in which RTC stands for Real-Time Clock.
  • The images of the RTC module we are using are also provided below.
  • You can open the serial monitor from the top right-hand side on your Arduino IDE application as shown below.
  • We are using four of its pins, two for power(GND and VCC) and two for data(SDA and SCL).
  • The RTC module is used for remembering the date and the time.

in this Arduino clock project,

  • It comes with an inbuilt battery which helps it to keep working in the absence of external power.
  • The inbuilt battery has a very long life span.
  • We are displaying the day, date, and time on the Serial monitor which automatically keeps updating after a regular interval of time.
  • You can make various projects from it which deal with data-logging, time stamping, clock-building, real-world time.


ds1307 rtc module
ds1307 rtc module

Components Required

  • Arduino UNO
  • USB cable for uploading the code
  • DS1307 RTC module
  • Breadboard
  • Jumper wires

Components Table / Buy Link

You can buy the whole components from the given link we have to share the amazon link. from where you can get a good discount on the components.

S.NoComponent RequiredQuantityBuy Link
1.Arduino UNO1https://amzn.to/3ue2vmh
2.Arduino UNO Cable1https://amzn.to/3obXjht
3DS1307 RTC Module1https://amzn.to/2WC50SW
4.Jumper Wire40https://amzn.to/39q43jr

Circuit Diagram for the Project

ds1307 rtc module

Connection Table

Arduino UNODS1307 RTC Module
( +5V ) VCC
A4 Pin  ( SDA )SDA Pin
A5 Pin  ( SCL )SCL Pin
  • You have to make the connections according to the circuit diagram given above.
  • You can power the Arduino by using a USB cable or battery.
  • Use the breadboard for making connections.
  • Connect the 5-volts pin of the Arduino to the VCC of the DS1307 RTC module.
  • Attach the GND pin of the Arduino with the GND pin of the RTC module.
  • Join the analog-4 pin of the Arduino with the SDA pin of the RTC module.
  • Connect the analog-5 pin of the Arduino to the SCL pin of the RTC module as shown in the diagram.

Code for the Project

NOTE: Please upload the code which is given below to the Arduino. Before uploading you have to install <RTClib.h> and <Wire.h> libraries first. Check here how to install zip libraries to the Arduino IDE.

  // https://github.com/adafruit/RTClib  
 #include <Wire.h>  
 #include "RTClib.h"  
 RTC_DS1307 rtc;  
 char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};  
 void setup () {  
  while (!Serial); // for Leonardo/Micro/Zero  
  if (! rtc.begin()) {  
   Serial.println("Couldn't find RTC");  
   while (1);  
  if (! rtc.isrunning()) {  
   Serial.println("RTC is NOT running!");  
   // following line sets the RTC to the date & time this sketch was compiled  
   // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));  
   // This line sets the RTC with an explicit date & time, for example to set  
   // January 21, 2014 at 3am you would call:  
    //rtc.adjust(DateTime(2019, 3, 3, 20, 0, 0));  
   //rtc.adjust(DateTime(2019, 3, 3, 20, 0, 0));  
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));  
 void loop () {  
   DateTime now = rtc.now();  
   Serial.print(now.year(), DEC);  
   Serial.print(now.month(), DEC);  
   Serial.print(now.day(), DEC);  
   Serial.print(" (");  
   Serial.print(") ");  
   Serial.print(now.hour(), DEC);  
   Serial.print(now.minute(), DEC);  
   Serial.print(now.second(), DEC);  
   Serial.print(" since midnight 1/1/1970 = ");  
   Serial.print("s = ");  
   Serial.print(now.unixtime() / 86400L);  
   // calculate a date which is 7 days and 30 seconds into the future  
   DateTime future (now + TimeSpan(7,12,30,6));  
   Serial.print(" now + 7d + 30s: ");  
   Serial.print(future.year(), DEC);  
   Serial.print(future.month(), DEC);  
   Serial.print(future.day(), DEC);  
   Serial.print(' ');  
   Serial.print(future.hour(), DEC);  
   Serial.print(future.minute(), DEC);  
   Serial.print(future.second(), DEC);  

The Final Project Looks Like This

ds1307 rtc module

We hope that you learn the interfacing of a DS1307 RTC module with Arduino and please try to make the project on your own.

If you are facing any errors during making this please inform us in the comments section below. Also, check more tutorials on Arduino and Raspberry Pi written by us.


Video Sample

Spread the love, Share this post with friends

Leave a Reply

Your email address will not be published. Required fields are marked *