3.3v and 5v logic level converter question

Due to the ambiguity of the search terms I have been unable to find an exact answer to this scenario.

I am using various devices, some which require 5v and others 3.3v. Some use i2c, but they're not sharing the same i2c pin. Here's a concrete scenario:

device 1: 3.3v, using i2c, pins A5 for clk, A4 for data.
device 2: 3.3v, uses pin D7 for clk D8 for data.
device 3: 5v, uses pin D2 for data tx/rx.
device 4: 5v lcd, uses software serial pin 5.

I have not hooked up device 4 yet. I have a logic level converter hooked up for device 3 and it works great. I don't want to fry anything by attempting to simply hook up device 3 directly to pin 2. Is this only a problem when the pin being used is shared between differing voltage devices, or do you need to use a logic level converter for everything when you have devices using differing voltage. My intuition says you only need it when the pin is shared, but I don't want to be wrong and let out the magic smoke. :expressionless:

device 2 can’t be doing I2C on pins 7/8. Must be faking it in software (soft I2C?)

device 3 can’t be doing serial on pin 2. Must be faking it in software (soft serial?)

device 4 - same comment as device 3.

Hardware I2C is only available on A4/A5 (SDA/SCL) pins.

All I2C devices can be connected in parallel to the I2C pins, the internal pullup disabled, and pulled up to 3.3V with external 4.7K resistor.
I2C gets a high level from the resistor, the devices use open-drain or open-collector circuits to pull the pins low.

MrGarak:
Due to the ambiguity of the search terms I have been unable to find an exact answer to this scenario.

I am using various devices, some which require 5v and others 3.3v. Some use i2c, but they're not sharing the same i2c pin. Here's a concrete scenario:

device 1: 3.3v, using i2c, pins A5 for clk, A4 for data.
device 2: 3.3v, uses pin D7 for clk D8 for data.
device 3: 5v, uses pin D2 for data tx/rx.
device 4: 5v lcd, uses software serial pin 5.

I have not hooked up device 4 yet. I have a logic level converter hooked up for device 3 and it works great. I don't want to fry anything by attempting to simply hook up device 3 directly to pin 2. Is this only a problem when the pin being used is shared between differing voltage devices, or do you need to use a logic level converter for everything when you have devices using differing voltage. My intuition says you only need it when the pin is shared, but I don't want to be wrong and let out the magic smoke. :expressionless:

If the line isn't bidirectional then a simple voltage divider (two resistors) will drop 5V down to 3.3V.

Indeed, I have a logic level converter already and it works fine, I am just wondering if I need it in my situation.

Yes, device 1 is the only one that uses hardware i2c. 2 and 3 use custom software protocols, and 4 uses software serial. I guess to make the question more clear: Can the arduino support differing voltages being used on different pins? i.e. pin D4 connected to a 3.3v device and pin D8 connected to a 5v device. Or must all pins use the same voltage?

MrGarak:
Indeed, I have a logic level converter already and it works fine, I am just wondering if I need it in my situation.

Yes, device 1 is the only one that uses hardware i2c. 2 and 3 use custom software protocols, and 4 uses software serial. I guess to make the question more clear: Can the arduino support differing voltages being used on different pins? i.e. pin D4 connected to a 3.3v device and pin D8 connected to a 5v device. Or must all pins use the same voltage?

All I/O pin voltages will be according to the Vcc voltage used to power the chip. That is +5vdc on most arduino boards, 3.3vdc on a few available modular boards. Note that you can generally wire a 3.3vdc signal output to an arduino input pin even on a 5 volt board, but sending 5 vdc from an output pin to a 3.3v input device is usually not allowed unless it's stated as being '5 volt tolerent'.

Lefty

Thanks for the info, Lefty. To clarify my understanding then, is the wiring example here for the 3.3v BMP085 pressure device incorrect on an uno r3?

(page is at BMP085 Barometric Pressure Sensor Quickstart - SparkFun Electronics)

From your reply, the sending of data on A4 would be at 5v despite the BMP085 vcc being wired to 3.3v?

"the sending of data on A4 would be at 5v despite the BMP085 vcc being wired to 3.3v? "
Yes, both SCL & SDA from the '328 will be 5V unless you turn off the I2C pullupw within the '328 and let the external device provide the pullups.

