Creatron Raspberry Pi RTC Device

I purchased a Raspberry Pi 3 Model B at Creatron in downtown Toronto on December 27th. They had two different RTCs for the Pi: one (Creatron's part no. RASPT-116001) was on sale so I bought it because it's always been a big frustration for me that the Pi can't keep time when it's turned off.

I had some difficulties though: the device comes with zero documentation. The label looks like this:

DS3231 RTC Pi
for Pi/Arduino I2C 3.3/5V
Hi precision w battery
RASPT-116001
www.creatroninc.com

And that's the grand total of the documentation you get with it. On the product page (link above), Creatron helpfully links to two things: the Datasheet for the DS3231 chip that's used and an Adafruit tutorial on "Adding a Real Time Clock to Raspberry Pi". The latter sounds very promising, yes? But it isn't specific to this item. It mentions RTCs that use this chip, but that doesn't mean the pin-outs are the same because this is a different module.

So we have to do some educated guessing (with the considerable assistance of my friend Paul). There was no way to trace the chip pins to the header pins because the leads on the board aren't visible. The very small board the chip is on has some writing, partially obscured by the female pin headers soldered over top of them. There are five pins, and they appear to be: "+ D C NC" ... and nothing at all for the last pin. Part of the problem is that since the lower half of the letters are obscured, the second and third could be "P G". But Paul walked me through figuring out (I probably would have done this in about an hour - he did it in about three minutes) that the DS3231 runs on 3.3v, that "D" is probably SDA ("Data"), "C" is probably SCL, "NC" probably "Not Connected," and the final pin is almost certainly Ground. And this set of guesses corresponds exactly to the first five pins on the inside row of the RPi header.

The first test was to boot the new Pi without the RTC. It works fine: I chose the stripped down version of Raspbian since I'm already familiar with both the Pi and Debian. I unplugged it (and no network connection) for a couple minutes, then rebooted - and found the time had been maintained quite accurately. I then left it unplugged for about five hours, and even after that the Pi had managed to hold on to some semblance of the current time - although it was 15 minutes off. I had expected 15 years, so ... not too bad.

Enabling the RTC

I clipped the RTC on to the first five pins on the inside row, and then got to work. I followed the steps given by Adafruit, but their documentation is clearly out of date so I've made a few changes to make it work with the 2017-11-29 version of Raspbian currently available.

  • turn on I2C: run raspi-config at the command line (it's a TUI) and choose "Interfacing Options," then select I2C and enable it
  • next run i2cdetect -y 1: this produces a very ugly table, which will probably have only one entry, namely "68" which is the clock chip (apparently regardless of which clock chip it is, at least among the Adafruit choices)
  • edit '/etc/boot.config' and add the line 'dtoverlay=i2c-rtc,ds3231' to the end of the file (this is specific to the RTC I've purchased and its particular chip)
  • reboot
  • run i2cdetect -y 1 again: results should be slightly different with a marker at the '68' position but now it says 'UU' (this indicates that probing was skipped because the address is in use by a driver)
  • apt-get purge fake-hwclock (this software apparently interferes with the real RTC)
  • edit '/lib/udev/hwclock-set' and comment out these three lines:
#if [ -e /run/systemd/system ] ; then
# exit 0
#fi
  • check the RTC clock settings with hwclock (or hwclock -D which is "debug" mode and kind of interesting) and compare it to the output of date
  • I found that the RTC had automatically been set to the same date as the system, which had correctly got the time from the network
  • if the RTC is wrong but the system time is right, you can set the RTC with hwclock --systohc

I should now have correct time on the Pi with or without a network connection - at least for as long as the built-in battery on the module lasts. I've only had the RTC running a couple days, so I can't say anything about its accuracy yet.