I2C Bus Facts

There seems to be a lack of clarity in the Raspberry Pi community about the characteristics of the I2C bus and the proper means of connecting the Raspberry Pi to an I2C bus.  This blog page is my attempt to clarify and to contradict the glib advice that is currently being given on the Quick2Wire blog (posted 29Mar13).

Fallacy #1:  An Arduino I2C bus is defined by the weak internal pull-up resistors of an AVR MCU.
Contradiction #1: An ATmega Arduino I2C bus is a 5V bus with whatever pull-up resistors have been put in place to provide the desired level of performance.  A carefully designed ATmega Arduino I2C bus would not use "weak" pull-ups unless mediocre performance is intended.

Fallacy #2:  You can simply connect the Raspberry Pi to an Arduino I2C bus and "everything will be fine".
 Contradiction #2a:  The devices on an ATmega Arduino I2C bus have been designed to expect a logic High signal "close" to 5V.  (e.g. ATmega > 3.0V, MCP23017 > 4.0V, PCF8591 > 3.5V)  You cannot expect these devices to operate reliably or at high speed/temperature if their Arduino I2C bus is being dragged down by the Raspberry Pi's "pull-up" resistors.
Contradiction #2b:  Some popular Arduino devices include their own pull-ups to 5V (eg the Tiny RTC includes 3.3KOhm pull-ups).  The sum of these "extraneous" pull-ups with the deliberate pull-ups may be sufficient to threaten the wellbeing of a Raspberry Pi despite its 1.8K resistors to 3.3V.
Contradiction #2c:  If you do connect a Raspberry Pi to an ATmega Arduino I2C bus, it will no longer be an ATmega Arduino I2C bus because the voltage levels will be incorrect.  Instead, it will be a seriously compromised I2C bus that lacks integrity from both Arduino and Raspberry Pi perspectives.

Conclusion:  If you want your I2C bus to operate reliably and at high speed whilst tolerating the inevitable variations in temperature and power supply voltage, do not connect mismatched devices to the bus.  An ATmega Arduino I2C bus operates at 5V.  A Raspberry Pi I2C bus operates at 3.3V.  The standards are there to provide an assurance of good performance.  If you compromise the standards you must accept that performance will be degraded.  If that's "fine" with you, so be it. 

Considering Arduino Due: The above remarks do not consider the Arduino Due which has 2 I2C buses which operate at 3.3V, one with 1.5KOhm on-board pull-ups and the other without.   Arrival of the Arduino Due means that the Arduino community has to grasp the same nettle as the Raspberry Pi community in recognising that a compromised I2C bus will be just that, compromised to operate at degraded performance levels.
Since Raspberry Pi and Arduino Due both operate at 3.3V, the Raspberry Pi will be directly compatible with the Arduino Due's I2C bus from a voltage tolerance and threshold point of view.  The combination of pull-up resistors does however present a different compatibility challenge.  The two sets of pull-ups (1.5K and 1.8K) will operate in parallel to be effectively 818 Ohms.  To pull 3.3V down to ground against 818 Ohm pull-up resistors requires the driver to sink 4mA of current, a fairly demanding task that may be near or beyond the limit of the Raspberry Pi's capability.  


No comments:

Post a Comment