I2C Distance

kaor:
Tested connection via CAT5 2 pairs over 200 meters.
No external parts but wires (used internal pullups).
Works almost nice, just set SCL speed to 500hz.
I'm going to add just capacitors to remove SCL spikes from SDA signal but during test I ran into one problem.
In some circumstances, I2C get stuck. I'm using standard Wire library.
Code hangs in twi_readFrom() function waiting for TWI_MRX changed value.
I tried another custom I2C library (by Wayne Truchsess), hangs anyway.
I met the same problem year ago and as I see there is no library guaranteeing 100% stable work.
I don't mean 100% clear data via I2C, I mean not hanging code even when there is error in I2C transmission.

Before you start arbitrarily adding components like capacitors I'd suggest you start reading some background info on I2C. As you've already downloaded Wayne's I2C library, perhaps you found the info on the same website referring to the dimensioning of Pullup resistors ?

From your description it appears that the I2C bus simply locks up. I've had the same problem in one of my projects (10 devices over about 5 meters). Wayne's library allows to set a timeout value after which the I2C bus is restarted/reset, which is something the standard Arduino TwoWire library does not offer. If the data you are transferring is not critical that may help your situation. However, that limits the effects but does nothing to deal with the root cause of the problem, which is likely system capacitance and noise. The Application Note I linked to in my post above contains some valuable information that does not only apply when using the I2C bus extenders :wink: