Skip to content

Adding a RTC to Raspberry Pi

Brendan Smith edited this page Sep 2, 2016 · 6 revisions

A RTC, or "Real Time Clock", will be used to keep track of time for our datalogger.

##Overview When a Raspberry Pi turns on, it asks the internet what the local time is. If there is no internet connection, it will fall back to a default time.

Because we wish to start up the datalogger out in the field, it is necessary to keep a module responsible for tracking time. We will use Adafruit's breakout board for the DS1307. It works just as the clock in your watch does.

This chip will communicate with our Raspberry Pi via a communication protocol called I2C ("i squared c").

###Setting up I2C

(TODO background on I2C)

Please follow these instructions to set up the Pi for I2C.

Though beyond the scope of this project, please see Quick2wire's I2C explanation for a concise introduction to the protocol.

###Connecting the RTC

With I2C configured for our Pi, we connect the RTC. Refer to Adafruit's wiring instructions.

As of August 2016, DO NOT follow Adafruit instructions to "Set RTC Time". Instead, please refer to AB Electronics' RTC Pi on a Raspberry Pi Raspbian Jessie.

###Testing the RTC

(TODO needs to be better prefaced. This is simple, but takes up the same length as the rest)

After this is said and done, you should be able to test to see that your RTC works correctly.

Disconnect from the internet, reboot the pi, and then see if the time was set.

If your Pi connects to the internet automatically, run

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

To change the name of your wifi temporarily so it does not automatically connect.

If the time shows up correctly without the internet, you have successfully added the RTC!

Clone this wiki locally