Serial distance capability.

My rotator project is going to have the position sensed by a compass module over I2C. Now I don't believe that I2C will survive a cable length of 8-10 metres so need to extend it. The obvious choice is a pair of I2C extenders until I saw that it was going to cost the same as 10 Nanos!

Next idea, put the compass and Nano at the head end and talk to another Nano in the controller over serial.
But; TTL serial also has a limit I believe that is lower than 10m? Another option is MAX232 both ends and use RS232?

Bluetooth etc is a no go because the Nano will be inside the metal rotator housing for RF screening.

Have you considered RS485. It is made for long distance multi-drop serial comms. There are modules to interface with Arduinos. And they are not expensive.

RS232 is fine for your needs.

Converters to run rs485 from arduino are very inexpensive and their use is well documented.

RS485 is DESIGNED to be interference resistant and run over large distances.

With RS485 communication distances of 1200 m are possible.

Now I don't believe that I2C will survive a cable length of 8-10 metres

Believe it!
Have you tried it?
I have I2C working over about 30m in my house reading temperature sensors. No problems at all. I think (would have to check) it's working currently at 60kHz.

The problem with long cable runs (apart from interference) is capacitance.

The solution is to reduce the speed as far as necessary - I2C can do this quite well (software version) as you also can with raw serial CMOS data (no, not obsolete "TTL" :roll_eyes: )

Of course RS485 will be more rugged.

PerryBebbington:
Believe it!
Have you tried it?
I have I2C working over about 30m in my house reading temperature sensors. No problems at all. I think (would have to check) it's working currently at 60kHz.

PerryBebbington:
Believe it!
Have you tried it?
I have I2C working over about 30m in my house reading temperature sensors. No problems at all. I think (would have to check) it's working currently at 60kHz.

What kind of cable are you using? Shield? CAT5 or 6?

thehardwareman:
What kind of cable are you using? Shield? CAT5 or 6?

So, my answer was so good you quoted me twice :slight_smile:

I use 2 pair telephone cable, that's actual copper telephone cable to specification CW1308, not the copper coated steel or copper coated aluminium rubbish available on your favourite retail web site and some electrical wholesalers. By all means try cat 5, but I have not done so.

I used one pair for clock and data and the other pair for power. I now think this was a mistake as it encourages crosstalk between clock and data. I think I should have used one pair for ground and (say) clock and the other pair for +5V and (say) data. However, it works as it is so I am not changing it.

Pull up resistors are 1k at the controller. Some will say this is too low according to the I2C specification. Maybe it is, maybe not, I don't know. What I do know is that it works, and has never been a problem. This hobby is about experimenting with things, so experiment.

There is a case for distributing the resistors over the network, so put a pair of resistors at the controller and at each end point* if it is star wired, or at the controller and end of the line if it is daisy chained. Bear in mind that all the resistors will be in parallel so the the total parallel resistance should not be lower than 1k. Putting the resistors at the end points* will absorb any reflections. However, the times when I was having a problem I put an oscilloscope on clock and data I didn't see any evidence of significant reflections.

I put capacitors across the power at every end point* to clean it up from any crap picked up in the cables.

I once had one of my sensors not working reliably, mostly it gave correct results but there were a lot of errors as well. I found that the +5V wire had come loose at the sensor, so the it was being powered parasitically from clock and data. This didn't have any effect on the other sensors.

I checked the speed I have it running at and it is 10kHz at the moment, I'm pretty sure I've had it at 60kHz at some point.

Processor is a PIC in my case, but I have no reason to think any of the processors used by Arduino would be a problem. I originally did this with a Z80 and a software implementation of I2C, which ran very, very slowly.

When I first joined this forum there were people saying I2C is only good for 1m or so. Well, maybe it was designed for 1m or so, but my experience says it is capable of a lot further than that. I have not found the limit.

*By end point I mean the devices on the bus, in my case they are DS1624 temperature sensors.

