Skip to content
Advertisements

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.

DS1307_1.jpg
DS1307

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

Parts

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

Wirings

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

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

Wiring_OLED.png
DS1307 with OLED

Libraries

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

Codes

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:

 

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!

Advertisements

Yassine View All

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: