Can I use I2C over 2m cables?Is there a way to extend the length of wires for I2C connection?Maximum I2C Bus Length?Arduino: Reliable and practical way to connect an I²C device (1 m away)Best way to do I2C/TWI over long distanceDistance problems with I2C connection for multiple devicesWhat I2C address should I choose?Selecting communication between microcontrollers at high temperatureI2C bus multiplexing issueSTM32F3 I2C communication with ArduinoCrosstalk through I2CI2C - Certain Slaves not Pulling the Lines down fullyNoise resilient, hot-pluggable communication bus over long cables?How can I enable a LDO using the I2C SCL signalCommunication via I2C sensor via CAN busI2C sometimes works sometimes doesn't
Could a German insult Hitler without being arrested?
Is the net charge on a capacitor zero? If yes, then why?
How to Take Advantage of Arbitrage Opportunity of Two Options
Is it possible to kill parasitic worms by intoxicating oneself?
How to get a bowl with one liter of water
Set identification
Table columns widths are not equal
Why is there no No:6 in the movie?
What is the narrative difference between a Charisma and Wisdom saving throw?
In a piece for piano and vocals, when I move the vocal part down an octave do I also need to move the piano part down an octave?
Why are bicycle tires incapable of maintaining pressure over time, while car tyres seem to have less of a problem?
Finding New York City tournaments as a visitor from Moscow
Why do we need full-fledged workstations running massive OSes with massive software?
Check if simple regex matches string
How can I force a bank to close my account with them?
How to arrange objects in outward facing circle?
What are some games I can watch to become better in playing chess?
No transit zone at Linate airport. Couldn't get on connecting flight. Whose responsibility is it?
What license do I use when I don't want stock image companies charging people money for photos?
I am ask to complete my withdrawal transaction with COT fee of 1200 dollars
Can homotopy colimits recover cohomology sheaves?
Why one result is so wide in this logistic multiple regession
How can I show that a sphere is rolling in a simulation?
How can I get 2 characters to bond while standing alternate watches?
Can I use I2C over 2m cables?
Is there a way to extend the length of wires for I2C connection?Maximum I2C Bus Length?Arduino: Reliable and practical way to connect an I²C device (1 m away)Best way to do I2C/TWI over long distanceDistance problems with I2C connection for multiple devicesWhat I2C address should I choose?Selecting communication between microcontrollers at high temperatureI2C bus multiplexing issueSTM32F3 I2C communication with ArduinoCrosstalk through I2CI2C - Certain Slaves not Pulling the Lines down fullyNoise resilient, hot-pluggable communication bus over long cables?How can I enable a LDO using the I2C SCL signalCommunication via I2C sensor via CAN busI2C sometimes works sometimes doesn't
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
$begingroup$
In my current project, I need to communicate between a microcontroller and some sensors over I2C. One of them is a temperature sensor, it needs to be placed at approximatively 2 meters far from the microcontroller. I cannot choose another protocol (the sensor is on a module with given connector/pins/protocol).
Do you think it is possible to communicate in this configuration? What information should I look up to ensure it can or can't be possible? Do you have some advice?
It is my first time communicating with IC outside the PCB.
i2c communication cables
$endgroup$
add a comment
|
$begingroup$
In my current project, I need to communicate between a microcontroller and some sensors over I2C. One of them is a temperature sensor, it needs to be placed at approximatively 2 meters far from the microcontroller. I cannot choose another protocol (the sensor is on a module with given connector/pins/protocol).
Do you think it is possible to communicate in this configuration? What information should I look up to ensure it can or can't be possible? Do you have some advice?
It is my first time communicating with IC outside the PCB.
i2c communication cables
$endgroup$
5
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
5
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
6
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
1
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
2
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45
add a comment
|
$begingroup$
In my current project, I need to communicate between a microcontroller and some sensors over I2C. One of them is a temperature sensor, it needs to be placed at approximatively 2 meters far from the microcontroller. I cannot choose another protocol (the sensor is on a module with given connector/pins/protocol).
Do you think it is possible to communicate in this configuration? What information should I look up to ensure it can or can't be possible? Do you have some advice?
It is my first time communicating with IC outside the PCB.
i2c communication cables
$endgroup$
In my current project, I need to communicate between a microcontroller and some sensors over I2C. One of them is a temperature sensor, it needs to be placed at approximatively 2 meters far from the microcontroller. I cannot choose another protocol (the sensor is on a module with given connector/pins/protocol).
Do you think it is possible to communicate in this configuration? What information should I look up to ensure it can or can't be possible? Do you have some advice?
It is my first time communicating with IC outside the PCB.
i2c communication cables
i2c communication cables
edited Oct 1 at 6:40
winny
6,0065 gold badges25 silver badges38 bronze badges
6,0065 gold badges25 silver badges38 bronze badges
asked Oct 1 at 6:32
JackOfHeartsJackOfHearts
3771 silver badge4 bronze badges
3771 silver badge4 bronze badges
5
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
5
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
6
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
1
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
2
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45
add a comment
|
5
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
5
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
6
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
1
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
2
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45
5
5
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
5
5
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
6
6
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
1
1
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
2
2
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45
add a comment
|
5 Answers
5
active
oldest
votes
$begingroup$
I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters.
I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe.
To be sure that it will function, you should use an I2C bus extender like the P82B715.
However, the datasheet of the PB2B715 says the following in section 8.2:
For typical twisted pair or flat cables, as used for telephony or
Ethernet (Cat5e) wiring, that capacitance is around 50 pF to 70 pF /
meter so the cable could, in theory, be up to 50 m long. From
practical experience, 30 m has proven a safe cable length to be driven
in this simple way, up to 100 kHz, with the values shown. Longer
distances and higher speeds are possible but require more careful
design.
So the experts (NXP is the former Philips, the inventor of I2C) say that 30 meter has been proven a doable distance. My experience says 2 meters is a doable distance, and experiences that were reported back to me indicate that more heavily loaded I2C buses without any extender are also possible.
The key points to working I2C buses on long distances are:
- Using a low capacitance cable (twisted-pair/Ethernet);
- Limiting the bus speed;
- Having pull-ups that are correctly sized.
Pullup calculation
Texas Instruments has a good application note (SLVA689) about pull-up calculation .
- The lower bound of the pullup (minimum value) is determined by the current the weakest peripheral on the bus can pull, and the maximum voltage that represents 0 for any peripheral. So if 1V is still 0, your VCC is max 3V6 and your weakest device can only pull 20mA, your resistance is determined by the voltage loss over the resistor and the current pulled by that device: $(3.6 mathrmV- 1 mathrmV) / 20 mathrmmA=130 Omega$ .
- The upper bound is determined by the maximum rise time: your maximum I2C frequency is directly related to that, but there is also an upper limit defined by the protocol. The upper limit is $R_max=t_r/(0.8473 * C_b)$ . Where $t_r$ is the maximum rise time and $C_b$ is the bus capacitance. So if $C_b$ is 400pF, and the bus is operating in standard mode ($t_r$=1ms), then you'll find $R_max=2950 Omega$ . TI's application note has graphs so that you can find appropriate values quickly.
- Of course the value for the pullup is the equivalent value of all pullups in parallel combined. You may have a pullup on the master end, the slave end, and any other slave/master on the bus.
- The more you are "at the limit", the more you also need to account for "parasitics" such as the voltage drop in the cable.
$endgroup$
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
add a comment
|
$begingroup$
You are generally limited by 400 pF maximum bus capacitance.
It should work fine if you lower your frequency to something like 1 kHz and provide power supply decoupling next to the sensor.
If you need something more robust then you can use differential I2C converters on both ends like PCA9615.
$endgroup$
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
add a comment
|
$begingroup$
You can, but it is not recommended.
Different buses for different purposes
I2C, like SPI, is designed for communication within a board or group of boards (think Raspberry Pi and its hats or arduino and its shields). It can work over longer distances (see other answers) but should not be used in those cases, simply because that's not what it was designed, optimised and qualified for.
The risk you take is that you may not be able to add more sensors in the future, or that your system will not work everywhere, or will fail under certain circumstances.
What you should be looking for is a field bus, something like 1-wire, CAN, RS-485, ethernet, etc.
Wireless systems like bluetooth or zigbee could also be an option.
$endgroup$
add a comment
|
$begingroup$
As noted by @filo, I2C is generally limited by the bus capacitance. However, there are ways to work around this:
- Use a bus extender. The P82B96 or PCA9600 would both be good options in your case.
- If you need higher speeds or extremely long cables, you can use a differential I2C transceiver like the PCA9600. However, this will make your circuit considerably more complicated, and you need an IC at both ends of the cable.
Take a look at AN10658 and AN11084 from NXP for more information.
$endgroup$
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
add a comment
|
$begingroup$
I like the answers of filo and Caleb.
Another option is using one or multiple DS28E17 1-Wire-to-I2C Master Bridges at the individual sensors and wire up the bus as Onewire. This is good for >100m buses and well suited to low-throughput sensor array applications as distributed temperature and battery management.
$endgroup$
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("schematics", function ()
StackExchange.schematics.init();
);
, "cicuitlab");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "135"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f461010%2fcan-i-use-i2c-over-2m-cables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters.
I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe.
To be sure that it will function, you should use an I2C bus extender like the P82B715.
However, the datasheet of the PB2B715 says the following in section 8.2:
For typical twisted pair or flat cables, as used for telephony or
Ethernet (Cat5e) wiring, that capacitance is around 50 pF to 70 pF /
meter so the cable could, in theory, be up to 50 m long. From
practical experience, 30 m has proven a safe cable length to be driven
in this simple way, up to 100 kHz, with the values shown. Longer
distances and higher speeds are possible but require more careful
design.
So the experts (NXP is the former Philips, the inventor of I2C) say that 30 meter has been proven a doable distance. My experience says 2 meters is a doable distance, and experiences that were reported back to me indicate that more heavily loaded I2C buses without any extender are also possible.
The key points to working I2C buses on long distances are:
- Using a low capacitance cable (twisted-pair/Ethernet);
- Limiting the bus speed;
- Having pull-ups that are correctly sized.
Pullup calculation
Texas Instruments has a good application note (SLVA689) about pull-up calculation .
- The lower bound of the pullup (minimum value) is determined by the current the weakest peripheral on the bus can pull, and the maximum voltage that represents 0 for any peripheral. So if 1V is still 0, your VCC is max 3V6 and your weakest device can only pull 20mA, your resistance is determined by the voltage loss over the resistor and the current pulled by that device: $(3.6 mathrmV- 1 mathrmV) / 20 mathrmmA=130 Omega$ .
- The upper bound is determined by the maximum rise time: your maximum I2C frequency is directly related to that, but there is also an upper limit defined by the protocol. The upper limit is $R_max=t_r/(0.8473 * C_b)$ . Where $t_r$ is the maximum rise time and $C_b$ is the bus capacitance. So if $C_b$ is 400pF, and the bus is operating in standard mode ($t_r$=1ms), then you'll find $R_max=2950 Omega$ . TI's application note has graphs so that you can find appropriate values quickly.
- Of course the value for the pullup is the equivalent value of all pullups in parallel combined. You may have a pullup on the master end, the slave end, and any other slave/master on the bus.
- The more you are "at the limit", the more you also need to account for "parasitics" such as the voltage drop in the cable.
$endgroup$
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
add a comment
|
$begingroup$
I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters.
I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe.
To be sure that it will function, you should use an I2C bus extender like the P82B715.
However, the datasheet of the PB2B715 says the following in section 8.2:
For typical twisted pair or flat cables, as used for telephony or
Ethernet (Cat5e) wiring, that capacitance is around 50 pF to 70 pF /
meter so the cable could, in theory, be up to 50 m long. From
practical experience, 30 m has proven a safe cable length to be driven
in this simple way, up to 100 kHz, with the values shown. Longer
distances and higher speeds are possible but require more careful
design.
So the experts (NXP is the former Philips, the inventor of I2C) say that 30 meter has been proven a doable distance. My experience says 2 meters is a doable distance, and experiences that were reported back to me indicate that more heavily loaded I2C buses without any extender are also possible.
The key points to working I2C buses on long distances are:
- Using a low capacitance cable (twisted-pair/Ethernet);
- Limiting the bus speed;
- Having pull-ups that are correctly sized.
Pullup calculation
Texas Instruments has a good application note (SLVA689) about pull-up calculation .
- The lower bound of the pullup (minimum value) is determined by the current the weakest peripheral on the bus can pull, and the maximum voltage that represents 0 for any peripheral. So if 1V is still 0, your VCC is max 3V6 and your weakest device can only pull 20mA, your resistance is determined by the voltage loss over the resistor and the current pulled by that device: $(3.6 mathrmV- 1 mathrmV) / 20 mathrmmA=130 Omega$ .
- The upper bound is determined by the maximum rise time: your maximum I2C frequency is directly related to that, but there is also an upper limit defined by the protocol. The upper limit is $R_max=t_r/(0.8473 * C_b)$ . Where $t_r$ is the maximum rise time and $C_b$ is the bus capacitance. So if $C_b$ is 400pF, and the bus is operating in standard mode ($t_r$=1ms), then you'll find $R_max=2950 Omega$ . TI's application note has graphs so that you can find appropriate values quickly.
- Of course the value for the pullup is the equivalent value of all pullups in parallel combined. You may have a pullup on the master end, the slave end, and any other slave/master on the bus.
- The more you are "at the limit", the more you also need to account for "parasitics" such as the voltage drop in the cable.
$endgroup$
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
add a comment
|
$begingroup$
I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters.
I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe.
To be sure that it will function, you should use an I2C bus extender like the P82B715.
However, the datasheet of the PB2B715 says the following in section 8.2:
For typical twisted pair or flat cables, as used for telephony or
Ethernet (Cat5e) wiring, that capacitance is around 50 pF to 70 pF /
meter so the cable could, in theory, be up to 50 m long. From
practical experience, 30 m has proven a safe cable length to be driven
in this simple way, up to 100 kHz, with the values shown. Longer
distances and higher speeds are possible but require more careful
design.
So the experts (NXP is the former Philips, the inventor of I2C) say that 30 meter has been proven a doable distance. My experience says 2 meters is a doable distance, and experiences that were reported back to me indicate that more heavily loaded I2C buses without any extender are also possible.
The key points to working I2C buses on long distances are:
- Using a low capacitance cable (twisted-pair/Ethernet);
- Limiting the bus speed;
- Having pull-ups that are correctly sized.
Pullup calculation
Texas Instruments has a good application note (SLVA689) about pull-up calculation .
- The lower bound of the pullup (minimum value) is determined by the current the weakest peripheral on the bus can pull, and the maximum voltage that represents 0 for any peripheral. So if 1V is still 0, your VCC is max 3V6 and your weakest device can only pull 20mA, your resistance is determined by the voltage loss over the resistor and the current pulled by that device: $(3.6 mathrmV- 1 mathrmV) / 20 mathrmmA=130 Omega$ .
- The upper bound is determined by the maximum rise time: your maximum I2C frequency is directly related to that, but there is also an upper limit defined by the protocol. The upper limit is $R_max=t_r/(0.8473 * C_b)$ . Where $t_r$ is the maximum rise time and $C_b$ is the bus capacitance. So if $C_b$ is 400pF, and the bus is operating in standard mode ($t_r$=1ms), then you'll find $R_max=2950 Omega$ . TI's application note has graphs so that you can find appropriate values quickly.
- Of course the value for the pullup is the equivalent value of all pullups in parallel combined. You may have a pullup on the master end, the slave end, and any other slave/master on the bus.
- The more you are "at the limit", the more you also need to account for "parasitics" such as the voltage drop in the cable.
$endgroup$
I2C is not designed to be used over long distances but I know of several applications where it is actually used over a distance of about 2 meters.
I also know of one case where they had issues with that and it was eventuelly fixed by fixing ground loops I believe.
To be sure that it will function, you should use an I2C bus extender like the P82B715.
However, the datasheet of the PB2B715 says the following in section 8.2:
For typical twisted pair or flat cables, as used for telephony or
Ethernet (Cat5e) wiring, that capacitance is around 50 pF to 70 pF /
meter so the cable could, in theory, be up to 50 m long. From
practical experience, 30 m has proven a safe cable length to be driven
in this simple way, up to 100 kHz, with the values shown. Longer
distances and higher speeds are possible but require more careful
design.
So the experts (NXP is the former Philips, the inventor of I2C) say that 30 meter has been proven a doable distance. My experience says 2 meters is a doable distance, and experiences that were reported back to me indicate that more heavily loaded I2C buses without any extender are also possible.
The key points to working I2C buses on long distances are:
- Using a low capacitance cable (twisted-pair/Ethernet);
- Limiting the bus speed;
- Having pull-ups that are correctly sized.
Pullup calculation
Texas Instruments has a good application note (SLVA689) about pull-up calculation .
- The lower bound of the pullup (minimum value) is determined by the current the weakest peripheral on the bus can pull, and the maximum voltage that represents 0 for any peripheral. So if 1V is still 0, your VCC is max 3V6 and your weakest device can only pull 20mA, your resistance is determined by the voltage loss over the resistor and the current pulled by that device: $(3.6 mathrmV- 1 mathrmV) / 20 mathrmmA=130 Omega$ .
- The upper bound is determined by the maximum rise time: your maximum I2C frequency is directly related to that, but there is also an upper limit defined by the protocol. The upper limit is $R_max=t_r/(0.8473 * C_b)$ . Where $t_r$ is the maximum rise time and $C_b$ is the bus capacitance. So if $C_b$ is 400pF, and the bus is operating in standard mode ($t_r$=1ms), then you'll find $R_max=2950 Omega$ . TI's application note has graphs so that you can find appropriate values quickly.
- Of course the value for the pullup is the equivalent value of all pullups in parallel combined. You may have a pullup on the master end, the slave end, and any other slave/master on the bus.
- The more you are "at the limit", the more you also need to account for "parasitics" such as the voltage drop in the cable.
edited Oct 3 at 10:40
ilkkachu
7765 silver badges8 bronze badges
7765 silver badges8 bronze badges
answered Oct 1 at 9:05
le_tople_top
2,2635 silver badges16 bronze badges
2,2635 silver badges16 bronze badges
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
add a comment
|
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
Having pull-ups that are correctly sized? How to determine the value and power rating?
$endgroup$
– Quantum0xE7
Oct 2 at 14:24
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
$begingroup$
As Nick B commented on another answer, be wary of the possibility of the bus extender chip or whatever else heating the temp sensor by a couple degrees.
$endgroup$
– Peter Cordes
Oct 3 at 7:39
add a comment
|
$begingroup$
You are generally limited by 400 pF maximum bus capacitance.
It should work fine if you lower your frequency to something like 1 kHz and provide power supply decoupling next to the sensor.
If you need something more robust then you can use differential I2C converters on both ends like PCA9615.
$endgroup$
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
add a comment
|
$begingroup$
You are generally limited by 400 pF maximum bus capacitance.
It should work fine if you lower your frequency to something like 1 kHz and provide power supply decoupling next to the sensor.
If you need something more robust then you can use differential I2C converters on both ends like PCA9615.
$endgroup$
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
add a comment
|
$begingroup$
You are generally limited by 400 pF maximum bus capacitance.
It should work fine if you lower your frequency to something like 1 kHz and provide power supply decoupling next to the sensor.
If you need something more robust then you can use differential I2C converters on both ends like PCA9615.
$endgroup$
You are generally limited by 400 pF maximum bus capacitance.
It should work fine if you lower your frequency to something like 1 kHz and provide power supply decoupling next to the sensor.
If you need something more robust then you can use differential I2C converters on both ends like PCA9615.
edited Oct 1 at 6:59
answered Oct 1 at 6:35
filofilo
7,5501 gold badge15 silver badges37 bronze badges
7,5501 gold badge15 silver badges37 bronze badges
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
add a comment
|
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
$begingroup$
I dimly recall some sensors having a minimum I2C frequency (not sure why).
$endgroup$
– Michael
Oct 1 at 19:05
add a comment
|
$begingroup$
You can, but it is not recommended.
Different buses for different purposes
I2C, like SPI, is designed for communication within a board or group of boards (think Raspberry Pi and its hats or arduino and its shields). It can work over longer distances (see other answers) but should not be used in those cases, simply because that's not what it was designed, optimised and qualified for.
The risk you take is that you may not be able to add more sensors in the future, or that your system will not work everywhere, or will fail under certain circumstances.
What you should be looking for is a field bus, something like 1-wire, CAN, RS-485, ethernet, etc.
Wireless systems like bluetooth or zigbee could also be an option.
$endgroup$
add a comment
|
$begingroup$
You can, but it is not recommended.
Different buses for different purposes
I2C, like SPI, is designed for communication within a board or group of boards (think Raspberry Pi and its hats or arduino and its shields). It can work over longer distances (see other answers) but should not be used in those cases, simply because that's not what it was designed, optimised and qualified for.
The risk you take is that you may not be able to add more sensors in the future, or that your system will not work everywhere, or will fail under certain circumstances.
What you should be looking for is a field bus, something like 1-wire, CAN, RS-485, ethernet, etc.
Wireless systems like bluetooth or zigbee could also be an option.
$endgroup$
add a comment
|
$begingroup$
You can, but it is not recommended.
Different buses for different purposes
I2C, like SPI, is designed for communication within a board or group of boards (think Raspberry Pi and its hats or arduino and its shields). It can work over longer distances (see other answers) but should not be used in those cases, simply because that's not what it was designed, optimised and qualified for.
The risk you take is that you may not be able to add more sensors in the future, or that your system will not work everywhere, or will fail under certain circumstances.
What you should be looking for is a field bus, something like 1-wire, CAN, RS-485, ethernet, etc.
Wireless systems like bluetooth or zigbee could also be an option.
$endgroup$
You can, but it is not recommended.
Different buses for different purposes
I2C, like SPI, is designed for communication within a board or group of boards (think Raspberry Pi and its hats or arduino and its shields). It can work over longer distances (see other answers) but should not be used in those cases, simply because that's not what it was designed, optimised and qualified for.
The risk you take is that you may not be able to add more sensors in the future, or that your system will not work everywhere, or will fail under certain circumstances.
What you should be looking for is a field bus, something like 1-wire, CAN, RS-485, ethernet, etc.
Wireless systems like bluetooth or zigbee could also be an option.
edited Oct 2 at 8:50
SusanW
2041 silver badge12 bronze badges
2041 silver badge12 bronze badges
answered Oct 1 at 8:00
SclrxSclrx
1,4505 silver badges15 bronze badges
1,4505 silver badges15 bronze badges
add a comment
|
add a comment
|
$begingroup$
As noted by @filo, I2C is generally limited by the bus capacitance. However, there are ways to work around this:
- Use a bus extender. The P82B96 or PCA9600 would both be good options in your case.
- If you need higher speeds or extremely long cables, you can use a differential I2C transceiver like the PCA9600. However, this will make your circuit considerably more complicated, and you need an IC at both ends of the cable.
Take a look at AN10658 and AN11084 from NXP for more information.
$endgroup$
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
add a comment
|
$begingroup$
As noted by @filo, I2C is generally limited by the bus capacitance. However, there are ways to work around this:
- Use a bus extender. The P82B96 or PCA9600 would both be good options in your case.
- If you need higher speeds or extremely long cables, you can use a differential I2C transceiver like the PCA9600. However, this will make your circuit considerably more complicated, and you need an IC at both ends of the cable.
Take a look at AN10658 and AN11084 from NXP for more information.
$endgroup$
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
add a comment
|
$begingroup$
As noted by @filo, I2C is generally limited by the bus capacitance. However, there are ways to work around this:
- Use a bus extender. The P82B96 or PCA9600 would both be good options in your case.
- If you need higher speeds or extremely long cables, you can use a differential I2C transceiver like the PCA9600. However, this will make your circuit considerably more complicated, and you need an IC at both ends of the cable.
Take a look at AN10658 and AN11084 from NXP for more information.
$endgroup$
As noted by @filo, I2C is generally limited by the bus capacitance. However, there are ways to work around this:
- Use a bus extender. The P82B96 or PCA9600 would both be good options in your case.
- If you need higher speeds or extremely long cables, you can use a differential I2C transceiver like the PCA9600. However, this will make your circuit considerably more complicated, and you need an IC at both ends of the cable.
Take a look at AN10658 and AN11084 from NXP for more information.
answered Oct 1 at 7:15
Caleb ReisterCaleb Reister
1,1636 silver badges20 bronze badges
1,1636 silver badges20 bronze badges
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
add a comment
|
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
1
1
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
$begingroup$
This will work ok with a bus extender, as several others have said. Something not immediately obvious to watch for is that the bus extender at the sensor end can dissipate enough heat to raise the temperature sensors reading by a couple degrees if the sensor and bus extender are close together.
$endgroup$
– Nick B
Oct 2 at 17:45
add a comment
|
$begingroup$
I like the answers of filo and Caleb.
Another option is using one or multiple DS28E17 1-Wire-to-I2C Master Bridges at the individual sensors and wire up the bus as Onewire. This is good for >100m buses and well suited to low-throughput sensor array applications as distributed temperature and battery management.
$endgroup$
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
add a comment
|
$begingroup$
I like the answers of filo and Caleb.
Another option is using one or multiple DS28E17 1-Wire-to-I2C Master Bridges at the individual sensors and wire up the bus as Onewire. This is good for >100m buses and well suited to low-throughput sensor array applications as distributed temperature and battery management.
$endgroup$
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
add a comment
|
$begingroup$
I like the answers of filo and Caleb.
Another option is using one or multiple DS28E17 1-Wire-to-I2C Master Bridges at the individual sensors and wire up the bus as Onewire. This is good for >100m buses and well suited to low-throughput sensor array applications as distributed temperature and battery management.
$endgroup$
I like the answers of filo and Caleb.
Another option is using one or multiple DS28E17 1-Wire-to-I2C Master Bridges at the individual sensors and wire up the bus as Onewire. This is good for >100m buses and well suited to low-throughput sensor array applications as distributed temperature and battery management.
answered Oct 1 at 7:22
JankaJanka
10.3k1 gold badge12 silver badges24 bronze badges
10.3k1 gold badge12 silver badges24 bronze badges
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
add a comment
|
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
Interesting thought, though it may introduce additional software overhead if the master does not have a 1-Wire interface.
$endgroup$
– Caleb Reister
Oct 1 at 7:29
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
It mostly an option if you have a Linux host, as it has the full driver stack for this stunt. On a Raspberry Pi, you just have to connect GPIO4 to the 1W input of the DS28E17 through those 100m of wire (plus GND of course), edit config.txt and you are done. It's fully transparent, looks like a local I²C. Just slower.
$endgroup$
– Janka
Oct 1 at 10:20
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Thanks. I was really surprised that 1-Wire can do that sort of distance. I guess it makes sense, since resistors are smaller.
$endgroup$
– domen
Oct 1 at 16:06
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
$begingroup$
Onewire does not rely on rising edge timing but instead, all bit timing is done in relation to the falling edge, which is actively driven. That's why it is less susceptible to high capacitive loading. A few nF are ok.
$endgroup$
– Janka
Oct 1 at 18:13
add a comment
|
Thanks for contributing an answer to Electrical Engineering Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f461010%2fcan-i-use-i2c-over-2m-cables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
$begingroup$
Please add more information. What would be i2c speed? Pull-up resistances? Used cable and its capacitance? What is the host MCU and what is the sensor? But in general, I2C works several meters over cables like HDMI so it should work when things are done properly.
$endgroup$
– Justme
Oct 1 at 9:08
5
$begingroup$
related: Maximum I2C Bus Length?, Best way to do I2C/TWI over long distance, Reliable and practical way to connect an I²C device (1 m away), Distance problems with I2C connection for multiple devices, Memoirs of an overgrown I2C bus
$endgroup$
– Nick Alexeev♦
Oct 1 at 15:16
6
$begingroup$
"I cannot choose another protocol" You can put a second microcontroller close to the sensor, read the data and send them with any protocol you like.
$endgroup$
– FooBar
Oct 2 at 11:31
1
$begingroup$
Do you have a minimum speed in kbit/s?
$endgroup$
– Mast
Oct 2 at 14:21
2
$begingroup$
If you slow the clock down you can go fairly long distance.
$endgroup$
– copper.hat
Oct 3 at 2:45