15
\$\begingroup\$

I have a project that requires to do I²C/I2C/TWI over a long distance (30 to 40 meters).

I've seen some people suggesting lowering the clock-rate to somewhere around 500 Hz, to mitigate the effects of the capacitance of such a long line I assume? The components I'm using require at least the standard 100 kHz clock-rate. I did some further research and found among answers to another question a suggestion to use a P82B96 level shifter. In the datasheet they give examples of using them on lines of even 100 meters:

I2C_longDistance

I've come across another way of shifting levels through a breakout board from adafruit, which is just a mosfet (bss138) with two pull-up resistors (one for each side/voltage). They got the idea from an application note from NXP (AN10441), and two of the channels on there could be used like this:

mosfet level shifting

Now I wonder: which solution is best? Or is there something I have overlooked? And also, is 5V enough to ensure a good connection? Would there be an advantage to using an even higher voltage like 12V?

\$\endgroup\$
6
  • \$\begingroup\$ As written, your question is probably too broad for this site's format. Try to narrow your question down and make it very specific. \$\endgroup\$
    – Joe Hass
    Commented May 8, 2014 at 15:01
  • \$\begingroup\$ I added a summary, is it narrow and specific enough? \$\endgroup\$
    – KJdev
    Commented May 8, 2014 at 16:03
  • \$\begingroup\$ You should also specify the maximum wire length to the sensors and give an idea of what "low cost" means to you. Are you expecting to provide power to the sensors over the same cable? \$\endgroup\$
    – Joe Hass
    Commented May 8, 2014 at 16:06
  • 1
    \$\begingroup\$ Hi, I know this is an old question but what did you end up doing in the end? I have exactly the same question as you, similar distances involved and minimum 100kHz clock rate. I'd be interested to know what worked for you, thanks. \$\endgroup\$
    – pcdev
    Commented Apr 21, 2018 at 12:57
  • 1
    \$\begingroup\$ I know this is an old question but the bottom scheme is a level shifter, has nothing to do with long distance support for I2C. The 82B96 is the device you need. It translates a voltage to a current and that allows long distance travelling for the signal On the other side of the cable the current is again translated into a voltage to "reconstruct" your I2C signal. \$\endgroup\$
    – GeertVc
    Commented May 13, 2023 at 14:27

4 Answers 4

1
\$\begingroup\$

I think you are on the right track with something like the NXP P82B96. If you have a look at Figure 14 and the associated text the datasheet discusses using cable length of up to 250 m with data rates over 100 kHz.

There are many I2C temperature sensor available that can give you accuracy of a few degrees celsius without calibration and without any added analog circuitry. Since you are bringing the data back for processing anyway, filtering out noise would be very easy.

If you are concerned about the wiring capacitance you might be better off with unshielded twisted pair rather than a shielded cable.

\$\endgroup\$
3
  • \$\begingroup\$ Could the P82B96 be replaced by the mosfet alternative? For the price of one P82B96 I can literally buy 100 bss138 mosfets (I can give you the links if you want). Indeed, like you said, I've found what looks like a suitable temp sensor: LM75A. As to the choice between a shielded or an unshielded cable, it seems it's a matter of which problem you want: possible interference (unshielded) or line capacitance (shielded), is this a correct assumption? Is one more prominent than the other? I have no idea how to determine this. Thanks btw! \$\endgroup\$
    – KJdev
    Commented May 19, 2014 at 16:26
  • \$\begingroup\$ I don't think you can replace the P82B96 with the MOSFETs for long lines. It looks like the repeater IC actually provides some amplification, where the MOSFETs are primarily providing a voltage level shift. I'm afraid I'm not sure how to make the call on the cable...you should look at the NXP application note AN255. They talk about using twisted pair wiring but don't mention a shield. For digital signals the noise might be less of an issue than the capacitance. \$\endgroup\$
    – Joe Hass
    Commented May 19, 2014 at 17:35
  • \$\begingroup\$ @JoeHass I agree - those op amps look like they're doing something non trivial. Do you think they're doing some kind of delta sensing as a noise cancellation mechanism like what happens with twisted pair ethernet or are they just simply amplifying? \$\endgroup\$
    – Volksman
    Commented Jan 23, 2021 at 22:26
2
\$\begingroup\$

You can probably get away with the DS18B20 sensors by using shielded CAT5 or similar cable. It's only thermal measurements, so if some readings get corrupted you can make your program robust enough to deal with that (it's good practice anyhow).

For chain restaurant use, I've designed what are called RTU (rooftop unit) controls that work on multiple passive sensors (they use interchangeable NTC thermistors, which require no calibration for comfort heating). It's much easier to filter noise out of a passive sensor. Another set of installations (a major North American automotive complex) used platinum RTDs with signal conditioners- very accurate and stable devices. You should decide the sensor first, then look at how it might be interfaced- any of these sensor options are suitable for your application (though the RTDs might be overkill).

In case it's not clear, I'm suggesting a "star" configuration of sensors around your processor.

If you really want to use a "bus" (other than one-wire or I2C), you'll need smarts at the ends, which means a processor in some form. If you're going whole-hog you might want to consider using wireless sensors that communicate via some ISM band that's legal in your locality. Alternatively, you could use one sensor per Pi and have them talk to each other via your WiFi intranet.

\$\endgroup\$
2
  • \$\begingroup\$ Right now I'm a the "determining what to buy" stage, so either the bus or the sensor can determine the other. The only requirements I have for these are easy to use and extendable. The reason for choosing a bus are that I prefer not to run a cable to each sensor (which is what you seem to suggest, or did I interpret the "star" wrong?). Is I²C a viable protocol to use on a cable that can be 30M/90FT? \$\endgroup\$
    – KJdev
    Commented May 8, 2014 at 21:17
  • \$\begingroup\$ Yes, that's what a "star" is- wires from the controller to each sensor. I2C at 30m.. well.. I've heard claims it's possible at very low speeds, but I would not count on it working well. \$\endgroup\$ Commented May 8, 2014 at 21:26
2
\$\begingroup\$

Adafruit now (2021) sells the "LTC4311 I2C Extender / Active Terminator". It works by monitoring the SCL and SDA lines and then injecting current during the positive transitions to help overcome capacitive line loads and sharpen the waveform. I've not implemented any yet myself, but the description says they've been able to read sensor data at 100kHz over 100m of Cat5 cable, and 400kHz at a few meters.

https://www.adafruit.com/product/4756

You only need one of these near the head end of the bus, with no other wiring modifications. Seems like this could be a much simpler and cheaper off-the-shelf solution than other options like RS-485 or the PCA9615-based extenders that SparkFun offers.

\$\endgroup\$
2
\$\begingroup\$

Extender: NXP PCA9617A works as both level translator and extender and supports Fast-mode Plus (1Mbps).

Isolator: ISO1540, ISO1640, ADuM1250

\$\endgroup\$
1
  • \$\begingroup\$ Can you provide a schematic or block diagram, or maybe a little more description? \$\endgroup\$
    – Voltage Spike
    Commented Feb 2, 2022 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.