What is the length that I can go for spi and i2c?

Hello I’m getting mixed results on how far of length I can go for spi and i2c?

My project I need to go 3ft for spi and 1.2ft for i2c is this possible?

Joseph

SparkFun QwiicBus - EndPoint

It depends on a lot of things but the two most important is the speed of the data and the capacitance of the wire.

With SPI it is easy to set the speed of the connection, so if you are having trouble try slowing it down.

With I2C the normal speed is only 100KHz, but even that might suffer with poor wiring and a too large a value of pull up resistors. Aim for 2mA current from the pull up resistors when they are pulled low.

Hello all, thank you for responding back. I two sensors on i2c for temperature and the spi I have a Ethernet module. Because of the limit space I have to run the Ethernet module apart from the rest.

Joseph

I have successfully tested I2C over 20 meter with a 4x twisted pair cable. GND+SDA in one pair, GND+SCL in the second pair (the other two pairs was not used).

Thank you very much.

Joseph

Just about the worse thing you can do with I2C as that increases the capacitance of the connection and that is the critical thing.
What were your pull up resistor values?

If doing long runs with high speed clocked logic busses like SPI, its wise to add small series resistors at each end to the signal wires, 68 to 100 ohms sort of value.

This should reduce the risk of signal reflections causing a double-edged clock transistion, and reduce overshoot spikes.

SPI in particular is not designed for off-board use as many devices are rated for 20MHz or higher and will be sensitive to poor logic-transition quality.

The above keeps capacitance to ground of both lines the same (~53pf/m for Cat-5/6),
and cross-talk between SDA and SCL minimal.
Twisted (or parallel) pair with pull up on both ends is AFAIK an easy way to bridge significant distances with I2C.

Please tell us how you would do it, without using extra hardware.
Leo..

That is not an issue.

I would use non twisted pairs of connectors with pull up resistors pulling 2mA instead of the normal 1mA. But for any great distance I2C is not the thing to use unless you use the differential drivers and receivers with signal reconstruction at both ends.

I2C Bus is designed for the I2C devices to be wthinn a board of around 12 in x12 in. You are operating the devices outside the specifications and the risk is yours.

4k7, if I remember correctly. And I did this just for the test.

I2C and cable length has been discussed here before.

There is a link to a video showing a guy using over 100 meter cable.

Hello everyone, thank you all for the information. I have a future project that requires about 15ft per sensor. It is 9 temperature sensors no humidity on them.I’m trying to map a room for cold and hot spots. Each one of the sensors are i2c 4 of them and 5 of the spi sensors. I just needed to know what is the father distance I can go on spi and i2c.

Joseph

Hmm, sounds like you chose the wrong sort of sensors. DS18B20's are perfect for this sort of distributed comms being OneWire which is designed for the purpose. I've used 20 sensors on one OneWire bus before now with good results.

Temperature sensing is not a high bandwidth application so SPI and I2C are overkill for that.

Hey mark nice to see you again. I have a ds18b20 about 6 of them. I totally forgot about them. I need to order 3 or 4 more. on. One wire can I reach a total of 15 to 20 ft if I need to?

Joseph

This is probably the document to read about OneWire: https://pdfserv.maximintegrated.com/en/an/AN148.pdf

Hey mark, Thank you very much.

Joseph

There is no spec for the length of I2C or SPI wiring. Or the pullup resistors.

The spec is the capacitance of the data wires, or in their intended use, PCB traces.

To really get it right, you need to use an oscilloscope on the data line. Ideally you should see a nice clean square wave during data transmissions. The pullup resistors need to be able to pull the data lines almost to Vcc when there is no data, but not so strong that the devices cant pull the data lines low. 4K7 is simply what the device manufacturers generally use when they publish their datasheets, and it works for most applications.