Arduino 1307 clock

        The project I am currently working on requires as accurate time keeping as possible on the arduino. There are a few commercially available external clocks such as spark fun’s generic modual or the ChronoDot temperature compensating unit, however both cost more than $10 and are thus more than my project can afford.

This video here shows how to keep accurate time with just an arduino by compensating in code for the variance of your particular 16 Mhz crystal. The down side is that it is only accurate within about a minute per day. Boo 😦
My solution is to build my own 1307 module.

The schematic couldn’t be easier. wpid-screen-shot-2010-05-11-at-8-42-32-am-2010-05-1-23-221.png
To make your own you will need just a few parts.

A Maximum ds1307 RTC – (Maximum can send you free samples, don’t abuse it)

wpid-ds1307-2010-05-1-23-221.jpg
A 32.768 crystal – Hint, you can find these on dead motherboards or most any electronics that keep time. Or buy one here.

wpid-xtal_watchab-2010-05-1-23-221.jpg

A coin Battery – again, dead motherboards are a great place to get them, or buy this one.

wpid-bat10061-2010-05-1-23-221.jpg

Once you have the parts, it is a simple matter of wiring it according to the schematic. There are 3 output pins, SQW, SCL, and SDA. You only need the second two. If you have everything wired correctly, then your RTC should be silently ticking away. It will continue to do so for years as long as the battery stays connected.

The next step is to interface it with a micro controler such as the Arduino.  People in the arduino community have been nice enough to create a library for the 1307 on the arduino. It includes the commands to read and write the current time to the chip. You can download it here. A full article with pinouts and code is available here. If you are wanting more, take a look at this blog here.

Advertisements

About spuder
spuder is a "super computer" support engineer by day, and tinkerer / hobbyist by night.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: