Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: I2C over rather long wires, how to?

  1. #1

    I2C over rather long wires, how to?

    I need to have I2C communication between some Teensies over rather long wires (don't know the exact length yet, it should be between half and one meter). I've been reading that I2C should happen at a rather short distance, and I remember reading some post in this forum saying that additional hardware is needed if I2C is to be run in long wires, but I can't find that post again.

    Since I'm designing some PCBs for this, I thought it's best to ask first before I go on and try my luck. So, how can I get I2C communication over, say, a wire that's one meter long?
    Thanks

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,256
    I haven't used any of these things, but a google search yielded:


    But more often when people talk about signalling over a distance, it tends to go to serial protocols designed for longer distances such as RS-485, RS-422, or RS-423:


  3. #3
    What I understand from reading all the above is that one meter shouldn't be an issue. My setup though might be a little bit more problematic as I will probably use more than one slave, and I don't know if their wires add up to the total capacitance that can cause issues.
    Here's a schematic describing the setup:
    Click image for larger version. 

Name:	I2C_length_issue.png 
Views:	3 
Size:	22.6 KB 
ID:	17550
    If the greatest length of this setup is one meter, the shortest is 15 cm, and the middle length is half a meter, does it mean that the total cable length should be considered to be 100cm + 50cm + 15cm = 165cm? In this case the wires labelled "SLAVE1_SDA" etc. will also add to the whole length?

    It's quite unlikely that I will use 9 slaves, but the setup should provide various places where the slaves can be wired, that's why I inserted all these in the schematic. If I am to use, say three slaves in the above setup, will using a lower pull-up resistor fix any possible issues? What's the lowest resistor value that can be used with I2C on a Teensy?

  4. #4
    Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    79
    Meter is no issue. Put pull-ups on both ends. 30 feet is the "theoretical " limit.

    Or buy a couple of buffer chips if you're worried. I'm looking for the part numbers

  5. #5
    Quote Originally Posted by ETMoody3 View Post
    Meter is no issue. Put pull-ups on both ends. 30 feet is the "theoretical " limit.

    Or buy a couple of buffer chips if you're worried. I'm looking for the part numbers
    30 feet is approximately 10 meters, right? I'm not even getting close to that length. I'm using pull-up resistors on the master and all slaves, so I guess there shouldn't be a problem there either. Thanks both for the answers, hope I'm on the right track!

  6. #6
    Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    79
    Yes, 10 meters is approximately 30 ft. As you already know, capacitance is your enemy. Pullups on both ends works reliably

  7. #7
    Member ETMoody3's Avatar
    Join Date
    Mar 2014
    Location
    New Ulm, Mn
    Posts
    79
    Ah, found them

    Texas Instruments P82B715

    http://www.ti.com/lit/ds/symlink/p82b715.pdf

  8. #8
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Location
    Florida
    Posts
    343
    Iíve had success running i2c over a cable that was definitely at least 30ft possibly upwards of 50ft with no issues running at 100khz. They were connected to a Teensy LC and a level shifter because the receiving device was 5v and there was only pull-up resistors on the Teensy side.

    In my case I was replacing an old system that used 8051 microcontrollers that communicated over i2c from an ISA card to peripheral devices. On the ISA cards they used a 3ma constant current sources instead of pull-up resistors and they had resistors running inline with the SDA and SCL lines before each 8051.

    So I used a Teensy LC to replace the ISA cards and the old computer that was used to run them so I could interface with the peripheral devices over USB with a modern computer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •