Are the I2C pins on the Arduino and Arduino Mega 5V only?
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.
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.
MarkT:
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.
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?
See above. You need change the Wire library so that it does not turn on the Internal pull-ups.
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.
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.
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).
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.
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.
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:-
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.
Grumpy_Mike:
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?
Should I just go ahead and use a logic-level translator
Yes.
