Introduction: RTC Breakout for DS1339 on Arduino - Low Cost, Battery Backup, 2 Alarms

The most popular RTC for the Arduino is the DS1307, sold by Adafruit, Sparkfun, and others. However, it does have some drawbacks, the most notable of which is that its operating voltage is 5v, which meant I could not use it with my Arduino Pro Mini @ 3.3v.

That led me on a hunt for an appropriate replacement for the DS1307. Here were my design parameters:

1) Tolerant of a wide range of voltages, including 3.3 and 5 v

2) Battery backup, so I don't have to worry about resetting the date and time each time I power cycled it.

3) The presence of an alarm, so I could get timed interrupts (and possibly use that to manage power savings for the Arduino Pro Mini running off of battery.

4) DIP package preferably, so it would make for easier soldering (alas, this was not to be!)

The DS1307 is made by Maxim Integrated, and they have a dizzying array of RTC chips. After going through a whole set of datasheets, I was starting to get a headache! I finally settled on the DS1339, which satisfied all of my requirements, namely:

1) Tolerant of a wide range of voltages, from 1.8 V to 5.5V. In particular, I choose the DS1339-33, which has a voltage range of 2.97V-5.5V with the typical voltage as 3.3v

2) It had a battery backup

3) It had not one, but TWO alarms!

4) As a bonus, it also had a trickle charger

I set out to design a breakout board for the DS1339, which I've shared on

After I got the boards from Oshpark, I had to do some smd soldering. There are plenty of sites that tell you how to hand-solder smd components, so I won't go into that detail here. I added a solder jumper to the breakout board that can be used to enable/disable the pullup resistors.

After that, I actually needed a library to talk to the DS1339 from Arduino. The register format is different from that of the DS1307 (of which several libraries are available). Fortunately, I found a library for the DS1337 that was made specifically for the Mosquino, an Arduino compatible platform for extremely low power consumption. Fortunately, the DS1337 and DS1339 register formats were almost identical, with the exception that the DS1339 also had one more register for the trickle charger.

I forked the Mosquino DS1337 library, and made it more generic (you can specify which pins you are using for the external interrupts), made DS1337 and DS1339 subclasses (I could add trickle charger support for the DS1339, for instance), and also updated the example to be able to set and read the time, making it easier to set the time on the RTC module for the first time.

I've released it on github -

It is similar to any other Arduino library. Copy it over to the Arduino libraries folder, and restart Arduino. The DSRTCLib should show up under Examples.

Now you have a relatively low cost RTC module that is chock-ful of features, and can be used with a variety of Arduino boards.



Battery Powered Contest

Participated in the
Battery Powered Contest