Sorry for the double quote. I have problems with clicking the "quote" link. Nothing happens unless I click it several times :wink: And I did not see that I have quoted you to times.

Thanks for the info :slight_smile:

Sorry for the double quote. I have problems with clicking the "quote" link. Nothing happens unless I click it several times

You might find this of interest: More forum weirdness

Oh, and every time I see the title of this discussion I read it as 'social distance capability'.

I did not try I2C for long distances but I think it will be very different if you use it in an electrically quiet location (i.e. a long wire in the garden to a remote sensor) and when the I2C wires go around a motor driver, switching regulator and a wireless transmitter.

PerryBebbington:
Oh, and every time I see the title of this discussion I read it as 'social distance capability'.

Hmmm. So do I! :grinning:

thehardwareman:
Sorry for the double quote. I have problems with clicking the "quote" link. Nothing happens unless I click it several times

The forum software is getting quite annoying. Many times when it fails to respond it comes up with an orange "Loading" at the top - and does nothing. :roll_eyes:

johnerrington:
Converters to run rs485 from arduino are very inexpensive and their use is well documented.

RS485 is DESIGNED to be interference resistant and run over large distances.

So is RS232. The difference is RS485 can handle high bandwidth and long distance, whereas
with RS232 you have to trade bandwidth for distance, within reason. For 9600 baud 100m isn't
a big problem (although a shielded cable and 100 ohms series resistors at each end would be wise).

How are you powering each end?

You can go really far with ttl uart at low baud rate. Say 38400 or even lower can go hundreds of ft.

Obviously this won't work in a noisy environment which is why 485 exists, but if not, it will work.

Another way to help is to use cat5 wire and put tx and gnd on a itwisted pair, and rx and gnd on another twisted pair. Be sure the cable is shielded. This should go 200ft or more without issues at 19200 baud, probably even higher baud.

Paul__B:
The forum software is getting quite annoying. Many times when it fails to respond it comes up with an orange "Loading" at the top - and does nothing. :roll_eyes:

Wait 5-10 seconds or so, and hit the quote button again.
Repeat if needed, but it usually works here the second or third time.
Leo..

Wawa:
Wait 5-10 seconds or so, and hit the quote button again.
Repeat if needed, but it usually works here the second or third time.

The delay is annoying, often resulting in the double quote as above.

The intermittent nature is the most annoying.

Five to ten seconds? Seriously?

Thanks for all the very useful responses. Sorry to have taken so long, I had no internet until now due to 'indoors wasting all the 100Gb allowance I have on 4G, streaming her superstitious crap!
I tried to respond this morning and the forum would not allow me to sign in. Eventually when browsing this sub section it suddenly authenticated so here I am.

I am interested to hear that I2C might go the distance. I think I might give that a try initially with some CAT6. Bearing in mind Perry's experience I may go with each signal on a twisted pair with ground and see how it behaves. It is hardly mission critical if it isn't 100% reliable and it would save the issue of not being able to update the 'on mast' Arduino easily.

Failing that I will go with the two Arduinos and a pair of MAX232 converters which should be just the job. Powering can be done with the CAT6 cable which will bring the serial data down to the controller.

Thanks again for the help and advice.

I tried to respond this morning and the forum would not allow me to sign in. Eventually when browsing this sub section it suddenly authenticated so here I am.

Old bug that seems to have come back again after the forum update :frowning:

I2C is not limited by distance, but by the capacitance of the data and clock cables, referenced to ground. According to the spec, that is 400 pF.

I2C is originally designed as IC to IC communications and PCB trace capacitance was predictable.

The I2C standard mode is 100 kb/sec, which is roughly 1kHz.
The capacitance spec for CAT-5 is 52pF/meter at 800 Hz.

So, roughly, you can use 4 meters of CAT-5 cable for standard I2C data. Maybe.

The I2C standard mode is 100 kb/sec, which is roughly 1kHz

.
It's designed for 100kHz, not 1kHz. However, it doesn't care, you can run it at 1Hz and it works.