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 RTC module.

DS1307_1.jpg
DS1307 Module

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 low power, 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

Hardware and parts

For this tutorial I’ll be using the following parts, usual Arduino Uno board, OLED i2c display, LCD i2c display and of course the DS1307 RTC module, along side some jump wires and a breadboard:

 

Wirings

Wiring  1: with LCD i2c

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

Wiring_LCD.png
DS1307 with LCD i2c and Arduino UNO board

Wiring 2: with OLED i2c

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

Wiring_OLED.png
DS1307 with OLED and Arduino UNO board



Libraries

Codes

Make sure to check the video tutorial above to know what code does what, or check the pictures below.

Code 1: Library example – SetTime

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. And here are the codes I’ve made for the LCD and OLED: Download here 3 LCD codes, Download here 3 OLED codes, or check below:

 

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 !!

Code 2: LCD code 1

Code 3: LCD code 2



Code 4: LCD code 3

Code 5: OLED code 1

Code 6: OLED code 2

Code 7: OLED code 3

 



Tests

LCD tests:

DS1307_LCD_1
Code 1
DS1307_LCD_2
Code 2
DS1307_LCD_3
Code 3

 

And for the OLED

DS1307_OLED_1
Code 1
DS1307_OLED_2
Code 2
DS1307_OLED_3_1
Code 3 “animation 1”
DS1307_OLED_3_2
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.

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

Leave a Reply

Discover more from SURTR TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading