blasters
Posts: 2
Joined: Sat Dec 31, 2016 11:55 am

RTC I2C on pin 27-28

Sat Dec 31, 2016 3:30 pm

Hello,

i'm trying to connect RTC DS3231 on my raspberry pi3.

My problem is that the pins on GPIO are almost finished, and i cannot connect on pins (i2c) 03 e 05 because i use it for other functions.
I read on internet that pins 27 (i2c ID EEPROM SD) and 28 (i2c ID EEPROM SC) have I2C protocol.

Is it possible connect RTC on this pins? or are they used for other internal functions?
if yes, will i have a problems with library?
Thanks

User avatar
rpdom
Posts: 15604
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: RTC I2C on pin 27-28

Sat Dec 31, 2016 3:38 pm

The EEPROM ID pins are reserved for use by HAT boards and some internal functions (on the Pi 3). Also trying to use it can interfere with the functioning of the Pi.

Does the RTC clash with other devices on pins 3 and 5? If not, they can share the bus.

User avatar
joan
Posts: 14474
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RTC I2C on pin 27-28

Sat Dec 31, 2016 3:42 pm

You can't use GPIO 0/1 (pins 27/28) for hardware I2C on the Pi3.

I suggest you try software bit banging with the GPIO kernel module.

Add the following line to /boot/config.txt and reboot.

dtoverlay=i2c-gpio,i2c_gpio_sda=27,i2c_gpio_scl=28

This will create a bus /dev/i2c-3 which you should use to communicate with your RTC.

You will probably need to add pull-ups to 3V3 on pins 27/28. Anything in the 5k region should be okay. To test you could probably just enable the internal pull-ups.

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RTC I2C on pin 27-28

Sat Dec 31, 2016 3:45 pm

If you enable i2c_vc then the I2C stuff on pin #27&#28 will work, but the camera and official display will break. And it will cause trouble with the LEDs on an RPi3B.

Also any HAT with an EEPROM will fail.

It is not a general use programming interface, so use it at your peril. Any kernel or firmware change could break your system.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: RTC I2C on pin 27-28

Sat Dec 31, 2016 6:15 pm

DougieLawson wrote:If you enable i2c_vc then the I2C stuff on pin #27&#28 will work
Briefly if you are lucky. The very next time the Gpu accesses the Gpu expander it will remux away from pins 27/28 and you'll lose access to your rtc.
, but the camera and official display will break. And it will cause trouble with the LEDs on an RPi3B.

Also any HAT with an EEPROM will fail.

It is not a general use programming interface, so use it at your peril. Any kernel or firmware change could break your system.
Most likely on recent firmware the Gpu functions will sort themselves out to the detriment of your kernel module.
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.

Return to “Interfacing (DSI, CSI, I2C, etc.)”