It is very easy to make a clock using Arduino or ESP8266. We can make Wi-Fi clock using ESP which will directly set the time according to the time zones. But Arduino doesn’t have this type of support. Once the power got disconnected it will restart the system from beginning. But RTC (real time clock) is very helpful in making such projects. So today, we will have a look on RTC modules and finish our clock project with it. We will design the code such that RTC will auto pick-up time from sketch uploading device. No need to adjust the time using external tactile switches.

I am using JLCPCB PCB prototype service since 2021. You will get 5 pcs of quality boards just in $2. And if you sign-up using this link you will get free coupons of worth $30. Checkout to JLCPCB now and get amazing discounts on first order.

RTC(Real time clock):

Real-time clocks (RTC), as the name recommends are clock modules. The DS1307 real-time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a low-power clock/calendar with 56 bytes of battery backup SRAM. The clock/calendar provides seconds, minutes, hours, day, date, month and year qualified data. The end date of each month is automatically adjusted, especially for months with less than 31 days.

They are available as integrated circuits (ICs) and supervise timing like a clock and also operate date like a calendar. The main advantage of RTC is that they have an arrangement of battery back up which keeps the clock/calendar running even if there is a power failure. An exceptionally little current is required for keeping the RTC animated. We can find these RTCs in many applications like embedded systems and computer motherboards, etc. In this article, we are going to see one of the real-time clock (RTC), i.e. DS1307.

Features :

Two-wire I2C interface.

· Hour: Minutes: Seconds AM/PM.

· Day Month, Date – Year.

· DS1307 based RTC with LIR2032 battery (Battery include).

· 1Hz output pin.

· Consumes less than 500nA in battery backup mode with oscillator running

· Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to 2100

· 56-byte non-volatile RAM for data storage

· 56 Bytes of Non-volatile memory available to the user.

· The DS1307 is accessed via the I2C protocol.

· The module comes fully assembled and pre-programmed with the current time.

Components required:

1) DS1307 RTC

2) OLED Display

3) Arduino UNO/NANO

4) Breadboard or Custom PCB

5) Power supply and wires

Circuit diagram:

Both LCD and RTC are connected through Inter integrated circuit protocol, having different address for both. SDA pin is data pin which is connected to A4 of Arduino and SCL is clock signal connected to A5. Circuit can be supplied using 5volts @250mA.

I am using Cirkit designer software for my Arduino projects, now it comes with inbuilt code compilation option. So you can try that feature in free from here.

Additionally, cirkit designer will improve the overall experience because of good pictorial representation. If you wanna try, Download cirkit designer from here in free.

PCB files:

Download PCB files from here along with circuit diagram and code.

I am using JLCPCB PCB prototype service since 2021 and I think JLCPCB is the only pcb manufacturer providing cheapest and best PCBs. You will get 5 pcs of quality boards just in $2. And if you sign-up using this link you will get free coupons of worth $30. Checkout to JLCPCB now and get amazing discounts on first order.


#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4

Adafruit_SSD1306 display(OLED_RESET);


void setup () {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  if (! RTC.isrunning()) {
    Serial.println("RTC is...
Read more »