I2C Distance

I am creating a network with 1 master and around 10 slaves using I2C. What can be the maximum distances between the Master and slave? I have read somewhere that distance is low. Is it true? Can distance be increased to say around 75m - 100m?

Can distance be increased to say around 75m - 100m?

For such distances one typically uses - ethernet, RS485 or sometimes XBEE

IIRC - I2C will go up to 6 meters or 20 feet - you might need to tweak with the pull up resistors etc.

Myabe this is interesting - I2C - RS-485 adapter

What is the datarate / sec you need? Tell us about your application, there are allways other solutions

What is the data rate / sec you need? Tell us about your application, there are always other solutions

Data rate is quite small. whenever master asks for the status slaves respond with 1 byte of information. Its for hoe automation device. so length between the master and slave can extend upto 100m.
i2C cant do this?? =( Which is the best method to move forward with?
In the link you gave it shows conversion from i2c to RS 485. Is it possible? Is it the way forward for me via RS 485?
Dont have much idea about RS 485. :~

Its for hoe automation device.

It's almost spring. Lots of weeding to be done. I'm interested in this automated hoe of yours. Can I sit and drink beer and watch it do the weeding?

It's almost spring. Lots of weeding to be done. I'm interested in this automated hoe of yours. Can I sit and drink beer and watch it do the weeding?

XD XD XD XD XD XD XD U cracked me up... :stuck_out_tongue_closed_eyes:

Things that a small spelling mistake can do.. :astonished:
Its HOME not hoe... HOME! HOME! HOME! :sweat_smile:

Any help please???

I used P82B715PN I2C extender IC from Philips. Very cheap and easy:

http://pdf1.alldatasheet.com/datasheet-pdf/view/15876/PHILIPS/P82B715PN.html

I used P82B715PN I2C extender IC from Philips. Very cheap and easy:

P82B715PN pdf, P82B715PN Description, P82B715PN Datasheet, P82B715PN view ::: ALLDATASHEET :::

Thanks :slight_smile:
How much distance can I can expect by using this IC?
Or should I go for RS 485? I am totally confused. :frowning:

RS-485 is not very compatible with i2c. There are some chips that split the signals and that would allow 485 to be used but that's not very suitable for what you are doing IMO.

The P82B715PN is probably your best bet, either that or ditch i2c and use async serial. That would mean having a small processor at each sensor though.

How much distance can I can expect by using this IC?

Don't know, from what I've seen they never quote distances in the docs for these i2c extender chips, you need someone who has tried it.


Rob

On these questions always go back to the specs

http://www.nxp.com/acrobat_download2/literature/9398/39340011.pdf

http://ics.nxp.com/products/i2chubs/

Long Distance I2C or SMBus
The P82B715, P82B96, and PCA9600 are specifically designed to extend the reach of the I2C or SMBus over long distances, in the range of kilometers, depending on the maximum bus speed. This allows the designer to use I2C to interconnect equipment cabinets or for large area systems such as warehouse pick and place systems.
The P82B96 and improved PCA9600 use a static level offset on the slave side to isolate noise and loadings on either side of the device, allowing 4000pF on the high drive side. The nominal offset is 0.8V. That VOL level may create worst-case design tolerance problems with slave devices that do not use I2C switching levels, for example TTL levels. It also precludes operation with other bus buffers using special non-compliant I2C levels. A lower VOL level (<0.4V), combined with the ability to operate with any master, slave, or bus buffer, is the primary advantage of using the P82B715 for long-distance buses, but it doesn't isolate bus capacitance the way the P82B96 and the improved PCA9600 do, so the total system loading must be less than 3000pF.

You just need to use the search engines...

Thanks for the replies... :slight_smile: Man, I am in a pickle now.. :~ I coded an entire project on this using i2c and wire.h and I never thought about the distance problem... :frowning:
So I really have to change the protocol i used for this project? Or use i2c repeaters as mentioned by Garynomad and WiIIR?
Anyone here who has worked with the i2c repeaters?

We all make minor errors from time to time. Get over it.. :stuck_out_tongue:

We are Talking about $8-$12 or so... for two of them

DIP
http://parts.digikey.com/1/parts/1546480-ic-i2c-bus-extender-8-dip-p82b715pe4.html

SOIC (More $$$)
http://parts.digikey.com/1/parts/1546476-ic-i2c-bus-extender-8-soic-p82b715d.html

I think it will work. NXP is reputable and so is TI. I am sure there would be complaints galore if it did not work.

Well will give it a try then.. :slight_smile:
Thanks again for all your help..

I use the P82B715PN with about 20meter Cat-5 UTP cable. Works fine. :slight_smile:

This is great information. A couple questions:

  1. How many of these extenders can be used on a single bus? I thought I saw a limit of 30 somewhere.... Would you still be able to have the maximum number of devices on a bus as provided by the I2c spec if each connected to the bus via one of these extenders?

  2. It seems that pull up resistor value is critical with this device. But what if you don't know the total number of devices that will be connecting to the network? Can you design for the max number of devices in terms of pull up resistor calculations and still have everythig work when fewer than the maximum number of devices are on the bus?

  3. How are these extenders different from the mosfet-based level shifting circuit described at the end of the I2c spec? Until reading about the dedicated bus extenders, I had planned on using the level shifting circuit on every one of my slave devices to provide the same type of bus extendability provided by these chips.

  4. If you use these chips, how many wires do you need for the long-range bus? In the diagrams it looks like you could get by with just two wires but then other diagrams also show 4. I have a need to minimize the number of wires on the bus (I can do 3 wires max) while maximizing the number of slave devices supported as well as the total bus length.

Any suggestions would be much appreciated. Thank you!

--Rob

WillR:
http://www.nxp.com/acrobat_download2/literature/9398/39340011.pdf

http://ics.nxp.com/products/i2chubs/

Long Distance I2C or SMBus
The P82B715, P82B96, and PCA9600 are specifically designed to extend the reach of the I2C or SMBus over long distances, in the range of kilometers, depending on the maximum bus speed. This allows the designer to use I2C to interconnect equipment cabinets or for large area systems such as warehouse pick and place systems.

The 9600 works great for longer distances with little electromagnetic interference. Differential signaling is used in RS485 to transmit a single over two complementary signals sent over two paired wires. The 9600 chip breaks the I2C clock and data signals into inbound and outbound data lines. The Am26LS32 and AM26LS31 can be used to then turn each of the directional signals into a differential pair. To do this, I have used the i2C breakout board (http://sjtbits.com/i2c-to-differential-breakout-board/) by sjtbits.com. If believe they have the schematics on their site if you are interested in the wiring details.

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.

Just came across another very good source of information in respect of what cables to use etc.

http://ics.nxp.com/support/documents/interface/pdf/an444.pdf

Very recommended reading for anyone dealing with I2C over longer distances

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:

I'm talking about software library and reply is about hardware and same thing again and again.
I'm explained my goal in another topics and do not want to offtopic this one.
If I have some free time, I'll try to find out better solution for stabilizing I2C library.
BTW Wayne's timeout doesn't helps, I going to figure figure out why.

Of course the hardware is where the problem is, because one those length of cable your signal degrades considerably!
The internal pull-up resistors are less than ideally dimensioned for I2C bus operation. Right the first measurement in this article explains that:

Then you are using CAT5 cable with a nominal capacitance of 50pf/m. The I2C bus capacitance is supposed to not exceed 400pf and that does not only refer to the cable but the entire system. Past 5m of cable length your system capacitance will degrade your signal to a point where the I2C bus simply will not function reliably. Lowering the operation frequency of the I2C bus will only remedy that to a degree.

In the app note I linked to above (here it is again : http://ics.nxp.com/support/documents/interface/pdf/an444.pdf) they tested several different cables that have a significantly lower nominal capacitance than CAT5 cable. They specifically did not use twisted pair as the I2C signal is bidirectional/unbalanced.

If you really need to go in the range of 200m with CAT5 cable (or even "just" 50) you should use e.g a PCAA9600, which is specifically designed to separate the bidirectional I2C-bus signals into unidirectional TX and RX signals and enables the SDA and SCL signals to be transmitted via balanced transmission lines.

Perhaps you start using an oscilloscope so you have positive verification that your design works :wink: