Enable The Pi-Cubes Main Board Integrated RTC on Raspberry Pi/Raspbian

Enable The Pi-Cubes Main Board Integrated RTC on Raspberry Pi/Raspbian

0 Share

Enable The Pi-Cubes Main Board Integrated RTC on Raspberry Pi/Raspbian

In order to use integrated RTC on the Pi-Cubes Main board with Raspberry PI and Raspbian please follow instructions:

In order to use integrated RTC on the Pi-Cubes Main board with Raspberry PI and Raspbian please follow instructions:

1.  Load up the RTC module and run tests to make sure RTC is running. Raspberry Pi has to be connected to the Internet.
Load RTC Module :

sudo modprobe rtc-ds1307

sudo bash
echo ds1337 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
exit

Test that hardware clock can be read.

sudo hwclock -r

Write the current system time to the RTC.

sudo hwclock -w

2 . Add RTC clock module “rtc-ds1307” to the kernel :

sudo nano /etc/modules

 

1

Use Ctrl-X to exit and save module file.

3.   Edit hardware clock  “hwclock.sh” script by:

sudo nano /etc/init.d/hwclock.sh

After “unset TZ” at top add next script:

init_rtc_device()
{[ -e /dev/rtc0 ] && return 0;

# load i2c and RTC kernel modules
modprobe i2c-dev
modprobe rtc-ds1307

echo ds1337 0x68 >> /sys/bus/i2c/devices/i2c-0/new_device;
if [ -e /dev/rtc0 ];
then
log_action_msg “RTC found on bus I2C-0”;
break; # RTC found, bail out of the loop
else
echo 0x68 >> /sys/bus/i2c/devices/i2c-0/delete_device
fi
}

 

2

Find “case “$1” in “ and add “init_rtc_device” and as well comment out lines as per screenshot.

 

3

Exit and save it.

4.   Update the real HW clock and remove the fake one:

sudo update-rc.d hwclock.sh enable
sudo update-rc.d fake-hwclock remove

5.  Now the real clock is installed. Remove the fake package and crons:

sudo apt-get remove fake-hwclock
sudo rm /etc/cron.hourly/fake-hwclock
sudo rm /etc/init.d/fake-hwclock

6. Reboot. RTC should be setup as main HW clock. You may test to read time with :

sudo hwclock -r

This tutorial is based on the Raspberry Pi Forum topic.
If you need more information visit : https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=85683

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>