3
\$\begingroup\$

I would like to connect a BME280 sensor to an Arduino board through the i2c bus connection. I read that i2c was not meant to be used over long wires and will not work properly over 50cm. I want to get it to work within 5-15m. Is there some sort of chip or device I can to attach to one or both sides of an i2c connection to extend the wire length? I would like to use only one power source, not two, and have the wire carry the power over those 5-15 meter as well, if that is possible.

P.S. Pardon my drawing. My electronics skills aren't up to the level of making a schematic enter image description here

\$\endgroup\$
1
  • 1
    \$\begingroup\$ What speed is enough? A reminder that 100 kHz I2C is transmitted via HDMI cables without any special tricks so it is possible without extender chips. \$\endgroup\$
    – Justme
    Nov 24, 2019 at 13:42

3 Answers 3

4
\$\begingroup\$

I suggest you read AN10710 by NXP, which discusses the P82B715 I2C Bus Extender. This should cope with 15m of cable, particularly if you run I2C at less than the maximum speed.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 15 m might be pushing it for the P82B715, depending on the environment. That device can drive higher capacitance lines than the transceivers built into typical microcontrollers and slave devices, and it uses a higher voltage to provide some mitigation against attenuation and capacitively coupled noise, but fundamentally it's still sending using single-ended, open-collector signalling which isn't great for long-haul links. \$\endgroup\$ Nov 24, 2019 at 22:20
1
\$\begingroup\$

A good way to get distance over a cable is to not use I2C protocol. I2C has to support bidirectional flow on the SDA line that does not have convenient method to support the direction changeover for the signalling. Same holds true for the SCL line if the target device does clock stretching.

A better way to attack this is to use the ASYNC UART port of the Arduino's RxD and TxD lines. You would interface these through a chip like a MAX232. In the far end you use another MAX232 to convert the signals back to the logic level RxD and TxD signals that you feed to a small MCU. This remote MCU then connects to the I2C based sensor. A small bit of firmware in the MCU communicates with the Arduino via ASYNC UART to then read/write the sensor as needed per the commands received from the Arduino.

================

If you want to investigate an actual I2C bus buffer chip that would eliminate the need for the extra MCU then take a look at this other question. That discusses the use of the PCA9600/PCA9601 dual bi-directional buffer chip. These devices have special logic that is designed to be able to determine when a direction change is occurring (i.e. when the slave end is driving the bus) and switch the buffer chips accordingly. It is suggested to read the data sheet carefully and any related App Notes to understand how these work in order to be successful with using them.

\$\endgroup\$
4
  • \$\begingroup\$ Totally agree with your first sentence, but IMO a whole extra microcontroller is way overcomplicated for this application. \$\endgroup\$ Nov 24, 2019 at 22:06
  • 1
    \$\begingroup\$ @pericynthion - You will have to evaluate the approach to use. I simply made two suggestions on how you could move forward. As to the extra MCU idea, sometimes there may be very good reasons to go with that approach. One would be where you wanted to use RS485 protocol so you could transmit 2 - 3km. Another would be that you had some additional capability needed at the remote end such as several sensors with different interfaces or specialized control via GPIOs. \$\endgroup\$ Nov 24, 2019 at 22:23
  • \$\begingroup\$ Not sure who downvoted but I sure wish they had the guts to say so and why. \$\endgroup\$ Nov 24, 2019 at 22:28
  • \$\begingroup\$ I downvoted, for the reason I gave in my earlier comment. On further thought I'll retract the downvote in light of your second suggestion, but I still strongly believe that the complexity of a whole extra microcontroller for this would be a very poor design choice. \$\endgroup\$ Nov 25, 2019 at 5:21
1
\$\begingroup\$

Most forms of wired communication over that sort of distance use differential signalling, which is inherently more robust to attenuation, ground level shift and electromagnetic interference. There are several ICs available designed for exactly this application - EE.SE discourages product recommendation questions and answers so I won't give specific examples, but search terms along the lines of "I2C differential transceiver" should let you find some of them.

\$\endgroup\$

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