loading

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

https://www.oshpark.com/shared_projects/A21xcMiD

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 -

https://github.com/sridharrajagopal/DSRTCLib

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.

Enjoy!

Sridhar

<p>Hello and thank you for this work. I would like very much to experiment with your design, but have a couple questions concerning the parts used. I understand that you use the 0805 form factor. Is this correct. Also please confirm the capacitor value as 22uF and identify the manufacturer and part number of the coin cell holder. I'm working on an arduino project and need the 3.3v with alarms solution. Your design is perfect for my prototype needs.</p><p>thanks, Cliff</p>
<p>Hi Cliff, </p><p>Thanks! Yes, I use the 0805 form factor. Resistors are 4.7 kohm, and the capacitor is 0.1 uf. The battery holder is for CR1220 (12mm) with through hole mount. The crystal is 32.768k btw.</p><p>Hope that helps!</p><p>Sridhar</p>
<p>Cool!</p>

About This Instructable

2,513views

11favorites

License:

More by sridhar_rajagopal:RTC Breakout for DS1339 on Arduino - low cost, battery backup, 2 alarms Panavise Jr Knob Turning Tool Cat Scratcher Tower 
Add instructable to: