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!
Step 1: Parts
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
Step 2: Connect RTC to Arduino
- Place the coin-cell battery in the RTC. (The positive side faces outward on most RTC boards)
- 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
Step 3: Download the Arduino Library and Run the SetTime Sketch
- 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.
- 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.
- Be sure your Arduino is connected to the computer and download the sketch to the Arduino
- 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.