Simple Guide to Setting Time on a DS3231/DS3107/DS1337 Real Time Clock With Arduino UNO

by GeekMomProjects in Circuits > Arduino

125195 Views, 53 Favorites, 0 Comments

Simple Guide to Setting Time on a DS3231/DS3107/DS1337 Real Time Clock With Arduino UNO

DS3231_Both_Sides.jpg

The DS3231 is a highly accurate, widely used Real Time Clock (RTC), as are its slightly less accurate counterparts, DS3107 and DS1337. Before it can be useful, however, it needs to be set to the correct time. This Instructable is strictly for the purpose of setting the correct time on a Real Time Clock board using an Arduino UNO. There are other very informative guides about RTC boards, but they contain a lot of extra information that you may not want to read through. You won't get a lot of background in this Instructable, but hopefully, if you've come here looking to set your DS3231 to the correct time, you'll find what you need!

Parts

Components.jpg

You'll need only:

  • DS3231 (or DS3107/DS1337) Real Time Clock (EBay is among the cheapest sources)
  • An Arduino UNO (you could use another board but it may use different pins for SCL/SDA)
  • A coin cell battery (This article claims you need a rechargeable LIR2032 battery, though they often ship with a CR2032 battery)
  • 4 x Male to female breadboard cables

Connect RTC to Arduino

Components_Connected.jpg
  1. Place the coin-cell battery in the RTC. (The positive side faces outward on most RTC boards)
  2. Connect only the following four sets of pins together using the male to female jumper cables:
    VCC -> Arduino 5V
    GND -> Arduino GND
    SDA -> Arduino A4
    SCL -> Arduino A5

Download the Arduino Library and Run the SetTime Sketch

Components_Computer.jpg
ArduinoMenu.jpg
SetTimeSketch2.jpg
  1. Download and install the DS1307RTC Library from http://www.pjrc.com/teensy/td_libs_DS1307RTC.html. If you don't know how to install an Arduino library, read the instructions here.
  2. Connect your Arduino to your computer, then open the Arduino IDE, and open the SetTime sketch which you can find under: File->Examples->DS1307RTC->SetTime.
  3. Be sure your Arduino is connected to the computer and download the sketch to the Arduino
  4. Open up the Serial Window - make sure the baud rate is set to 9600. If everything goes correctly, you should see a success message as shown in the last image above.

That's it! You're now all set to use the correct time in your future projects.