Let's Make Robots!

Running both 5v and 3.3v devices on I2C

 

Problem Statement:

 

 

  1. Arduino UNO is the most prolific version of Arduino board, and runs at 5v DC.  It's I2C interface (Analog pins A4 and A5)  will drive to 5v.
  2. Raspberry Pi runs at 3.3v.  Both of it's I2C interfaces run at 3.3v.
  3. I2C devices purchased through Sparkfun, Adafruit, SeeedStudio, Parallax,  Pololu, can be any combination of 3.3v or 5v

I know the mantra is that if you only pull the SDA and SCL lines up to 3.3v on a I2C device,

they will work fine on a 5v I2C bus, but depending on tolerances of the device..

 

 

Running a 3.3v I2C device on a 5v I2C bus 

can either destroy the device immediately... 

or more likely... 

significantly reduce it's lifespan. 



 

So, how do we safely run 3.3v devices alongside 5v devices on the same bus?  

With a Bi-directional Logic Level Converter...

 

 

Logic Level Converter:  https://www.sparkfun.com/products/11978

 

 

From Sparkfun's Tutorial: ( Sparkfun: Using the Logic Level Converter )

LLC input and output arrowsLLC divided into thirdsThe LLC is designed to be very easy to use. Silkscreen indicators help identify which pins do what. There are twelve pins total – six on each side. We can divide them into groups of three to more clearly define how they relate:
The middle section of the board is where the reference supply for your high and low voltages should go. Supplying voltage to all four of these pins is required. If you’re converting 3.3V to 5V (and vice-versa), for example, you’d run 5V into the “HV” side, and 3.3V into the “LV” input. Make sure each is grounded too!
The outer pins correspond to inputs and outputs for channels 1 and 2. Each channel has one voltage divider and one MOSFET shifter.
The labels on these pins – “RXI”, “RXO”, “TXI”, and “TXO” – help describe what each pins does:

  • RXI – High voltage input to voltage divider from high-voltage device. Signal will be shifted down and sent to low-voltage device on “RXO” pin.
  • RXO – Low voltage output from voltage divider to low-voltage device. Signal is shifted down from “RXI” input.
  • TXI – Low voltage input/output of MOSFET circuit. This pin interacts with “TXO” on the high side. Bi-directional, but this is the only shifter that will shift from low to high.
  • TXO – High voltage input/output of MOSFET circuit. This pin interacts with “TXI” on the low side. Bi-directional, but this is the only shifter that will shift from low to high.

To send a signal from the low-voltage side to the high-voltage side (e.g. from 3.3V to 5V), the signal must be input at “TXI”. It’ll pass through the converter and come out as a higher voltage on the “TXO” (transmit output) pin.
On the other hand, a signal that strictly travels from high to low-voltage should pass from “RXI” to “RXO”.
Sending a signal from the high side to the low side is less restricted. We can use either the bi-directional channel or the voltage divider, but we may need to leave the bi-directional channel for converting from low-to-high.

 

 

Example Wiring of 3.3v and 5v I2C devices together.


Here, we have an Arduino UNO, an Accellerometer, a Compass, a Barometric Pressure Sensor, and a Raspberry PI all on the same I2C channel.  The neat thing is that with the UNO, as it has a 3.3v regulator on board, you can power  both 3.3v and 5v devices.

 

 

 


References:

Arduino Forum : I2C Bus with 3.3v and 5.0v Device

Raspberry Pi and Arduino linked via I2C

Sparkfun: Using the Logic Level Converter

https://www.sparkfun.com/products/11978

 

 

 

Sparkfun,

Adafruit,

SeeedStudio,

Parallax,

Pololu,


Comment viewing options

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

It's not that 5v device won't sense 3.3v, but rather a 3.3v device will not last for any great length of time on a 5v bus.

If, like me, you have chosen for one reason or another to purchase the lowly Arduino UNO, this becomes important...  When using the UNO as an I2C Master, it drives the bus to 5v, even though it has a 3.3v regulator onboard. 

*most* I2C devices are hearty enough to endure over voltage for a period of time, but early failure is definately a concern. 

In the common case of  I2C between Raspberry Pi and Arduino, it is typical that the PI (a 3.3v device) is master, and therefore drives the bus at 3.3v.  This is a high enough signal that the 5v Arduino Slave device can read as a high.   No harm, no foul.

 

In my particular case, I'm attempting to run my I2C bus in Multi-Master mode.   A series of I2C devices, MOST are capable of 5v as they are either highly tolerant, or have a 3.3v regulator onboard...  BUT, in this case, I now have a 3.3v PI as Master, collecting data for logistics and mapping, and a 5v Arduino as Master, collecting from these devices for trajectory and envirnment info.

 

This *could* possibly make the case for a second I2C bus, but I've chosen to use a single bus as both masters need the same info.