I2C and RTC Communication

Started by Anushka, September 17, 2022, 09:27:11 AM

Previous topic - Next topic

Anushka

I am using PCF8583 RTC with my A20-Olinuxino-Lime2 with I2C communication but my oimex doesn't detect rtc. I am using PB18(SCK) and PB19(SDA) as /dev/i2c-1 port pins.
The slave address of my rtc is A2h. This is my code:

from  pyA20Lime2 import i2c

i2c.init("/dev/i2c-1")
i2c.open(0xA2)
i2c.write([0x1A, 0x20])
i2c.close()

After running this code I get following error:
Traceback (most recent call last);
  File "/home/olimex/Desktop/i2c.py", line 4, in <module>
    i2c.open(0xA2)
OSError:  [Error 22] Invalid argument

I want to use rtc with my olimex for project what should I do for it to work???

LubOlimex

#1
What Linux image are you using? Check if that i2c you are trying to use free and enabled with "olinuxino-overlay". Not sure if the python modules work with latest images, maybe use the information we published in chapter "8.7. I2C" on page 31 from this guide:

https://github.com/OLIMEX/OLINUXINO/blob/master/DOCUMENTS/OLIMAGE/Olimage-guide.pdf
Technical support and documentation manager at Olimex

Anushka

I am using A20-Olinuxino-bullseye-base-20211130-145129 Linux image. I have enabled my i2c by "olinuxino-overlay" already.
Above information is not sufficient. Can you please elaborate more on how to connect external devices through I2C ports. My device has address A0h,A2h.

LubOlimex

Well probably the easiest way is using one of the ready Linux drivers for your RTC. Like this one:

https://github.com/torvalds/linux/blob/master/drivers/rtc/rtc-pcf8583.c
Technical support and documentation manager at Olimex