8
\$\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\$
  • \$\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 May 8 '14 at 15:01
  • \$\begingroup\$ I added a summary, is it narrow and specific enough? \$\endgroup\$ – DaJF May 8 '14 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 May 8 '14 at 16:06
  • \$\begingroup\$ @JoeHass Is the question now narrow enough? If not, what more do I need to do? \$\endgroup\$ – DaJF May 19 '14 at 11:38
  • \$\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 Apr 21 '18 at 12:57
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\$
  • \$\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\$ – DaJF May 19 '14 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 May 19 '14 at 17:35
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\$
  • \$\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\$ – DaJF May 8 '14 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\$ – Spehro Pefhany May 8 '14 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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