# Using RTC PCF8563 on Raspberry PI running Raspbian OS

I built the RTC circuit. Now, I had to start using the “RTC to keep time, in Raspbian OS”! Well,after a bit of digging and experiment, here’s what I did.

I used a PCF8563 RTC with Raspberry Pi Model B, running latest version of Raspbian OS (Release date: 2014-01-07).

NOTE: RTC PCF8563 is supported in the latest Raspbian OS kernels. No need to build a custom kernel.

- First, `sudo vi /etc/modprobe.d/raspi-blacklist.conf`
  - Then, comment out the following lines, by prepending them with a # character:

    #blacklist i2c-bcm2708

- Second, you need to configure to load modules at startup.
  - Open the file: `sudo vi /etc/modules`
  - Add the following lines, at the end of the file:

        i2c-bcm2708
        i2c-dev
        rtc-pcf8563

- Install i2c-tools:

      sudo apt-get install i2c-tools

  and then REBOOT

- After reboot, check to see if your h/w is connected and working:

      sudo  i2cdetect -y 1

  If your h/w is working you should see a 0x51 in the output of the above command.

- Now, you need to add the rtc clock to work right at every boot:
  - Open /etc/rc.local: `sudo vi /etc/rc.local`
  - Add the following lines, right before the line containing `exit 0` (the exit 0 should be the last line of the rc.local file)

        modprobe i2c-bcm2708
        echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
        modprobe rtc-pcf8563
        hwclock -s

  - Now reboot again.
- To change the date in rtc:
  - Check the current date and time in Raspbian OS: `date`
  - Set the date and time in your Raspbian OS(you should have set the correct timezone, before this step):

`date -s "MMM DD HH:MM:SS"`

Where, MMM=first 3 letters of months, DD=new date and HH:MM:SS = 24 hr format hours:minutes:seconds.
You should enclose the parameters, within double quotes. For more information check man page of date.

- To view the current date and time stored in the RTC Pi: `hwclock -r`
- Set the Linux system time to the value in the RTC Pi: `hwclock –s`
- To set the RTC Pi with a custom time directly, use:

`hwclock --set --date="2014-12-25 00:00:00" --utc`
and then use:
`hwclock --hctosys`

``For more information about `hwclock`, refer the man page.

- Done!

About these ads

### Share this:

- Twitter
- Facebook
- Google
- LinkedIn
- Reddit
- Print
- Email

### Like this:

Like Loading...

## 2 comments

1. I stumbled upon this blog while searching for a quick way to setup my brand new Raspberry Pi with a pcf8563. Thanks for this quick tutorial. Saved me a lot of time and googling around.

   Like Like

   Reply

   1. I am glad, it was helpful.

      Like Like

      Reply

### Leave a Reply Cancel reply

Enter your comment here...

Fill in your details below or click an icon to log in:

Email (required) (Address never made public)
Name (required)
Website

You are commenting using your WordPress.com account. ( Log Out / Change )

You are commenting using your Twitter account. ( Log Out / Change )

You are commenting using your Facebook account. ( Log Out / Change )

You are commenting using your Google+ account. ( Log Out / Change )

Cancel

Connecting to %s

Notify me of new comments via email.

### Archives

Archives

### Recent Posts

- eGalax touchscreen and Banana Pi and Raspbian OS
- Of CodeLite and Boost libraries
- Configure eth0 on Raspberry Pi
- Using RTC PCF8563 on Raspberry PI running Raspbian OS

### Categories

Categories
Follow

### Follow “Pragmatic Monk”

Get every new post delivered to your Inbox.

Build a website with WordPress.com
%d bloggers like this:

Send to Email Address Your Name Your Email Address
Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.