Greetings All,
I had the same problem. I bought an RTC board from ABElectronics in the UK:
https://www.abelectronics.co.uk/
They claimed to have tested their RTC with ALL Orange Pi's. However, mine didn't work.
They then admitted they did not actually run it on a OPZ2. So, they bought one and helped me configure it.
THis is the correspondence from Andrew @ ABEelectronics:
==========================================================================================================================================================================
The Orange Pi Zero 2 arrived this morning and I have managed to get the RTC Pi working on the board using Debian Linux. I can see why you have problems using “
orangepi-config” as it appears to be missing a lot of sections found on the other Orange Pi models.
These are the steps I used to get the RTC Pi working.
I started with a fresh install of Debian 4.9.170 from Orange Pi’s website at
https://drive.google.com/drive/folders/1Xk7b1jOMg-rftowFLExynLg0CyuQ7kCM
First, I updated the firmware on the Orange Pi.
sudo orangepi-config
Select
System / Firmware / Yes to “Do you want to update board firmware?
Reboot linux.
Next I ran
sudo apt update and
sudo apt upgrade
i2c-tools is not installed by default so I installed that next.
sudo apt install i2c-tools
According to the manual the I2C bus on the GPIO pins is i2c3 so I tried running i2c-detect.
sudo i2cdetect -y 3
It came back with the following results showing the RTC Pi on address 0x68.
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: -- -- -- -- -- -- -- --
It appears that on a clean install of Debian the i2c bus is enabled by default. To check if the RTC was working I used the i2cdump tool to read the contents of the RTC memory.
sudo i2cdump -y 3 0x68 i
This what it returned.
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 12 15 07 05 15 06 13 03 00 00 00 00 00 00 00 00 ????????........
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 12 15 07 05 15 06 13 03 00 00 00 00 00 00 00 00 ????????........
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 12 15 07 05 15 06 13 03 00 00 00 00 00 00 00 00 ????????........
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 12 15 07 05 15 06 13 03 00 00 00 00 00 00 00 00 ????????........
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
The numbers at the first two addresses which hold the seconds and minutes changed each time I ran the command which means the RTC was running.
If you want to use the RTC Pi with your own applications, for example in a python script, you should be ready with the steps I used above as this will give you direct access to the RTC hardware through the I2C bus. If you want to use the RTC as a hardware clock that Linux can use to keep time when the network is disconnected there are a few extra steps.
It took a while to find out how to enable the RTC Pi as a hardware clock but I eventually found it in the official Orange Pi Zero 2 user manual on the Orange Pi website
https://drive.google.com/drive/folders/1ToDjWZQptABxfiRwaeYW1WzQILM5iwpb
On page 172 it give instructions on using the DS1307 RTC module which is used on the RTC Pi.
You need to create a dts overlay which is used to load the RTC module. Create a new file called i2c-ds1307.dts
sudo nano i2c-ds1307.dts
In the file paste the following:
/dts-v1/;
/plugin/;
/{
compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616";
fragment@1 {
target = <&i2c3>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
ds1307@68 {
compatible = "dallas,ds1307";
reg = <0x68>;
status = "okay";
};
};
};
};
Save the file and run the following command to install the overlay
sudo orangepi-add-overlay i2c-ds1307.dts
Edit /boot/orangepiEnv.txt and add the following two lines
overlays=i2c3
user_overlays=i2c-ds1307
My /boot/orangepiEnv.txt file looks like this:
verbosity=1
console=both
disp_mode=1080p60
fb0_width=1920
fb0_height=1080
debug_uart=ttyS0
rootdev=UUID=c310ed9a-2899-4a7b-80c6-efe4d6118443
rootfstype=ext4
overlays=i2c3
user_overlays=i2c-ds1307
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
Save and reboot
Once rebooted you can check if the RTC is being used as the hardware clock by running the following command.
sudo hwclock -r -f /dev/rtc1
It should return the current date and time: 2023-06-16 11:56:39.445141+00:00
Hopefully you can use the steps above to get the RTC Pi working on your Orange Pi. If you are currently getting UU instead of 68 when you run i2cdetect that could mean the ds-1307 module is being loaded at boot. Check the
/boot/orangepiEnv.txt file to see if it contains "
user_overlays=i2c-ds1307". If it does, removing this and rebooting should allow the RTC Pi to appear in i2cdetect as 0x68 again.
If you have any problems after going through the steps above, please let me know. If you have a spare SD card it may be worth setting up a clean install of Debian to test with to check that the RTC Pi is working correctly.
Best regards
Andrew
==============================================================================================================================================================================
Hi George
On my Orange Pi Zero 2 it has the same issue as yours where after a reboot it changes the RTC Pi to RTC0.
After a bit of searching around various forums and tutorials I found a solution that should work to make the RTC Pi the default hardware clock.
Edit
/etc/rc.local
Add the following line:
hwclock --hctosys -f /dev/rtc0
Save the file and reboot. Try running the "
date" command.
Hopefully it should show the correct date from the RTC Pi.
To set the time on the RTC Pi you can use the following command.
sudo hwclock --set --date '2023-06-28 13:23:00' -f /dev/rtc0
You will need to either reboot or run "
sudo hwclock -s --hctosys -f /dev/rtc0" to copy the date from the RTC Pi to linux.
Hopefully this will work on your Orange Pi. If you have any problems please let me know.
Best regards
Andrew