Loading...
Pages: [1]   Go Down
Author Topic: I2C Pin Voltage  (Read 655 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are the I2C pins on the Arduino and Arduino Mega 5V only?
Logged

Illinois, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 126
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If the board is 5V, the I2C pins are 5V. They can usually connect to 3.3V devices as long as the other device is 5V tolerant (meaning they won't be damaged by 5V).

If the Arduino is 3.3V I don't think they are 5V tolerant. It will probably work, but the ATMega168 datasheet (for example)says the max input voltage is Vcc+0.5V so anything over 3.8V is risky.
Logged

0
Online Online
Tesla Member
***
Karma: 73
Posts: 6638
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, you mustn't overdrive the input protection diodes....  The I2C bus is supposed to be driven open-drain, so if all devices are playing properly you could try using pull-ups to 3.3V - but check the input voltage high specs for the 5V devices.  I can't remember whether the ATmega I2C hardware is open-drain or not.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 41
Posts: 5176
CMiYC
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't remember whether the ATmega I2C hardware is open-drain or not.
Yes it is.

Since the I2C pins are Open-Collector, it is possible to use external pull-up resistors to 3V3, to make the lines 3V3 compliant.  However, the Arduino libraries turn on the internal pull-ups, which pulls-up the lines to VCC (5V).  So you must modify the library before using them with a 3V3 pull-up.

If you look at the Wire library in the libraries folder, there is a folder called "Utility."  Inside there, you must modify twi.c to turn-off the internal pull-ups.
Logged

www.cmiyc.com - A guide to being an Enginerd

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The I2C sensor I'd like to connect to the Arduino has 1k pull-up resistors on SDA and SCL and accepts an input voltage between 1.4V to 3.6V DC. How do I get that to work with the Arduino's I2C pins?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 41
Posts: 5176
CMiYC
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

See above.  You need change the Wire library so that it does not turn on the Internal pull-ups.
Logged

www.cmiyc.com - A guide to being an Enginerd

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I ask because the diagram on this page shows the sensor in question connected to 3.3V and with SDA and SCL connected to the Arduino's I2C pins. The author doesn't say anything about changing the Wire library to disable the internal pull-ups.  Here's the schematic for the sensor.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 41
Posts: 5176
CMiYC
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't believe all of the tutorials you read on the internet.

It probably won't damage the TMP, but you really should disable the internal pull-ups.
Logged

www.cmiyc.com - A guide to being an Enginerd

Offline Offline
Edison Member
*
Karma: 9
Posts: 1000
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We should be able to use the Wire library for 3.3V components.
So I have posted this: http://arduino.cc/forum/index.php/topic,105291.0.html
I think that the wire library should change (replies about wire library with that topic please).
« Last Edit: May 10, 2012, 08:18:07 am by Krodal » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all for your help.

The problem with modifying the Wire library for a particular project is that the change isn't visible to someone who is only looking at the sketch, which is just a recipe for trouble. An alternative is to use a bidirectional 5.5V to 3.3V level translator on SCL and SDA, but having a way to explicitly disable the internal pull-ups via the Wire library would be a good alternative for use with external pull-ups.
« Last Edit: May 10, 2012, 09:03:13 am by AdrianLopez » Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 41
Posts: 5176
CMiYC
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

After giving this some more thought...

The internal pull-ups on the ATmega328 might be so weak, it doesn't matter.  It'd be nice to disable them, but having them enabled may not cause issues, assuming stronger external pull-ups are used (<4.7k).

I suppose it be possible to simply call digitalWrite(A4, 0) and digitalWrite(A5, 0) after initializing TWI. 
Logged

www.cmiyc.com - A guide to being an Enginerd

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

You can use this version of the I2C library, it has an option to disable the pull up resistors as well as change the speed:-
http://dsscircuits.com/articles/arduino-i2c-master-library.html

On some versions of the arduino like the new Mega, there are pull up resistors on the board which means that you can't easily change it to drive a 3V3 system.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On some versions of the arduino like the new Mega, there are pull up resistors on the board which means that you can't easily change it to drive a 3V3 system.
I have the R3 version of the Arduino Mega. Should I just go ahead and use a logic-level translator?
Logged

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

Quote
Should I just go ahead and use a logic-level translator
Yes.
Logged

Pages: [1]   Go Up
Print
 
Jump to: