So can a 3.3v mCu directly communicate via i2c to a 5v mCu ? the buss will be pulled to the lower voltage 3.3v. And since i2c protocols involves just sinking current is what makes me think it will work
-
1\$\begingroup\$ This depends on the specific devices... I'm also not sure why you say that "I2C protocols involves just sinking current"? I2C is very much a voltage-level protocol... \$\endgroup\$– Ron BeyerCommented Jan 3, 2021 at 17:27
-
\$\begingroup\$ @RonBeyer, they probably mean that the 5-V device won't be driving 5 V onto the bus because it has an open-drain driver rather than totem-pole. \$\endgroup\$– The PhotonCommented Jan 3, 2021 at 17:34
-
\$\begingroup\$ Maybe, if the 3.3V device is 5V tolerant. You really need to say what exact devices you are using. \$\endgroup\$– JustmeCommented Jan 3, 2021 at 17:39
-
\$\begingroup\$ the answer to electronics.stackexchange.com/questions/539731/… may be relevant to this question \$\endgroup\$– V.V.TCommented Jan 3, 2021 at 19:23
2 Answers
It depends what the \$V_{ih}\$ minimum level is on the 5 V device. You can look this up in the datasheet. If it's lower than 2.7 V or so, then you should be okay.
This is a plausible scenario if your 5-V device uses TTL logic levels rather than CMOS. However, the I2C Standard defines the input levels roughly as CMOS levels, so this would require a non-standard device.
With standard-compliant devices it won't be possible, because \$V_{ih}({\rm min})\$ is \$0.7\times V_{dd}\$ and \$0.7\times 5\ V = 3.5\ V\$.
As pointed out in comments, if your 3.3-V device has 5-V-tolerant inputs, you may be able to connect the two devices together directly with the pull-ups to 5 V instead of 3.3 V. Again, check your datasheets. Again this would not be compliant with the I2C standard, but many microcontrollers are not strictly compliant.
-
\$\begingroup\$ The other way is more likely to work - many 3.3V MCUs have 5V tolerant IO pins, especially for I2C pins. \$\endgroup\$– JustmeCommented Jan 3, 2021 at 17:40
-
-
\$\begingroup\$ @Justme I do apologize for not providing an IC as this is just a random question i cant get out of my head. So the next time i ever encounter a situation where i need to connect 3.3v and 5v i2c logics, check if the 3.3 version i2c pins are 5v tolerant before adding a level shifter circuit? \$\endgroup\$ Commented Jan 4, 2021 at 17:27
Don't build a product to sell like you described, but if you are playing around with a home project, it will work well enough to get by.
I use MSP430 MCUs with 3.3V IO with 5V I2C LCD displays. I had to remove the 5V pull-ups on the LCD PWB and add my own 3.3V pullups. Works fine.
Worst case CMOS logic high is 70%, but a typical part switches close to 50%. 70% of 5V is 3.5V, 50% is 2.5V.
-
1\$\begingroup\$ Beware, some 5V devices have I2C ports with Schmitt trigger inputs that do have a higher threshold voltage. \$\endgroup\$ Commented Jan 3, 2021 at 20:53
-
\$\begingroup\$ Its not even a home project, let alone a product to sell. Just a random question i cant get my mind off. I do apologize i was not able to specify an IC \$\endgroup\$ Commented Jan 4, 2021 at 17:24