njsss
Posts: 35
Joined: Fri May 20, 2016 9:36 pm

How to set up i2c for rtc?

Fri Feb 15, 2019 11:31 pm

I have used adafruit RTC pcf8523 with raspberry pi. Now I am trying to get it to work on CM3+.

I tried to edit the config.txt to set it on pins 22/23 or 23/24 (as appeared default in i2c-gpio)

Code: Select all

# Add new I2C
#dtoverlay=i2c-gpio,i2c_gpio_sda=22,i2c_gpio_scl=23
#dtoverlay=i2c1-bcm2708,sda1_pin=22,scl1_pin=23,pin_func=6
dtoverlay=i2c-gpio
dtoverlay=i2c-rtc,pcf8523

The device was detected as an i2c, but doesn't appear to be recognized.

Code: Select all

$ i2cdetect -y 3

shows 68 at location 68, but probe return error

Code: Select all

$ dmesg | grep pcf8523

rtc-pcf8523: probe of 1-0068 failed with error -121
failed to access rtc

Code: Select all

$ sudo hwclock -D -r

hwclock from util-linux 2.29.2
hwclock: cannot open /dev/rtc: No such file or directory
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
Finally it doesn't seem the gpios were changed after all.

Code: Select all

$ sudo raspi-gpio get

GPIO 0: level=1 fsel=0 func=INPUT
GPIO 1: level=1 fsel=0 func=INPUT
GPIO 2: level=1 fsel=4 alt=0 func=SDA1
GPIO 3: level=1 fsel=4 alt=0 func=SCL1
GPIO 4: level=1 fsel=0 func=INPUT
......
GPIO 22: level=0 fsel=0 func=INPUT
GPIO 23: level=1 fsel=0 func=INPUT
GPIO 24: level=1 fsel=0 func=INPUT
How to fix it? Thanks!

User avatar
DougieLawson
Posts: 40824
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: How to set up i2c for rtc?

Sat Feb 16, 2019 7:50 am

njsss wrote:
Fri Feb 15, 2019 11:31 pm

Code: Select all

$ dmesg | grep pcf8523

rtc-pcf8523: probe of 1-0068 failed with error -121
Your RTC hardware is broken or not wired to the I2C sda/scl pins correctly.
https://pinout.xyz/pinout/i2c
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10576
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: How to set up i2c for rtc?

Sat Feb 16, 2019 9:52 am

I2c-rtc is set up to talk to an rtc on i2c_arm, not an i2c_gpio device.
Documentation of overlays is in the readme https://github.com/raspberrypi/linux/bl ... ays/README

There's also an i2c-rtc-gpio overlay that is the same as i2c-rtc but using i2c_gpio. Switch to using that and it should work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

njsss
Posts: 35
Joined: Fri May 20, 2016 9:36 pm

Re: How to set up i2c for rtc?

Mon Feb 18, 2019 5:02 pm

6by9 wrote:
Sat Feb 16, 2019 9:52 am
I2c-rtc is set up to talk to an rtc on i2c_arm, not an i2c_gpio device.
Documentation of overlays is in the readme https://github.com/raspberrypi/linux/bl ... ays/README

There's also an i2c-rtc-gpio overlay that is the same as i2c-rtc but using i2c_gpio. Switch to using that and it should work.
Thank you, it works! Now I need to figure out how to add other i2c to the same pins.

Return to “Compute Module”