Electronic – Distance problems with I2C connection for multiple devices

i2cpullup

I'm considering using the I2C bus protocol to connect up to 100 devices (worst case scenario) to a motherboard to avoid using serial-port connection with each one.

The problems I face are:

  • I need them to be at a distance as far as 3-5 m
  • The maximum voltage should be 5V

I've tried to find an answer to the problem and I've come across a couple of solutions such as setting pull-up resistors to counter the increase in capacitance, but I've found mixed opinions and articles and I can't reach a solution.

Do you think this is viable? What other options do I have?

Best Answer

IIC is fairly high impedance due to being passively pulled up and that the pulldown current must be rather small. The pullups are usually a few kΩ minimum, which is the impedance of the lines when idle. This is usually fine on a single board above a consistent ground plane, but extending such lines 5 meters is asking for trouble. If you really have to do this, make the data rate low and encapsulate every packet with a checksum.

Ultimately you end up trading data rate with reliability. You can probably get away with 100 kBit/s or so (just guessing). That would give the lines 5 µs to settle after each edge before they should be looked at.

A probably better option would be to use CAN. 100 devices is getting near the limit but is still within spec. The common MCP2551 is specified to support 112 devices, for example. CAN is a differential bus with 120 Ω pull-together resistors at each end. The differential nature and much lower impedance (60 Ω) make is suitable for going off board. It was initially designed for use in cars, which are notorious for being electrically noisy.

5 meters is short for CAN. If you use the right twisted pair, daisy chain topology, and properly terminate the bus at each end, you should be able to do 1 MBit/s without problems.

Another advantage of CAN is that silicon to implement the low levels of the protocol is built into many microcontrollers. The lowest level firmware sends and receives whole packets. The hardware takes care of encoding the data onto the wire, collision detection with backoff and retry, and checksum generation and validation.