Thanks. According to the schematic, the breakout board has 4.7k ohm pullups, so I guess this is why they suggest that wiring example.

EDIT: Verified with a multimeter that the voltages are in fact 3.3v at those two pins.

Crossroads... I've seen the description before but perhaps you might be kind enough to repeat it... before I did-remember it entirely?

Bob

Verified with a multimeter that the voltages are in fact 3.3v at those two pins.

I suspect the 4k7 to 3v3 is overriding the ~40k internal pullup to 5v if indeed they are enabled.


Rob

@Docedison, what part?

All I2C devices can be connected in parallel to the I2C pins, the internal pullup disabled, and pulled up to 3.3V with external 4.7K resistor.
I2C gets a high level from the resistor, the devices use open-drain or open-collector circuits to pull the pins low.
Yes, both SCL & SDA from the '328 will be 5V unless you turn off the I2C pullups within the '328 and let the external device provide the pullups.

I would assume they're enabled since I am using the default arduino framework. I have an sht75 sensor I'm using at 3.3v and its data pin also measures 3.3v. That data pin is in parallel with a 10k resistor to 3.3v so I assume that's the reason?

Or the lower resistance to 3.3v is overcoming the higher resistance to 5V.

CrossRoads:
All I2C devices can be connected in parallel to the I2C pins, the internal pullup disabled, and pulled up to 3.3V with external 4.7K resistor.
I2C gets a high level from the resistor, the devices use open-drain or open-collector circuits to pull the pins low.
Yes, both SCL & SDA from the '328 will be 5V unless you turn off the I2C pullups within the '328 and let the external device provide the pullups.

I'm trying to get this all clear. The 328P d/s says the SCL,SDA pins use open-drain when in I2C mode,
but Table 28.7 says Vih must be minimum 0.7Vcc = 0.75V = 3.5V. [general I/O pins say 0.6*Vcc].

So, from this it would appear you cannot connect I2C devices with 3.3V pullups to a 5V Arduino. So,
????????

Secondly, I assume the Wire library sets the bitrate for I2C = 100-Khz default. Is it possible to run
at up to 1000-Khz for fast I2C devices.

I could never figure out how to set the ports low so I could connect a 3V3 device to the Arduino and let the 3V3 source do the pull-up. I built a level converter between my BMP085 and my Arduino... I'd sure like to get rid of it... If I could as they are extra unnecessary parts. That was why I asked about how to have the ports not asserted high. The Bus should be low and pulled up by whatever is using it... Not pulled high... great for 5V stuff but that's slowly becoming history.

Bob

I could never figure out how to set the ports low so I could connect a 3V3 device to the Arduino and let the 3V3 source do the pull-up.

Isn't setting open-drain taken care of automatically by the Wire.begin() function? In which case,
the idle state of SCL,SDA will automatically revert to the pullup levels. IOW, the I2C port takes
case of all the level setting.

But that still doesn't solve the 0.7 * 5V = 3.5V problem.

I could never figure out how to set the ports low so I could connect a 3V3 device to the Arduino and let the 3V3 source do the pull-up.

If you are thinking about a software i2c implementation, initialize the pins low, and then turn the pins to output / input to write '0' and '1' on the bus. Do not use the pinMode() call for that, use DDRx directly.

"But that still doesn't solve the 0.7 * 5V = 3.5V problem."

At Vcc = 2.4V to 5.5V, Vih minimum is 0.6 * Vcc. at 5V, that is just 3V.
See Table 29-1 of the '328 data sheet.

At Vcc = 2.4V to 5.5V, Vih minimum is 0.6 * Vcc. at 5V, that is just 3V.
See Table 29-1 of the '328 data sheet.

See post #13, Table 28.7 in my datasheet (8161D) says 0.7*Vcc for I2C.

Latest 328 spec

TWI (I2C) is now section 29.
I don't have answer for the apparent Vih min level requirement conflict.
I do know that pulling up to 3.3V works - another user just physically removed pullups to 5v and wired in pullups to 3.3V to support a 3.3V device.

Turning off the pullups - maybe as simple as digitalWrite(A4, LOW); and digitalWrite(A5, LOW); after Wire.begin(); is called?