Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

maximum cable length I2C with twisted pair?

Thu Jul 17, 2014 11:23 am

I tried to connect a few I2C sensors (Grove Barometic Sensor (I2C address = 0x77) and Grove Digital Light sensor (I2C-address = 0x29)) with a long (12,5 m) UTP cat6 twisted pair cable, but they aren't detected with

Code: Select all

[email protected] ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $
and I get errors in Python when I want to address them:

Code: Select all

Error accessing 0x77: Check your I2C
When I connect the same sensors with short flatcables (20 cm), they are detected

Code: Select all

[email protected] ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77
[email protected] ~ $
and can be addressed using standard I2C commands in Python, so the sensors are working proparly.

Is there a maximum length for UTP cat6 twisted pair cables for I2C?

If this is the case, could I use the NXP I2C-bus buffers PCA9600 to split the transmit and receive signals of the SDA and SCL from 2 wires to 4 four wires (+ 2 wires for GND and power). Details on the PCA9600 are here: http://www.nxp.com/documents/leaflet/75016081.pdf, http://www.nxp.com/documents/data_sheet/PCA9600.pdf, http://www.nxp.com/documents/leaflet/pc ... r_card.pdf and http://www.nxp.com/documents/applicatio ... N10658.pdf.

This is meant to be used on Arduino or other controllers, but it doesn't says anything for using it with a Raspberry Pi so I'm not sure it would solve my problem.
Johan Vandewalle
(Belgium)

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: maximum cable length I2C with twisted pair?

Thu Jul 17, 2014 11:57 am

Word on the street is it's only a few metres.

Here's a handy discussion of potential solutions:
http://forum.arduino.cc/index.php?topic=57604.0

GerryAttrick
Posts: 15
Joined: Sat Jan 19, 2013 9:09 pm

Re: maximum cable length I2C with twisted pair?

Thu Jul 17, 2014 8:23 pm

Perhaps you could try adding your own pull-up resistors (say, 10k). If these are connected from the 3.3 V pin on the Pi to the SDA and SCL lines, they will effectively be in parallel with those in the Pi and so give a more positive and responsive high level. I wouldn't try anything lower than 4.7k, though.

danjperron
Posts: 3330
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: maximum cable length I2C with twisted pair?

Thu Jul 17, 2014 9:41 pm

Long wire will start to have ringing effect. Try to put pull-up resistor on both side.

Also RF could cause problem, add ferrite bead, like the one on USB cable,on both end.

But I2C is not made for that. You should use some other protocol like , RS-232, RS-485, CAN-BUS, 1-wire.

Daniel

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: maximum cable length I2C with twisted pair?

Fri Jul 18, 2014 3:02 am

If you are using Cat-6 network cable, then I would try the following pinout.
Attachments
rj45-pinout2.JPG
rj45-pinout2.JPG (60.33 KiB) Viewed 38311 times
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Fri Jul 18, 2014 9:03 am

GerryAttrick wrote:Perhaps you could try adding your own pull-up resistors (say, 10k). If these are connected from the 3.3 V pin on the Pi to the SDA and SCL lines, they will effectively be in parallel with those in the Pi and so give a more positive and responsive high level. I wouldn't try anything lower than 4.7k, though.
Both sensors are connected through the GrovePi expansion board. This board connects the sensors directly with the +5V and GND (of both the GrovePi and the RPi; pin 2 and 6 of the GPIO-connector) and with the SDA and SCL of the GrovePi . It has some pull-up resistors of 10k and MOSFET-N installed (for isolation) between the SCL of the RPi (towards the +3.3 V) and the SCL of the GrovePi (towards the +5V) and between the SDA of the RPi (towards the +3.3V) and the SDA of the GrovePi (towards the +5V) as shown in the diagram. So there is an isolation of the SCL and SDA of the sensors and the SCL and SDA of the RPi and both signals are pull-upped with a 10k resistor on the side of the RPi (but I haven't placed extra pull-up resistors at the sensor side of the cable).
Attachments
GrovePi_I2C-connections.png
GrovePi_I2C_Level_Conversion
GrovePi_I2C-connections.png (12.04 KiB) Viewed 38274 times
Johan Vandewalle
(Belgium)

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Fri Jul 18, 2014 9:28 am

Richard-TX wrote:If you are using Cat-6 network cable, then I would try the following pinout.
My current pinout is like this (see previous reply on the wiring through the GrovePi) since I don't need the +3.3V pin and the +5V and GND are already doubled (through a second cat6 single pair cable to connect analog and digital sensors to the GrovePi (which don't have any problem on the cable length). So I tripled the SDA and SCL wires (but maybe in the wrong pairs).
pin-layout.jpg
pin layout of the connecting wire
pin-layout.jpg (59.08 KiB) Viewed 38266 times
Johan Vandewalle
(Belgium)

bbodin
Posts: 70
Joined: Sat Jun 28, 2014 3:23 pm

Re: maximum cable length I2C with twisted pair?

Fri Jul 18, 2014 5:25 pm

Your wire assignment is not good. Putting SDA and SCL on the same twisted pair increases the chance of crosstalk between the two signals. Tripling the SDA and SCL wires doesn't accomplish anything except unnecessarily increase the capacitance of the I2C bus. The wire arrangement suggested by Richard-TX is good and should be followed. It pairs the SDA/SCL with a ground wire. By doing so, it helps to minimize the crosstalk between the signals, reduce the inductance and maintain a uniform capacitance along the cable. If you don't need the +3V wires, leave them unconnected.

There are several factors that limit the length of the I2C bus:
- Clock rate
- Capacitance of the wire carrying SDA/SCL with respect to GND
- Ability of the I2C driver.

The I2C driver is basically an open-drain (or open-collector) transistor with a pull-up resistor connected to a positive supply (+3.3V on the RPi side, +5V on the GrovePi side). A logic 0 is transmitted by turning on the transistor which discharges the bus capacitance. A logic 1 is transmitted by turning off the transistor. In this case, the charging of the bus capacitance relies on the pull-up resistor. The charging/discharging time dictates the rise/fall time of the SDA/SCL signal.

For fast-mode rate (400 kHz), the max. rise/fall time is 300 ns. If the rise time tr is defined as the time it takes for a voltage to go from 30% to 70% of its steady-state value, the maximum value of the pull-up resistor Rp is calculated as

Rp = tr / (0.8473 x Cb)

where Cb is the bus capacitance.

If SDA and SCL with their corresponding GND are assigned to two separate twisted pairs of a 12.5m CAT6 cable, and the capacitance between two wires in a pair is estimated to be 44 pF/m, the maximum value of Rp is:

Rp = 300 / (0.8473 x 44 x 12.5) = 0.643 kohm

With 5V across Rp, the current flow is 7.8 mA. This current is well within the sinking ability of the barometric sensor I2C port (not sure for the light sensor).

I would suggest adding an extra 1 kohm pull-up resistor for the SDA/SCL wire on the I2C bus (GrovePi side). If this doesn't work for fast mode, it should work for standard mode (100 kHz).
Binh Bui

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Fri Jul 18, 2014 9:00 pm

Bbodin, I first want to thank you for explaining it so good. Now it makes sense to me. I still have some questions. Can you take a look at them?
bbodin wrote:Your wire assignment is not good. Putting SDA and SCL on the same twisted pair increases the chance of crosstalk between the two signals. Tripling the SDA and SCL wires doesn't accomplish anything except unnecessarily increase the capacitance of the I2C bus. The wire arrangement suggested by Richard-TX is good and should be followed. It pairs the SDA/SCL with a ground wire. By doing so, it helps to minimize the crosstalk between the signals, reduce the inductance and maintain a uniform capacitance along the cable. If you don't need the +3V wires, leave them unconnected.
Ok, I'll change the wires and do it as Richard-TX suggested by pairing the SDA with a GND wire (on positions 1 and 2), pairing the SCL line with a GND wire (on positions 7 and 8) and with +5V wires on position 4 and 5 but without the + 3.3V wires on positions 3 and 6. Is it still necessary to double the +5V wire or is just one+5V wire sufficiant, since there is already a second one is already on the other UTP-cable?
bbodin wrote:If SDA and SCL with their corresponding GND are assigned to two separate twisted pairs of a 12.5m CAT6 cable, and the capacitance between two wires in a pair is estimated to be 44 pF/m, the maximum value of Rp is:

Rp = 300 / (0.8473 x 44 x 12.5) = 0.643 kohm

With 5V across Rp, the current flow is 7.8 mA. This current is well within the sinking ability of the barometric sensor I2C port (not sure for the light sensor).
In the datasheet of the BMP085 sensor (which is used in the Grove Barometic Sensor) I found these electrical parameters for the I2C interface:
  • Clock input frequency, fSCL: max. 3.4 MHz
  • Input-low level, VIL: min. 0 V, max. 0.2 * VDDD (1 V)
  • Input-high level, VIH: min. 0.8 * VDDD (= 4 V), max. VDDD (= 5 V)
  • SDA and SCL pull-up resistor, Rpull-up: min. 2.2 kΩ, max. 10 kΩ
  • SDA sink current at VDDD = 1.62V, VOL = 0.3V, ISDA_sink: typ. 9 mA
  • EOC sink current at VDDD = 1.62V, VOL = 0.3V, ISDA_sink: typ. 7.7 mA
  • EOC source current at VDDD = 1.62V, VOH = 1.32V, ISDA_source: typ. 1.5 mA
  • XCLR pulse length, tXCLR: min. 1 µs
  • Start-up time after power-up, before first communication, tstart: min. 10 ms
In the datasheet for the TSL2561-sensor (which is used in the Grove Digital Light sensor) I found these AC electrical parameters, at VDD = 3 V, TA = 25°C:
  • Conversion time, t(CONV): min. 12 ms, typ. 100 ms, max. 400 ms
  • Clock frequency, f(CONV): 400 kHz
  • Bus free time between start and stop condition, t(BUF): 1.3 µs
  • Hold time after (repeated) start condition. After this period, the first clock is generated, t(HDSTA): 0.6 µs
  • Repeated start condition setup time, t(SUSTA): 0.6 µs
  • Stop condition setup time, t(SUSTO): 0.6 µs
  • Data hold time, t(HDDAT): min. 0 µs, max. 0.9 µs
  • Data setup time, t(SUDAT): min. 100 ns
  • SCL clock low period, t(LOW): 1.3 µs
  • SCL clock high period, t(HIGH): 0.6 µs
  • Detect clock/datta low timeout (SMBus only), t(TIMEOUT): min. 25 ms, max. 35 ms
  • Clock/data fall time, tF: 300 ns
  • Clock/data rise time, tR: 300 ns
  • Input pin capacitance, Cj: 10 pf
The sink current isn't mentioned, but maybe you can calculate it from these parameters?
bbodin wrote:I would suggest adding an extra 1 kohm pull-up resistor for the SDA/SCL wire on the I2C bus (GrovePi side). If this doesn't work for fast mode, it should work for standard mode (100 kHz).
Where should I put this 1 kΩ pull-up resistor, on the sensor-side of the cable (I mean between the cable and the sensor) or on the Grove-Pi side of the cable (I mean between the cable and the GrovePi)?

Johan
Last edited by Johan Vandewalle on Sun Jul 20, 2014 1:35 pm, edited 1 time in total.
Johan Vandewalle
(Belgium)

bbodin
Posts: 70
Joined: Sat Jun 28, 2014 3:23 pm

Re: maximum cable length I2C with twisted pair?

Sat Jul 19, 2014 11:24 am

1) One +5V wire is sufficient. However since you have +5V supplied by another cable, leave both +5V wire unconnected.

2) The sink current cannot be derived from the AC parameters for the light sensor. Under the absolute maximum ratings in the data sheets, the digital output current Io is 20 mA. Thus it's safe to use a sink current of 7.8 mA. Under the electrical characteristics, the output low voltage VOL is 0.6V max for a 6mA sink current. At a 8mA sink current, VOL may be higher and approaching the 0.8V upper limit of the input low voltage threshold VIL. If this is the case, we may have to back off the target sink current by using a higher pull-up resistor (e.g. 1.2Kohm, 1.5 Kohm...). If you have access to an oscilloscope, you can use it to measure the low output voltage as you try different pull-up resistor values.

