i2cget - i2cset

 

The DS3231 Real Time Clock (RTC), I2C address 0x68, will be used for the following examples:

The programs, i2cget and i2cset, both assume the I2C device has a single byte index register. Thus, devices with no index register as well as those with two byte index registers don't work well with these tools.

Using i2cget, view indexed register 4 "Date" (day of the month)
$ i2cget -y 1 0x68 4
0x14

Using i2cget, view indexed register 0 "Seconds"
$ i2cget -y 1 0x68 0
0x05

Using i2cget, view indexed register 0 "Seconds"
$ i2cget -y 1 0x68 0
0x07

Using i2cset, change indexed register 4 "Date" (day of the month) to 25
$ i2cset -y 1 0x68 4 0x25

Display the indexed register's new value
$ i2cget -y 1 0x68 4
0x25

 
< + >