Pages: [1]   Go Down
Author Topic: I2C and voltages  (Read 946 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quick question.

Since I2C requires the +ve and ground, do I assume that if I am trying to interface say, my 5volt mini pro to say a 3.3volt gyro sensor that this is a no no?

How should one go about this?
Does one have to have a 3.3V mini pro?

Thanks
Phil
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I2c doesn't require the +ve, it just requires the data lines to be "pulled up". On a 5V system, you'd pull them up to +5V through a resistor, on a 3.3V system you'd pull them to +3.3V.

On a mixed-voltage system, you will probably get away with pulling it up to +3.3V. The 5V system will recognize this as a logic high.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi Rugged,

thanks for the quick response.

So, a common ground and the 'two wires'?  I beleive the arduino pulls up the data lines, so the slaves (if not an arduino) would need those pulled up to their voltage?

Is a common ground required or can I get away with just the two wires?
Does that make sense and is it correct?

Thanks
Phil
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You definitely need a common ground wire.

The Arduino does pull up the data lines (weakly) using internal pullup resistors. You can disable those by writing 0 to the port pins (you write a 1 to enable the pullup resistor), and then add your own physical resistors externally (pulled up to 3.3V) on the slaves. Depending on how fast you want the I2C bus to talk, something between 1.5k and 10k is reasonable (the lower the resistance, the faster the bus).

--
The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34159
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem with doing this is that the pull up is activated for some time before you can deactivate it. Thus subjecting the device to too much voltage. You are better hacking the I2C libary so that they are not enabled in the first place.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm thinking the pullups are so weak (20k minimum, 50k maximum on at ATmega328P) that 5V through that resistance won't damage a 3.3V input.

3.3V zeners could be added to the I2C lines for extra safety, though slowing down the edge rates (bus speed) a bit.

--
The QuadRAM shield: add 512 kilobytes of external RAM to your Arduino Mega/Mega2560
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been playing with an ADXL345 accelerometer, also a 3,3V device connected to my Uno. I connected 2 4k7 resistors between SDA/SCL and 3,3V. Becomes more difficult when you want to combine 3,3 and 5V devices on the same I2C bus.
Logged


Salt Lake City
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This tutorial (http://www.ladyada.net/learn/sensors/bmp085.html) recommends against keeping 3.3V and 5V devices on the same bus.  I'm currently using a 5V RTC and a 3.3V pressure sensor on the same bus with a logic level converter with no real problems.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This tutorial (http://www.ladyada.net/learn/sensors/bmp085.html) recommends against keeping 3.3V and 5V devices on the same bus.

No, you have to interpret the tutorial more carefully. Here is what it says (and I agree):

Quote
You may be wondering, how is it OK to connect a 3.3V chip like the BMP085 to 5.0V data pins like the Arduino? Isn't that bad? Well, in this specific case its OK. I2c uses pullup lines to the 3.3V power pin, so the data is actually being sent at 3.3V. As long as all the sensors/device on the i2c bus are running on 3.3V power, we're fine.

Once again: it is OK to connect 3.3V and 5V devices together over the I2C bus as long as the pullup resistors go to 3.3V, and not 5V.

--
Beat707: MIDI drum machine / sequencer / groove-box for Arduino
Logged

Salt Lake City
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, I apologize, I misunderstood that section.  It is a lot more clear now, thank you!
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 722
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Allow me to take a slightly different position on this. I prefer using a bi-directional voltage translator instead. Something like a PCA9306. For relatively little money (i.e. less than $1 in single unit quantities at Digikey) you get a chip custom-made for these sorts of applications. Seems like a more reliable solution. I take the same approach on the SPI bus.

Lastly, I'd check digikey and other sites for similar gyros that can run on 5V logic levels to avoid the translation need in the first place. Or, run the Arduino at a lower speed and turn the system voltage down to 3.3V...
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't know about the PCA9306, looks like a very easy solution if you want to combine 3,3 and 5V I2C devices. Will have to order one smiley Thanks for the info.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the great replies everyone. 

Best
Phil
Logged

Pages: [1]   Go Up
Jump to: