Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using an external RTC with Orange Pi
Here is a little "tutorial" (i hate that word) on using one of these cheap DS3231 internal-TCXO modules with Orange Pi (tested on my system, should be the same on Armbian or any other system)

You will need:
- A DS3231 module (like this one (actually, this should work with any Maxim Integrated RTC that has its address at 0x68)
- 4 female-female wires (your standard 2.54, or whatever you are comfortable with)
- An Orange Pi board (duh)
- Access to TTY on the board and access to root (Just open terminal if you are running X)

So, lets get to it.
First, connect the GND pin on your module to GND on your OPi's header (I've connected it to pin 9), then VCC to 3.3V on your board (pin 1 will do), then SDA and SCL to pin 3 and 5 respectively, then boot your board.
Now, log in as root (or use sudo if you like) connect to a network for NTP, make sure the time is right with the "date" command (just type it in and press enter, easy, right?)
Then, you type in this:

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

This tells the I2C subsystem that there is a device at address 0x68 on I2C bus 0, and it should use the ds1307 driver.
Next, you need to type in:

hwclock -f /dev/rtc1 -w

Since H3 has an internal RTC, just without a backup battery, the detected RTC on the I2C bus (the one you just connected) gets detected as rtc1, and not rtc0, thats why we need to tell hwclock (an utility for using the hardware clock) to use rtc1 instead.

Now that the RTC is set, you go and edit /etc/rc.local with:

nano /etc/rc.local

and insert these lines (before "exit 0"):
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
hwclock -f /dev/rtc1 -s

then save with "Ctrl-O", enter, and "Ctrl-X".

This tells our OPi to sync the clock at every boot, overriding the internal clock.
Congratulations, you have the RTC set up! Now your OPi will keep time even after a power cycle.

PS: If you dont have access to internet, or your NTP doesnt work, you can set the time manually with:

hwclock -f /dev/rtc1 --set --date="YYYY-MM-DD hour:minute"

For example:

hwclock -f /dev/rtc1 --set --date="2016-01-24 17:57"
My personal site:
My GitHub:

If you wanted to fail, and you succeed, what did you do?

Nice, thanks!

Possibly Related Threads...
Thread Author Replies Views Last Post
  How do I configure ps2 and gpio control on orange pi pc Clayverson 0 1,235 12-19-2016, 10:37 PM
Last Post: Clayverson

Forum Jump:

Users browsing this thread: 1 Guest(s)