Difference between revisions of "Rtc"

From BitWizard Wiki
Jump to navigation Jump to search
Line 2: Line 2:
modprobe i2c-dev
modprobe i2c-dev
modprobe i2c:mcp7941x
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device // For rev1 RPi
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device // For rev2 RPi


To write the system time to the RTC (you might need to run this command twice, when you use the RTC for the first time):
To write the system time to the RTC (you might need to run this command twice, when you use the RTC for the first time):
Line 16: Line 17:
modprobe i2c-dev
modprobe i2c-dev
modprobe i2c:mcp7941x
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device // For rev1 RPi
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device // For rev2 RPi
hwclock -s
hwclock -s



Revision as of 14:37, 10 April 2013

Load the I2C and RTC drivers as root:

modprobe i2c-dev
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device  // For rev1 RPi
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device  // For rev2 RPi

To write the system time to the RTC (you might need to run this command twice, when you use the RTC for the first time):

hwclock -w

Read out the RTC, and print the date and time to your console:

hwclock

Read out the RTC, and adjust system time:

hwclock -s

To automatically do this on startup, add the following lines to /etc/rc.d/rc.local

modprobe i2c-dev
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device  // For rev1 RPi
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device  // For rev2 RPi
hwclock -s

Source: http://www.element14.com/community/message/63885