Enginursday: Battle of the RTC

New tutorials and Arduino libraries for the DeadOn RTC and Real Time Clock module breakout boards – plus, a fun little analog clock project.

Favorited Favorite 0

I have a project on the near horizon that needs relatively accurate time counting -- something a little more dependable than ticking off millis(). In these days of "connect-all-the-things," finding the time is often just an NTP request away, but if your project isn't internet-connected, a Real Time Clock (RTC) (or GPS) is the best time-keeping option available.

We've got a pair of RTCs in the SparkFun catalog -- the DeadOn RTC Breakout and the Real Time Clock Module -- both based on Maxim ICs: the DS3234 and DS1307, respectively. As I was browsing through the product pages for each, I noticed they were both lacking in the documentation section, with no hookup guides and sparse (to put it nicely) example code (the RTC module had PIC16F88 code! Yikes, that's an oldie!). So I decided to remedy that situation first.

I present the DeadOn RTC Breakout Hookup Guide...

DeadOn RTC Breakout Hookup Guide

October 6, 2016

An introduction to the DS3234 real-time clock (RTC), example wiring diagrams, and an Arduino library!

... Real Time Clock Module Hookup Guide...

Real Time Clock Module Hookup Guide

October 6, 2016

A quick introduction to the DS1307 RTC module and a hookup guide for the SparkFun Breakout.

... and Arduino libraries for those boards' chips: the SparkFun_DS3234_RTC_Arduino_Library and the SparkFun_DS1307_RTC_Arduino_Library.

(There's still plenty of work to be done on those libraries. Nate's "Genericizing Arduino Libraries" post from earlier this week is a good place to start. Additionally, both libraries share a lot of common algorithms; instead of copying and pasting one to the other and replacing some registers, I should create a parent class that keeps those shared functions in one place. Revisions to come!)

RTC Showdown

Even though they ultimately serve the same purpose, the RTC breakouts offer some unique differences. The DS3234 on the DeadOn RTC uses an SPI interface, while the DS1307 talks over I2C. Mostly out of laziness, I prefer I2C -- two fewer wires to route!

RTC showdown

The DS3234 is the only chip that supports 3.3V supplies, which, in a world of increasingly lower-power devices, is a big bonus. Plus, it includes a pair of programmable alarms -- a nice feature to be able to offload from your µC.

If you don't have a specific need for programmable alarms, SPI, or 3.3V capability, I suggest going with the DS1307 on the Real Time Clock Module. You'll benefit from far lower power consumption -- the DS1307 can run for decade(s) on a coin cell battery, versus just a couple years for the DS3234 -- and save a little money.

Analog Time Meter

Finally, a quick project: While I was plugging away at documenting the RTCs, ThinkGeek's new Analog Voltmeter Clock caught my eye. We've got everything in our catalog to make it! I grabbed a few Analog Panel Meters and, using the template posted by EthanS. (thanks EthanS.!), swapped the voltage display for time displays.

Swapping out the analog meter display

Then I banana-cabled everything together, modified the RTC demo code to analogWrite to a few pins, and voila! Panel meter clock:

Wiring up the analog meter clock

Clocks are one of those classic projects everyone has to make at least one of. I'm guessing for a lot of us (me included), a clock was our introduction to soldering, programming, or even analog electronics. Hopefully this simple project serves as inspiration for many more! If you want to make an analog panel meter clock of your own, here are a few links:

Then throw it in a red box and stick it on your shelf!

Box analog panel meter clock in action


Comments 9 comments

  • xsk8rat / about 8 years ago / 3

    Thank you for creating the Hookup Guides and updating the libraries. I live and die by those things!

    Cheers!

  • Risen / about 8 years ago / 1

    The 1307 that I put into a standalone clock project loses a couple minutes per month. It's a little annoying to have to adjust it that frequently.

  • JPerch / about 8 years ago * / 1

    If you are in need of the higher accuracy of the DS3234 but pin limited such that you want the I2C bus, you could use the DS3231 also from Maxim. It appears to be essentially the same chip but with an I2C interface instead of SPI. The register set even appears to be the same.

    https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS3231.html

    Joe

    Edit: Just noticed the two parts have a different number of pins and a different pinout. So the DS3231 would require its own breakout board.

    • Maine Solder Guy / about 8 years ago / 1

      The DS3231 can use the 1307 libraries. I'm not sure that you extract all functionality, but my uses have been fairly simple and I don't need all bells and whistles. My major interest was the temperature controlled oscillator and high accuracy.

    • Sembazuru / about 8 years ago / 1

      The Chronodot uses the DS3231N (this is the industrial version that is tested to work below freezing). The versions that I've used have solder locations for I2C pullup resistors, but leave it up to you to decide if you need them or not. I think you can get the Chronodot over at EvilMadScientist and/or AdaFruit. Maybe other places. Creative searching might find DS3231 based breakouts less expensive than the chronodot, but you won't get the cute round PWB. ;-)

      Watch out, though. The DS3231 doesn't have NVRAM, so if you plan on using the storage (for example, storing daylight savings time rules/settings) then you are out of luck.

      • Hoping somebody else noticed that detail. NVRAM is so much easier to work with compared to eeprom. No write limits means you can just block read the thing on boot right into your variables and occasionally (meaning add a call to any of the routines that would change them) just dump the entire block back to the clock. No worries about wear leveling. I like easy.

      • JPerch / about 8 years ago / 1

        Yes, the Chronodot uses this device (that is how I knew about it). Adafruit does sell the Chronodot (I have bought a couple of them). They have also created their own breakout board for this device as well as a feather board.

        Joe

        • Sembazuru / about 8 years ago * / 1

          Too bad the chronodot doesn't use the DS3232SN... That is I2C like the DS3231SN, but includes NV SRAM (but only 236 bytes instead of the 256 bytes of the DS3234).

          But, maybe that is an opportunity for SparkFun. A refresh of the DeadOn RTC:

          • Upgrade the current version to the ...SN variant and add the RESET and 32khz breakout pins.
          • Make a new breakout board for an I2C DeadOn using the DS3232SN.

          That would give customers the option of I2C or SPI without loosing the accuracy and existence of on-board memory.

          Also, Adafruit's breakout and feather wing board only uses the ...S variant, not the ...SN variant. The ...S variant isn't rated for accuracy below freezing.

Related Posts

Recent Posts

Why L-Band?

Tags


All Tags