Arduino real time clock using DS1307 and SSD1306 OLED

This post shows how to build a real time clock using Arduino, DS1307 RTC and SSD1306 OLED. The DS1307 RTC is used as a real time clock chip which keeps the time running even if the main power supply is off (with the help of a battery), time and date are displayed on the SSD1306 128×64 OLED.

In this Arduino project the DS1307 RTC as well as the SSD1306 OLED share the same I2C bus which minimizes the pin used. The I2C bus has two lines: SDA (serial data) and SCL (serial clock), an addition rest pin is required for the SSD1306 OLED. So with two push buttons we need a total of 5 pins. The two push buttons are used to set our real time clock (time and date).

Related Projects:
The two posts below contain some useful information which may help building this project.
Interfacing Arduino with SSD1306 OLED display
Arduino real time clock with DS1307

Hardware Required:

  • Arduino board
  • DS1307 RTC  —  datasheet
  • SSD1306 OLED (I2C mode)
  • 32.768KHz crystal oscillator
  • 2 x 10K ohm resistor
  • 2 x push button
  • 3V coin cell battery
  • Breadboard
  • Jumper wires

Arduino real time clock with DS1307 and SSD1306

The SSD1306 OLED used in this project is configured to work in I2C mode, some SSD1306 OLED boards may require a small hardware modifications (to select between SPI mode or I2C mode) such as soldering, placing jumpers …

In this project I used Adafruit SSD1306 OLED driver and Adafruit GFX library. Both libraries can be downloaded through Arduino IDE Library Manager of manually from the links below (after downloading, unzip the folders and place them in Arduino libraries folder, for example C:\Program Files\Arduino\libraries)
Adafruit SSD1306 OLED library   —   direct link
Adafruit GFX library                  —   direct link

Arduino real time clock using DS1307 and SSD1306 OLED circuit:
Project circuit diagram is shown below.

arduino ds1307 ssd1306 oled real time clock

(All grounded terminals are connected together)

The two push buttons B1 and B2 are for setting time and date.

Arduino Code:
SSD1306 OLED and DS1307 RTC share the same I2C bus and the Arduino communicates only with 1 device at a time depending on the address (sent by the Arduino), the SSD1306 address is 0x3D and the DS1307 address is 0x68.

The Arduino code below uses Adafruit SSD1306 OLED driver and Adafruit GFX library. It doesn’t use any library for the DS1307 RTC.

Project simulation:
The video below shows the simulation of the project with Proteus ISIS. Note that the simulation circuit is not the same as the actual hardware circuit, project hardware circuit is shown above (don’t try to build your hardware circuit as shown in the simulation video, otherwise your circuit may not work or you’ll damage your components!).

Proteus simulation file download (for version 8.6 or higher):
Arduino + SSD1306 OLED + DS1307


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

6 thoughts on “Arduino real time clock using DS1307 and SSD1306 OLED”

  1. how can we increase/decrease minutes,hour, date with 2 buttons.
    i dont want to keep increasing the minute is i passed the wanted minute

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top