Skip to content

How to use DS1307 RTC with Arduino and LCD/OLED


           Hi, and welcome to this tutorial, it’s about another RTC (Real Time Clock) module, it’s the DS1307, previously I did a tutorial about the DS1302, and a project where I set it  up using a keypad, then an Alarm Clock project based on that module, I also did a tutorial about the DS3132.


But today we’re about the DS1307, and I’m gonna use it with Arduino UNO board and I’ll also use a LCD i²c screen and OLED display, to show time and date in different formats.

“The DS1307 serial real-time clock (RTC) is a lowpower, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year.”

– MaximeIntegrated datasheet


For this tutorial I’ll be using the following parts, along side some jump wires and a breadboard these parts:


For the LCD i²c version, both are connected with 5v and they both share A4/A5 for SDA/SCL

DS1307 with LCD

For the OLED version they both share 5V and A4/A5 for SDA/SCL

DS1307 with OLED


Download here Time Library

  • LCD i²c library:    Download here LCD i²c NewLiquidCrystal library
  • OLED libraries: –  Download here  Adafruit OLED SSD1306 library                                                               –  Download here Adafruit GFX Library


For the codes I’ve used to set the RTC module and print the Time/Date on the serial monitor are just examples from the RTC DS1307 library.

Important !! First time you must wire the module and upload the “SetTime” example, it sets the module to the compiling time of the code which is technically your real time and date.

N.B: If you are testing the module with multiple things it’s better to close the “SetTime” example, open it again and upload to the board, otherwise your module will be programmed with the first time the “SetTime” example was compiled, and you may think that your module doesn’t work well !!

And here are the codes I’ve made for the LCD and OLED:



LCD tests:

Code 1
Code 2
Code 3


And for the OLED

Code 1
Code 2
Code 3 “animation 1”
Code 3 “animation 2”


That’s it for this RTC module, if you have any problem feel free to get in touch!

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

5 thoughts on “How to use DS1307 RTC with Arduino and LCD/OLED Leave a comment

Leave a Reply

%d bloggers like this: