Now, since the Raspberry Pi is an extremely popular nifty little device, we buy it and we fiddlers want to connect it to the also very popular Arduino development boards. Now, lets say, our project focuses itself on the Raspberry Pi as a home automation server and we want to connect it to the Arduino development boards. But we want to do this over a length of, let’s take this example, 16 meters. We then have some limits we face.
One of I²C specifications is that the total capacitance on the bus should not exceed 400pF, and this includes everything from physical layer and maybe used microchips, connectors etc… Lets say in an ideal world the capacitance of an cat5 cable is between 47.5 and 55 pf/m and just connect 2 devices on the bus, you will have a maximum between 7.2 and 8.4 meters. Well, in our setup, that is not even the under limit in bus length we want to achieve. And besides that. The raspberry pi runs 3.3 volt, and the Arduino 5 volt. It is possible to mix it, if you are feeling bold, but to do some logic level conversion is advised, and i won’t explain why mixing would work.
Lets raise the bar a little bit
We are going to extend the bus from a couple of meters to 16 meters, and we are going to do logic level shifting from 3.3 to 5 volts. With the simple method used we make it possible to use I²C as well in close range as far from the Raspberry Pi. By using the Adafruit 4-channel I²C-safe Bi-directional Logic Level Converter. directly at the raspberry pi’s I²C pins we go from 3.3 to 5 volts. This converter has two Vcc pins. As logical one for 3.3 Volt lv pin and the 5 volt hv pin. To extend the length of the I²C bus i used two Texas Instruments P82B96 Bidirectional buffer chips (p82b96 spec sheet ). I use one on the “master” side of the bus, and one of the “slave” side of the bus. I specific say “master” and “slave” because as of this moment the Raspberry Pi does not support I²C slave mode. If this is added in the future the current setup will support it. I use the p82B96 chip because eventually i want to further extend the buffered bus from 16 to 50 meters, and leave some extra space for splitting up. This chip supports up to 4000pF, and has a nice sink Amperage. Read the spec sheet for more info. The picture below shows a test setup. This setup has an Arduino attached at the long”slave” end, and an BlinkM attached to the logic level converter next to the “master” I²C extender.
In the screenshot below i logged in to the pi, just did an i2cdetect command. Maybe some of you will recognize the addresses, The 0x09 Address is the default for the BlinkM, and the 0x40 address is the address of the Arduino running the I2C-LTS-LC sketch software.
The devices do lay close together on the desk, but the Arduino is connected to an 16 Meter cat5 cable, via an extender.
To build the extender on your own you need a couple of parts:
- Adafruit 4-channel I²C-safe Bi-directional Logic Level Converter
- 2 Bidirectional P82B96 buffers,
- 4 x 330 Ohm resistors,
- 2 4.7 kOhm resisters,
- Breadboard wires, or other wires you would like to use.
- Offcourse a raspberry pi and an Arduino with a simple I²C sketch on it, but instead of an Arduino any I²C device supporting 100Khz should work.
Below the screenshot of a simple with fritzing created scheme. Use the 4 x 300 Ohm resistors at the bus size as pull ups, and the 4.7 kOhm resistors as pullups for the arduino, or other I²C device. The I2Cext devices are the extenders. I think you will be ok with 330Ohm up to 25 meters, and 4 times 780 Ohm (i did not got the change to test that) up to 50 meters.
Have fun building! The original Fritzing will follow as soon as possible.
Here is a soldered result of the above
Be aware, this setup does not do any sort of isolation! i should have used some Schottky and Zener diodes. When there is a correct setup of the above, i will change the page, so you can create a correct extender. but this should get you started.