1

Currently using i2C to connect a RPi with an arduino. It seems i2C is quite finicky and, drops the bus immediately if there are any IO errors. Since what i am building is meant to be semi permanent, I am worried that i2C may not be the best choice.

Has anyone done any real world testing of i2C vs GPIO for RPi to arduino communication?

  • 4
    GPIO is too generic to compare to without being more specific; for example, you can (with some difficulty) implement I2C using GPIOs. I2C reliability/recovery problems are likely more about drivers than peripheral blocks themselves. – Chris Stratton Jul 22 '14 at 20:48
1

Here are a few things to remember:

  • You should have a ground connection between the RPi and Arduino
  • I2C was meant for really short distances on a printed circuit board
  • Arduino runs at 5 Volt logic levels and RPi at 3.3 Volt logic levels - you need a level translator between them to make that work.

If the RPi and the Arduino are not far apart, I would say less than 1 foot (30 cm) and you have the grounds connected between the boards, then it is a software issue. I2C is meant for short distances any anything longer than a foot puts too much capaitance on the wires and starts causing unreliable communication. I would not even use it for more than a few inches unless it was on a circuit board where you control the capacitance.

I am assuming your using the Wire library on the Arduino side. On the RPi side I would use the the Adafruit I2C library for the RPi as I have had success using the library to communicate with I2C sensors listed on their site. Here is the link:

Adafruit RPi I2C Tutorial

| improve this answer | |
  • Not sure there is such a thing as the 'Adafruit' i2c library. The instructions on the adafruit site are quite good, but really no different than those on half a dozen other blogs. Also I believe you are incorrect about needing a level translator if connecting just one device. – Bachalo Jul 24 '14 at 1:52
  • 1
    Sorry, I2C is not the library, I was thinking the smbus Python library they tell you to apt-get. That is what I installed for my RPi. As for the level translator - you should not put 5 Volt signals to the RPi pins as it will burn them out. It might take a little while, though in my experience I burn out a few GPIO with 5 Volt signals as soon as I turned power on. Take a look at this from the Raspberry Pi website: raspberrypi.org/documentation/hardware/raspberrypi/gpio/… – tiger19tony72 Jul 24 '14 at 2:03
  • @tiger19tony72 is right. If its 5V, use 5V, if 3.3V use 3.3V. Specifications exsit for a reason :) – Martynas Oct 22 '14 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.