Monday, 11 August 2014

Raspberry Pi Real Time Clock Upgrade

Just a quick update following my Raspberry Pi B+ ZX Spectrum USB Keyboard Case Mod, there was almost a square inch of space inside the unit. This would not do, so I have been asked to add a Real Time Clock module. The RTC stores the date and time and is backed up by a battery when the unit is not powered up. Most larger computers have one of these built in, but there wasn't space on the Raspberry Pi. The DS1307 is the standard I2C RTC chip to use for this sort of thing. I use these in my LED clocks.
Here I've used an Adafruit RTC module as it was relatively small, although I've still had to fit horizontal headers to it. It's not specifically designed for the Pi, but is easily adpated. I've removed the I2C pullup resistors on the RTC as the Pi has it's own, and they pull up to 3V3, where as the DS1307 runs from 5V.
The wiring is straightforward, but due to the limited height, I've also had to bend the GPIO pins sideways to make the connections, the I2C SDA and SCL on the left and 0V and 5V on the right. It all fits snugly in the only remaining space inside the Spectrum.
I've overlaid the image of the parts in the top of the case, so you can see the 3D spacial puzzle involved in arranging the components inside.
Setting it up was fairly straight forward, I followed this guide on the adafruit site. This is what they refer to as the 'v2' Raspberry Pi, the I2C on the GPIO is bus 1. Also remember to read the text as some of the screenshots are different.