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

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

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

Not Found :rolling_eyes:

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

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 " ?

HI: Please modify it . parameter “-r”

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

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

If bought this RTC, and I am wondering how to generate square waves from it through the BPI since there is no direct pin connection from the SQW pin of the RTC. Is there a safe way to do it (not prone to damaging the RTC)?

for my understanding:

hwclock -w -f /dev/rtc1 ---> Write the Time to RTC
hwclock -r -f /dev/rtc1 ---> Read the Time from RTC

right?

but where does the name rtc1 come from when I make it that way?

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

then “/dev/new_device” is right or not?