New tutorials and Arduino libraries for the DeadOn RTC and Real Time Clock module breakout boards – plus, a fun little analog clock project.
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…
(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!)
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!
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.
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.
Then I banana-cabled everything together, modified the RTC demo code to
analogWrite to a few pins, and voila! Panel 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!