This guide covers the basic use of the Makerverse Supercap Real Time Clock (RTC) on the Raspberry Pi. We'll connect the RTC, and set the Pi up to use the RTC for its main time source - useful for datalogging projects or projects that get power-cycled a lot.

Transcript

G'day and welcome to the guide video for the Makerverse SuperCap RTC on the Raspberry Pi. In this video, we're going to learn how to configure the Raspberry Pi to use the SuperCap RTC as its primary clock, so that in the event of a reboot or a power failure, it doesn't lose track of time.

The SuperCap RTC is an I2C device, so we're going to need to make four connections, two for power and two for the I2C bus. Using the RTC in this orientation, let's start with the ground connection. You can see the ground pin on the back of the RTC labelled, and we're going to use the fifth pin in from this corner on the Raspberry Pi. The next three connections are actually quite straightforward, because the Raspberry Pi has VCC, serial data and serial clock in the same order as the RTC pinout.

With the RTC connected to the Raspberry Pi, it's time to boot up the Raspberry Pi and open up a web browser and navigate to the guide for the rest of this installation. On the Raspberry Pi, the bulk of this tutorial is going to be done in the command line. Basically, there isn't really an easy GUI tool to do a lot of these steps. As a bonus, it's very easy to use this guide through SSH.

On the Raspberry Pi, we're going to open up a terminal with CTRL-ALT-T, and the first thing we're going to do is configure the I2C interface. The steps for enabling the I2C interface are towards the top of the guide. We'll scroll down and find the Raspberry Pi I2C configuration and run through the steps. First thing is to open up the Raspberry Pi configuration utility, and then scroll down to Interface Options, scroll down to I2C, press Yes to enable the I2C bus, and press OK to confirm the changes. Then we're going to scroll down and press Finish to exit this utility.

Scrolling down in the guide, you'll find the next step is to install some software. Running that the driver is now loaded and the Raspberry Pi can talk to the RTC.

This command at step 7 is going to install some I2C utilities so we can use the command line to talk to the I2C devices. Copy that one into a terminal and run it. When that's done, the last thing to do here is to reboot to make sure that any changes we've made have been configured properly.

With the Raspberry Pi rebooted and the guide back open, we're going to run a command to make sure that the Raspberry Pi can actually talk to the RTC. Scrolling through the guide, you'll see this command I2C detect-Y1. We'll run that in the terminal, and hopefully you'll get this output. The 52 in this location indicates that address 52 in hexadecimal can actually talk to a device, and that is the RTC module.

The next step is to configure the RTC chip itself so that it falls over to the capacitor as a battery backup, and so that it charges the capacitor while it's switched on. To do that, we'll find the section in the guide RV3028 Capacitor Configuration, and copy these three commands into a terminal and press enter to run them all. Next, we can confirm that this configuration was done correctly by finding the next command to read back one of the registers from the RTC, and making sure that the output is 0x3C. This means we're all good to go.

The next step is to enable the RV3028 driver in the Linux kernel, so the driver loads on boot. We do that by scrolling down in the guide to Enabling the RV3028 Driver, running this first command here, we'll just add the correct line to the Raspberry Pi's config.txt file to load the RV3028 driver. We'll run that command, and then we'll do a reboot and make sure that it's been loaded.

With the Raspberry Pi rebooted and the guide back open, we can check out the guide and run this command here to make sure that the driver has loaded. If the driver has loaded, the 52 is being replaced with UU. This just means that the driver is now loaded and the Raspberry Pi can talk to the RTC.

I2C detect hasn't tried to probe the address because the kernel driver is currently using it. To configure the Raspberry Pi clock, we need to remove the existing fake hardware clock driver. This is done by copying three commands into the terminal and letting them run. We then run a command that edits a script so that it reads from the RTC instead of the old fake hardware clock driver. This is done by running a fairly cryptic looking command, which comments out a whole stack of lines in a configuration file and replaces them with a command that reads from the RTC to set the system clock.

After rebooting, we can check the system log to make sure that the RV3028 is being used as a time source. To do this, we run the dmessage command and search for the string RV3028. If the output has been registered as RTC0, then we are all good.

Next, we disable the network time service so that we can manually set the time without the network time service changing it back almost instantly. This is done by running two commands under the heading Disabling Automated Network Time Updates.

To set the time manually, we run the command which sets the time. We then run the next command which writes the current system time to the hardware RTC. To do a debug to make sure it's actually written to the RTC, we run the hwclock command.

RTC correctly, we can run this command here. And you can see that the time in the RTC is currently a few seconds after the time that we manually set earlier.

We hope this has given you some ideas for your own offline time-based projects. If you make something cool, or just have a question about this guide, leave a comment on the article for this video.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.