Prototype and configure your own Real Time Clock module for the Raspberry Pi ( Open Source Hardware and Software Configuration)

To keep the price of the raspberry pi down the developers left out some of the essentials one of those is the real time clock. At the moment the raspberry pi gets it time over the Ethernet from updating the time automatically from the global ntp (nework time protocol) server, but this means that when the Ethernet is unplugged and the Raspberry Pi Powered Down the raspberry pi has no way to keep the time or retrieve the correct time when powered back up again, for some applications this is unacceptable,  but don’t stress it is simple to add a real time clock to keep the time i will show you how in this simple tutorial with open source hardware that you can use for yourself.

Prototype and configure your own Real Time Clock module for the Raspberry Pi

Step 1: Components

Parts List                 
* Raspberry Pi
* DS1307 DIP8
* Raspberry Pi connector Spark fun part # 11765 or equivalent
* Battery 1220 3v
* 1220 Battery holder
* Crystal 32.768kHz
* Prototyping Board
* 11mm spacer
* 2 screws
* Solder
* Multicolored flexible wiresTools
* Wire cutters
* Soldering iron
* Drill
* Grinder ( optional )

Step 2: Schematic

When looking to add new hard ware it always pays to read the datasheet carefully, let me take you thought the wiring X1 is a common crystal that is readily available it is not polarized and wire it to x1, and x2, B1 is a 3V battery and wired to Vbat and GND This is so that when the power goes out to the pic the Real time clock still has power and keeps the time so that on the next power up you will still have the correct time. SCL is the serial clock for the I2c bus and connects to pin5 on the raspberry pi connector as shown in picture 2, SDA is the the serial data for the i2c bus and connects to pin 3 n the raspberry pi connector, You can also wire pin 2 form the raspberry pi  to 5V and GND to pin 6

Step 3: Make the circuit board

* Pictorial steps to wiring up an RTC module prototype are shown in the PDF below

Step 4: Set Up the I2C Bus for the Raspberry Pi

I2c on the Raspberry Pi is disabled by default to enable it

Open the raspi-blacklist.conf file by running the command

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Find the I2C line where the I2c is black listed

blacklist i2c-bcm2708

Comment it out by replacing it with the line below

#blacklist i2c-bcm2708

2. Load the required modules at startup.

The Raspberry Pi also needs the following I2c module to be loaded on start up

Open the modules file by running the command

sudo nano /etc/modules

Prototype and configure your own Real Time Clock module for the Raspberry Pi code

Add the following line at the end
i2c-bcm2708
i2c-dev
rtc-ds1307
 
For more detail: Prototype and configure your own Real Time Clock module for the Raspberry Pi ( Open Source Hardware and Software Configuration)

Scroll to Top
Read previous post:
*Preliminary* SPI on the Pi: Communicating with a SPI 3-axis accelerometer using a Raspberry Pi

Step by step guide on how to setup Raspbian, and communicate with a SPI device using bcm2835 SPI library (NOT...

Close