[BPI-M3] BPI RTC (DS3231) Module and how to use


(BPI_Justin) #1

OS: BPI-M3 Ubuntu15.10 (Kernel3.4) Version: 1.0 HDMI

Insert GPIO-Pin 1、3、5、7、9


Step 1:

sudo su sudo apt-get install i2c-tools

Step 2:Check the RTC (DS3231) device to see if it’s on track.(address 0x68) (I2c port number for M3: 2 )

i2cdetect -y 2

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- 68 – -- – -- – -- –
70: – -- – -- – -- – --

Step 3: Input RTC (DS3231) address

echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-2/new_device

Step 4 : RTC (DS3231) Module is in /dev/rtc1

hwclock -w -f /dev/rtc1 ==> Write the system time to file in /dev/rtc1 hwclock -r -f /dev/rtc1 ==> Read the time in /dev/rtc1 hwclock -s -f /dev/rtc1 ==> Read the time in /dev/rtc1 and write the system time to file as well.


Video Demo:

Demo procedure:

  1. Check System Time (Video_Demo:1m 11s)
  2. Write the system time to file in dev/rtc1 (Video_Demo:1m 32s)
  3. Check the time in /dev/rtc1 (Video_Demo:1m 39s)
  4. Modify the system time (Video_Demo:1m 58s)
  5. Check System Time. (Video_Demo:2m 22s)
  6. Read the time in dev/rtc1 and write the system time to file as well. (Video_Demo:2m 26s)
  7. Check System Time. (Video_Demo:2m 30s)

more about RTC moudle,please see gitbook:

https://bananapi.gitbooks.io/bpi-accessories/content/rtcmodule.html


[BPI-M3] BPI RTC (DS3231) Module Demo
Has anyone added an RTC
(BlinkQ) #2

OS: Linux bpi-m3 3.4.39-BPI-M3-Kernel #1 SMP PREEMPT Wed Dec 2 00:01:00 UTC 2015 armv7l GNU/Linux

ls /sys/class/i2c-adapter/i2c-2/

can see 2-0068 but i can find /dev/rtc1


#3

Not Found :rolling_eyes:


(BPI_Justin) #4

HI: Please check it https://bananapi.gitbooks.io/bpi-accessories/content/en/rtcmodule.html


#5

What is the parameter “-e” hwclock ? (in your gitbook) I do not need to save this configuration - echo ds3231 0x68 > / sys/class / i2c-adapter/i2c-2 /new_device ? …for example, in " rc.local " ?


(BPI_Justin) #6

HI: Please modify it . parameter “-r”

hwclock -r -f /dev/rtc1 ==> Read the time in /dev/rtc1


#7

…after the boot I have again the 1970 year :grin: