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!
I am using rtc ds1307 and Linux orangepizero 3.4.113-sun8i.
I followed the process but after a power cycle
$ sudo hwclock -f /dev/rtc1 -r
gives back "Sat 01 Jan 2000 ..." when I exclusively set the time to current date and time.
Please help me up with this problem. I have been stuck with RTC for too long. Thank you.
(02-26-2018, 11:38 AM)saad.majid Wrote: I am using rtc ds1307 and Linux orangepizero 3.4.113-sun8i.

You aren't using the RTC the instructions are for, did you expect it to work? Huh

DS1307 uses a different address and a different register map. Maybe someday i will get a module... but to be honest, since they are priced the same, and DS3231 is a superior product because of the TXCO, i don't really see a point. There are plenty tutorials online, and with little modifications (address, address in the echo command) you should be able to get DS1307 working too.
My personal site:
My GitHub:

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

Olá como faço para o ds3231 funcionar no Android?
Quais comando devo fazer?

Possibly Related Threads...
Thread Author Replies Views Last Post
  Game Boy Zero - based on Orange pi zero plus 2 indevor 10 11,218 06-01-2020, 11:59 PM
Last Post: willk
  How do I configure ps2 and gpio control on orange pi pc Clayverson 2 6,271 02-27-2020, 05:28 AM
Last Post: Himyorange
  [ing..] Game Boy Zero - based on Orange pi zero intelis 0 1,430 01-31-2019, 04:53 PM
Last Post: intelis
  simple LoRa (RA-02) receiver for Orange pi zero rehan1993 0 2,642 05-24-2018, 04:44 AM
Last Post: rehan1993
  RTC battery for Orange Pi Zero Plus 2 indevor 1 4,281 03-02-2018, 04:17 PM
Last Post: kozaczek

Forum Jump:

Users browsing this thread: 1 Guest(s)