Let's Make Robots!

I2C logic level converter

Convert 5V I2C signals to 3V3 and 3V3 signals to 5V

Arduino's and its clones come in many flavours, some work @ 5V others @ 3V3. If you want to communicate over the I2C bus between 2 Arduino's with different voltages you will need to convert the signals to the correct voltage. There are also lots of digital sensors (for example accelerometers, gyroscopes, ...) that are only 3V3 tolerant. You can not connect them to a 5V Arduino. You first need to convert the voltage. I2C uses 2 pins, SDA and SCL. So its easy to hook up a sensor or communicate between Arduino's. You also need to connect the grounds of the Arduino's.

To convert I2C signals we need a bi-directional logic level converter. I2C was invented by Philips, they have written an application note on how to convert I2C signals (see the link to the pdf on the top).

The easy way to convert I2C signals:

Sparkfun sells a logic level converter for less then 2$ -> https://www.sparkfun.com/products/8745 Buy it and hook up your I2C pins and your ready :)

We can of course make it ourself. On page 10 of the Philips application note there is a schematic for a bi-directional logic level converter. I redrew the schematic in Eagle and generated a simple PCB for it. The circuit only uses 4 resistors and 2 small logic level mosfets. I used 2N7000 mosfets and 4 2K2 resistors. Soldered the components and some pins on a small piece of perfboard and now I have a working logic level converter.

I2C is well supported by Arduino. The standard Arduino IDE comes with the wire library, this lib handles the I2C communication. It's not the easiest lib. If you want to keep things simpler there is another lib written that's very easy to implement. See here on the bottom of the page: http://www.gammon.com.au/forum/?id=10896

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This is a bloody superb circuit. I've used it with massive success to interface a Wii Nunchuk to a Microchip PIC. My version here includes an edge connector to attach a USB / I2C interface and a voltage regulator to power the nunchuk. The USB nunchuk doesn't get enough publicity!

This is the explanation of mister Philips (copy/paste from the application note):

2.3.1
 Description of the level shift operation.
For the level shift operation three states has to be considered:

 State 1. No device is pulling down the bus line and the bus line of the “Lower voltage” section is pulled up
by its pull-up resistors Rp to 3.3 V. The gate and the source of the MOS-FET are both at 3.3 V, so its VGS
is below the threshold voltage and the MOS-FET is not conducting. This allows that the bus line at the
“Higher voltage” section is pulled up by its pull-up resistor Rp to 5V. So the bus lines of both sections are
HIGH, but at a different voltage level.

 State 2. A 3.3 V device pulls down the bus line to a LOW level. The source of the MOS-FET becomes
also LOW, while the gate stay at 3.3 V. The VGS rises above the threshold and the MOS-FET becomes
conducting. Now the bus line of the “Higher voltage” section is also pulled down to a LOW level by the 3.3
V device via the conducting MOS-FET. So the bus lines of both sections become LOW at the same
voltage level.


State 3. A 5 V device pulls down the bus line to a LOW level. Via the drain-substrate diode of the MOS-
FET the “Lower voltage” section is in first instance pulled down until V passes the threshold and the
GSMOS-FET becomes conducting. Now the bus line of the “Lower voltage” section is further pulled down to
a LOW level by the 5 V device via the conducting MOS-FET. So the bus lines of both sections become
LOW at the same voltage level.

The three states show that the logic levels are transferred in both directions of the bus system, independent of
the driving section. State 2 and state 3 perform the “wired AND” function between the bus lines of both sections
as required by the I C-bus specification.
Other supply voltages than 3.3V for VDD1 and 5V for VDD2 can be applied, e.g. 2V for VDD1 and 10V for
VDD2 is feasible. In normal operation VDD2 must be equal to or higher than VDD1.
The MOS-FET’s allow that VDD2 is lower than VDD1 during switching power on/off, of course the bus system
is not operational during that time.
The maximum VDD2 is not critical as long as the drain of the MOS-FET can withstand this voltage. At a higher
VDD2 a slower falling edge for both bus sections has to be taken in account, both in state 2 and state 3,
because it takes more discharge time of the bus line.
The lowest possible supply voltage VDD1 depends on the threshold voltage V of the MOS-FET’s. With a
GS(th)threshold voltage of about 1 Volt below the lowest VDD1, the level shifter circuit will operate properly. If for
example the lowest VDD1 is 3 Volt, a threshold voltage VGS(th) of maximum 2 Volt is allowed.

That makes complete sense now. I did not allow for the fact that in State one, the FET would be off.

This is interesting, I do not fully understand how this circuit is supposed to work as it apears the FETs are just on all the time. Can you explain it's opperation?