3) You can put the extra pull-up resistor at either the GrovePi or sensor side of the cable. (You need one resistor for each of the SDA and SCL wires.)
Binh Bui

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 1:11 pm

I've changed the wiring (SDA and GND in twisted pair 1 (orange/orange-white), SCL and GND in twisted pair 4 (brown-brown-white) and installed a pull-up resistor of 1k between SDA and +5V and between SCL and +5V on the side of the GrovePi (just before the RJ45-socket which goes to the cable). The +5V is going through the other wire. I measured the voltages in the sensorbox (in stand by modus, e.g. without sending any commands to the RPi).

GND -> +5V = 4.63V
GND -> SCL = 0V
GND -> SDA = 4.61V

This is consistent with the result I get from
gpio readall

Code: Select all

[email protected] ~ $ gpio readall
+----------+-Rev2-+------+--------+------+-------+
| wiringPi | GPIO | Phys | Name   | Mode | Value |
+----------+------+------+--------+------+-------+
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | High  |
|      2   |  27  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | High  |
|      5   |  24  |  18  | GPIO 5 | IN   | High  |
|      6   |  25  |  22  | GPIO 6 | IN   | High  |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   2  |   3  | SDA    | ALT0 | High  |
|      9   |   3  |   5  | SCL    | ALT0 | Low   |
|     10   |   8  |  24  | CE0    | ALT0 | High  |
|     11   |   7  |  26  | CE1    | ALT0 | High  |
|     12   |  10  |  19  | MOSI   | ALT0 | Low   |
|     13   |   9  |  21  | MISO   | ALT0 | Low   |
|     14   |  11  |  23  | SCLK   | ALT0 | Low   |
|     15   |  14  |   8  | TxD    | ALT0 | High  |
|     16   |  15  |  10  | RxD    | ALT0 | Low   |
|     17   |  28  |   3  | GPIO 8 | IN   | Low   |
|     18   |  29  |   4  | GPIO 9 | IN   | Low   |
|     19   |  30  |   5  | GPIO10 | IN   | Low   |
|     20   |  31  |   6  | GPIO11 | IN   | Low   |
+----------+------+------+--------+------+-------+
because SDA is High and SCL is Low

This means there's some voltage loss, but not very much. 4.6V should normaly be engough the get the sensors running fine.

The sensors still aren't detected by
sudo i2cdetect -y 1
even worse, now nothing is detected, neither the GrovePi (0x04), the barometic sensor (0x77), the digital light sensor (0x29) or the I2C 1-Wire Host Adaptor (0x18) are shown. The only thing I see is a UU on 0x3b and a UU on 0x51. This is the result:

Code: Select all

[email protected] ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $
.

If I unplug the UTP cable for I2C (but leave the UTP cable for the other sensors; wich means SDA and SCL of both sensors aren't connected anymore), I get this result:

Code: Select all

[email protected] ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $
Both the GrovePi (0x4) and the I2C 1-Wire Host Adapter(0x18) then become detectable.

When I connect the sensors directly in the I2C-ports of the GrovePi they are connected, so there's nothing wrong with the sensors.

Maybe 12.5m cable is indeed to long. If I leave out the digital light sensor and only use the barometic sensor, I can work arround the problem (without solving it) by placing the barometic sensor next to the GrovePi / Raspberry Pi in the cellar (I know what the difference in altitude is, so I can calculate the barometic pressure in the sensorbox). Of course this can't work for the light sensor because the light in the cellar is not related to the light outside.
Last edited by Johan Vandewalle on Wed Jul 23, 2014 3:01 pm, edited 3 times in total.
Johan Vandewalle
(Belgium)

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 1:21 pm

Hi,
Johan Vandewalle wrote:The sensors still aren't detected
Lower the I2C bus speed.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 2:41 pm

Make sure the pullups are at the far end of the cable.

12 meters is pretty long. You may need an I2C "extender".

A P82B715 is one possible solution. It permits operation at cable length up to 50 meters.

http://www.nxp.com/documents/data_sheet/P82B715.pdf
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 8:15 pm

Richard-TX wrote:Make sure the pullups are at the far end of the cable.

12 meters is pretty long. You may need an I2C "extender".

A P82B715 is one possible solution. It permits operation at cable length up to 50 meters.

http://www.nxp.com/documents/data_sheet/P82B715.pdf
This seems indeed very easy to install. I wonder if there's a giant difference with the PCA9600 wich I mentioned in the original post: http://www.raspberrypi.org/forums/viewt ... 01#p580101. The link to its datasheet is here: http://www.nxp.com/documents/data_sheet/PCA9600.pdf.

Unfortunately both are products of NXP. It seems very hard to order them online in small quantities (I only need 2 of them) if your in Europe (Belgium). The shipping cost and custom costs are much to high to order a 2 USD item (they charge about 36 USD for shipping and then you have to pay VAT (21% on both the product and shipping) and import tax (10.4% on both the product and shipping). To total cost would be for 2 of these extenders: 2 * 2 USD + 36 USD shipping + 16 USD VAT + 4.24 USD import taxes = 60.24 USD (about € 44.75) for just 4 USD value (or € 2.97). does anyone knows if there are suppliers in Europe where you can order only to (or even 5 or 10) of these with limited shipping costs?
Johan Vandewalle
(Belgium)

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 8:30 pm

Hi,
Johan Vandewalle wrote:does anyone knows if there are suppliers in Europe where you can order only to
You can buy two PCA9600DP or P82B715TD chips for cca. 13 EUR (UPS next day delivery included):
http://be.farnell.com/nxp/p82b715td-112 ... dp/1627047
http://be.farnell.com/nxp/pca9600dp/ic- ... =lookahead


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
joan
Posts: 14004
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 8:33 pm

Have you tried lowering the I2C bus speed as suggested?

bbodin
Posts: 70
Joined: Sat Jun 28, 2014 3:23 pm

Re: maximum cable length I2C with twisted pair?

Wed Jul 23, 2014 9:00 pm

Try the lower standard speed (100 kHz) as suggested.

The P82B715 is also sourced by TI. The through-hole PDIP part number is P82B715P. You can buy this IC on Ebay or this board for $18.95 with free shipping.
Binh Bui

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 5:07 pm

joan wrote:Have you tried lowering the I2C bus speed as suggested?
I'm not shure about this. IS lowering the bus speed possible for just the two sensors on the long cable (the Grove barometic sensor and the Grove digital Light sensor) without affecting the bus speed for the I2C to 1-wire host apdaptor? I woun't like I2C to 1-wire host adapter adaptor speed to get lower as well since it has to read out 6 DS18B20 1-wire temperature sensors every 10 seconds (which means the communciation speed per sensor is 1/6th of 30 seconds or less than 2 seconds to get the reading from the sensors, and send it back to the RaspberryPi over I2C within the same time frame). 1 of these DS18B20 sensors is about 10 m away from the I2C to 1-wire host adapter adaptor, the other 4 are about 1,5 to 2,5 m away.
Johan Vandewalle
(Belgium)

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 5:11 pm

FLYFISH TECHNOLOGIES wrote:Hi,
Johan Vandewalle wrote:does anyone knows if there are suppliers in Europe where you can order only to
You can buy two PCA9600DP or P82B715TD chips for cca. 13 EUR (UPS next day delivery included):
http://be.farnell.com/nxp/p82b715td-112 ... dp/1627047
http://be.farnell.com/nxp/pca9600dp/ic- ... =lookahead


Best wishes, Ivan Zilic.
Thanks Ivan,

I just ordered them (2 pieces of each) for € 15.62 + € 3.28 VAT = € 18.90 and with free shipping and payment via bank transfer after receiving the package.
Johan Vandewalle
(Belgium)

User avatar
joan
Posts: 14004
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 5:14 pm

Johan Vandewalle wrote:
joan wrote:Have you tried lowering the I2C bus speed as suggested?
I'm not shure about this. IS lowering the bus speed possible for just the two sensors on the long cable (the Grove barometic sensor and the Grove digital Light sensor) without affecting the bus speed for the I2C to 1-wire host apdaptor? I woun't like I2C to 1-wire host adapter adaptor speed to get lower as well since it has to read out 6 DS18B20 1-wire temperature sensors every 10 seconds (which means the communciation speed per sensor is 1/6th of 30 seconds or less than 2 seconds to get the reading from the sensors, and send it back to the RaspberryPi over I2C within the same time frame). 1 of these DS18B20 sensors is about 10 m away from the I2C to 1-wire host adapter adaptor, the other 4 are about 1,5 to 2,5 m away.
I don't believe so, I think the bus speed has to be the same for all devices on the bus.

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 8:35 pm

joan wrote:I don't believe so, I think the bus speed has to be the same for all devices on the bus.
That's why I don't want to lower the bus speed. The other devices need to operate higher speed. So solving the problem for the I2C devices Grove Barometic Sensor and Grove Digital Lighting Sensor, gives me other problems.

I'll wait till the arrival of the PCA9600DP or P82B715TD chips, and see if that works out.
Johan Vandewalle
(Belgium)

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 8:52 pm

Hi,
Johan Vandewalle wrote:The other devices need to operate higher speed. So solving the problem for the I2C devices Grove Barometic Sensor and Grove Digital Lighting Sensor, gives me other problems.
It seems that your procedure is not optimized... when you initiate DS18B20 temperature measurement, you don't have to wait 750ms (or so) and then continue with next DS18B20 sensor. You could trigger these measurements (6x), then read barometric and light sensors and then come back to DS18B20 and read temperatures results... Consequently, there is plenty of time left (and could lower the bus speed).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

Johan Vandewalle
Posts: 40
Joined: Wed Apr 16, 2014 2:45 pm

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 10:42 pm

FLYFISH TECHNOLOGIES wrote:Hi,
Johan Vandewalle wrote:The other devices need to operate higher speed. So solving the problem for the I2C devices Grove Barometic Sensor and Grove Digital Lighting Sensor, gives me other problems.
It seems that your procedure is not optimized... when you initiate DS18B20 temperature measurement, you don't have to wait 750ms (or so) and then continue with next DS18B20 sensor. You could trigger these measurements (6x), then read barometric and light sensors and then come back to DS18B20 and read temperatures results... Consequently, there is plenty of time left (and could lower the bus speed).

Best wishes, Ivan Zilic.
The procedure is indeed not very simple, this is because I read the temperature with the DS18B20's through the I2C to 1-wire host apdaptor. This is done by calling the owread function at the RaspberryPi prompt:

owread /28.sensor_ID/temperature; echo

in the script this is the command:

Code: Select all

for loop in range(0, 6):
	now = time.time()
	f=os.popen(*owread /* + str(sensor_ID[loop] + "/temperature")
	for i in f.readlines():
		temp += i
	print("Sensor " + str(loop) + ", sensor_ID: " + sensor_ID[loop], + str(round(float(temp), 2)) + " degr. C, time = " + str(now) )

Johan Vandewalle
(Belgium)

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: maximum cable length I2C with twisted pair?

Thu Jul 24, 2014 10:59 pm

Hi,
Johan Vandewalle wrote:
FLYFISH TECHNOLOGIES wrote:It seems that your procedure is not optimized...
This is done by calling the owread function at the RaspberryPi prompt:
Ok, I see...

If/when you'll run out of resources with this approach, feel free to come back and you'll get much better solution... ;-)


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: maximum cable length I2C with twisted pair?

Fri Jul 25, 2014 12:07 am

Hi,
Richard-TX wrote:My son was living in Begium for a few years. He got tired of paying ridiculous fee and tax amounts.
Well, it makes sense always to consider both costs and benefits sides. Public health network is one good example, which you can (unfortunately) still just dream about, for example.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

Return to “Interfacing (DSI, CSI, I2C, etc.)”