assuncao
Posts: 48
Joined: Mon Oct 21, 2013 7:24 pm

How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 6:53 pm

Hi,

I would like to know how many devices can I connect to Raspberry Pi. I pretend to use about 12 RFID like these:
http://www.nxp.com/documents/data_sheet/MFRC522.pdf

Datasheet says there are 6 bit address, but I don't know about I2C protocol, I'm asking here before to buy because it should take about a month to get here, then I have time enough to study about it.

Thanks again!
Erik Figueiredo

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 6:59 pm

As far as I'm aware you can as share many i2c devices within reason but they must have different addresses.

Richard S.

assuncao
Posts: 48
Joined: Mon Oct 21, 2013 7:24 pm

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:10 pm

redhawk wrote:As far as I'm aware you can as share many i2c devices within reason but they must have different addresses.

Richard S.
Hi Richard,

Thanks for your answer! It is possible to share many i2c devices... But does it depend also of the kind of device or not? I mean, I need to connect those RFID readers and they accept i2c, but could they apply any limitation about how many devices / address I can have? Thanks!

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:25 pm

The type of device isn't important but if 2 or more share the same address line then you cannot communicate with them.
For example the TEA5767 and RDA5807M FM Radio module both use the same 0x60 I2C address.
Individually they work fine on the Pi but I cannot connect both modules together because they both use the same 0x60 address.

Richard S.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5348
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:34 pm

assuncao wrote:
redhawk wrote:As far as I'm aware you can as share many i2c devices within reason but they must have different addresses.
Richard S.
Hi Richard,
Thanks for your answer! It is possible to share many i2c devices... But does it depend also of the kind of device or not? I mean, I need to connect those RFID readers and they accept i2c, but could they apply any limitation about how many devices / address I can have? Thanks!
To add to @redhawk's comment - based upon the output of i2cdetect on a Pi there are 117 available "slave addresses" however, AFAIK, many** i2c (slave) devices only have 3 address control lines leading to 8 possible unique addresses for a single device type (but some similar devices use different address sets). The other potential issue is the drive capability (or "fan out") of the i2c bus itself (especially the clock). That I'm not too sure about since I've only played around with a few devices at a time so far, but the chip datasheets should provide more detailed info.
Trev.
** or at least the "low cost" ones I've used so far. ;)
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

MaxK1
Posts: 1043
Joined: Sun Aug 26, 2012 11:34 pm

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:38 pm

Would a Rev 2 do it for you? (2 x i2c busses) Or does it not matter that there are 2 separate busses?
You are in a maze of twisty little passages, all alike.
When General Failure and Major Disaster get together, Private Parts usually suffers.

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:43 pm

redhawk wrote:The type of device isn't important but if 2 or more share the same address line then you cannot communicate with them.
For example the TEA5767 and RDA5807M FM Radio module both use the same 0x60 I2C address.
Individually they work fine on the Pi but I cannot connect both modules together because they both use the same 0x60 address.

Richard S.
Hi,

You can make use of sub addressing if both modules share the same address. See http://www.nxp.com/documents/data_sheet/PCA9544A.pdf
Ferdinand.
Success with your project!
Ferdinand

User avatar
Douglas6
Posts: 4812
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:51 pm

As far as I can see, and as you mentioned, these look like they have 6 I2C address pins, so I would expect a max of 2^6 = 64 of these devices on the same I2C bus, each with a unique address.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5348
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 7:58 pm

Douglas6 wrote:As far as I can see, and as you mentioned, these look like they have 6 I2C address pins, so I would expect a max of 2^6 = 64 devices on the same I2C bus, each with a unique address.
Thanks @Douglas6 - I missed that in the O.P. :oops:

To add to my earlier comments - an example of similar devices with different address sets are the PCF8574 and PCF8574A 8-bit port expanders. The first device uses addresses in the range 0x20 - 0x27 and the second 0x38 - 0x3F

Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
mikronauts
Posts: 2743
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: How many I2C devices can I connect to Raspberry Pi?

Mon Feb 17, 2014 8:10 pm

Rule of thumb:

The slower you run I2C, the longer cable run / more devices you can have on one bus

Basically, the longer the cable, the higher the capacitance. You may also have to deal with more reflections, and long cables pick up more electrical noise.

I2C was designed as an inter-integrated circuit bus, to connect devices on the same pcb, or close by. Based on what I've read, assuming I remember correctly, you will be fine with a total length of 1 meter, at 400kbps, which matches my experience. I've heard of 4 meters being OK, but I have not personally tried that yet.

You can also use bus extenders, NXP has some nice ones.
assuncao wrote:Hi,

I would like to know how many devices can I connect to Raspberry Pi. I pretend to use about 12 RFID like these:
http://www.nxp.com/documents/data_sheet/MFRC522.pdf

Datasheet says there are 6 bit address, but I don't know about I2C protocol, I'm asking here before to buy because it should take about a month to get here, then I have time enough to study about it.

Thanks again!
Erik Figueiredo
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Return to “Beginners”