Sat Sep 21, 2013 2:22 pm
yes, you will need a level shifter to connect a 5V gadget that uses 5V on the I2C bus to the Pi that works with 3.3V.
the simplest level shifter is the type you see on the schematic for the last link. but you do not need the 5V to 3.3V regulator. the Pi already has 3.3V.
the level shifter works in this way:
the MOSFET has the Gate connected to 3.3V and the Source connected to the Pi GPIO. the Drain connects to the I2C bus on the gadget. a resistor from the GPIO pin to 3.3V pulls the pin voltage to 3.3V when the GPIO pin is inactive.
you need a resistor from Drain to 5V, to pull up the pin voltage when the Pi GPIO is high and the MOSFET is OFF.
When the Pi GPIO goes low, the MOSFET turns ON, because its gate is at 3.3V and its Source is at GND. So the Drain goes low.
if the gadget pulls its pin low, current will flow in the body diode of the MOSFET and the Source is pulled down. a low level appears on the Pi GPIO (Source). the MOSFET turns ON, so the Source will swing down to the Drain voltage.
the idea with this contraption is that any device on the I2C bus can pull down the bus voltage. and the 5V devices will see 5V levels and the 3.3V devices will see 3.3V levels. No device can force the bus voltage high. the GPIO must be set so that it has open drain configuration, or a very weak pullup.
for a better understanding, read the I2C specification. there is also a good NXP app note about level shifting, "AN97055, Bidirectional level shifter for I2C bus and other systems". anybody that wants to use this type of level shifter should be aware of its limitations. if the temperature is low, a "normal" low level MOSFET will not work, you need one that has low enough gate threshold. BSN20 is one example. it costs about $0.30 at Mouser. there are also special ICs for level shifting I2C.