I2C supply voltage

I have two I2C devices that require 5V supply, and a third that requires 3.3v.
Do the different supply voltages have any significant implications for using all three devices on the same SDA / SCL lines?

It depends on the devices but most I2C devices should work properly with pull ups to +5. Those pins do not supply power, they generally are open drain. Look at the data sheet for each I2C device and see it it will tolerate 5V on the I2C pins.

If needed, level shifters are pretty cheap and simple. You can buy them pre-made on a board or make them with discrete components.
Here is a set of level shifters for an ESP 8266 (3.3V) talking to a 5V LCD.

The devices that have high voltage tolerant inputs are the exception rather than the rule, especially when it comes to I2C inputs.

A part operating at 3.3V needs I2C pulled up to 3.3V. All you need to do is add a level shifter in the I2C lines.

Thanks for the help. I'm afraid I'm still a little confused. Is this right ...?

I2C supply voltages.jpg

I2C supply voltages.jpg

You have shown the Nano as connecting to the 3.3 V side. Nanos operate on 5 V!

Aliexpress item

Paul__B:
You have shown the Nano as connecting to the 3.3 V side. Nanos operate on 5 V!

I've shown the nano connecting to 3.3v (pin17) and 5v (ppin27). Is there something wrong with that?

The position of the level shifter gives the Nano the 3.3V bus, not the 5V bus.

Hi,
What are the I2C devices?
Can you post links to data/spec please?

Thanks.. Tom.. :slight_smile:

5V : 16x2 LCD with HW-061 backpack (this was off eBay and I've struggled to find a datasheet for it.)
5v : Adafruit 1270 large 7 seg LED display
3.3v : Sparkfun SX1509 i/o expander

That I/O expander is an interesting one. It's operating at 3.3V but its inputs are 5V tolerant. The I2C pins however are NOT 5V tolerant so you need a level shifter for this one.

Beware that if using this for driving LEDs you will want to wire them active low, as the inputs can sink 15 mA but source only 8 mA. Of course it's sourcing current at 3.3V, that's another issue when driving white or blue LEDs.

For your HW-061, a quick Google search showed me the details including schematic. This is almost certainly a common I2C backpack, based on the PCF8574 port extender - you will be able to find that number on the big chip.

wvmarle:
For your HW-061, a quick Google search showed me the details including schematic.

The google algorithms must be very different for you. Searching for "hw-061" "datasheet" returned 6 pages for me and none of them were any use. Could you share the link you found please?

Here you go.

Schematic in one of the first links.

It's really a bog standard I2C backpack for those 1602, 2004 and related LCD displays.

Thanks.

I'm still not clear how to connect these three devices together.
From what I've read, I2C devices are "voltage agnostic", and both 3.3v and 5v can be supplied via the Nano. But with these devices specifically requiring different supply voltages, I have no sense of what the voltage on the SDA and SCL lines is, nor whether it is required to level shift the 5v devices or the 3.3v device if they share the same SDA and SCL line.

(Apologies if I'm missing what appears to others to be blindingly obvious.)

As said before, you need an I2C level shifter between the 5V and 3.3V devices. 5V device uses a 5V I2C bus. A 3.3V device uses a 3.3V I2C bus. It's as simple as that.

Many 5V devices can work with 3.3V devices - the Atmega328P etc. are an example.
The internal pullups need to be turned off after Wire.begin() is called;
then external 3.3V pullups are used (perhaps located on the module being used).
If any onboard pullups are installed (Mega2560) they need to be disconnected/removed.

wvmarle:
As said before, you need an I2C level shifter between the 5V and 3.3V devices. 5V device uses a 5V I2C bus. A 3.3V device uses a 3.3V I2C bus. It's as simple as that.

Do you mean the SCL and SDA voltages will always operate at 5v because the Nano runs at 5v, and the SX1509 will always need to have the SCL and SDA lines dropped to 3.3V? (See image below.)

The Sparkfun tutorial suggests it can be used with (their) Arduino without level shifters, albeit with a 3.3v supply voltage.

Or do you need a level shifter because there are 5v devices sharing SCL and SDA? In which case, why does the level need shifting for the 3.3v device rather than the 5v devices?

I2C supply voltages 2.jpg

I2C supply voltages 2.jpg

CrossRoads:
Many 5V devices can work with 3.3V devices - the Atmega328P etc. are an example.
The internal pullups need to be turned off after Wire.begin() is called;
then external 3.3V pullups are used (perhaps located on the module being used).
If any onboard pullups are installed (Mega2560) they need to be disconnected/removed.

As I understand it, neither of these 5v I2C devices can use 3.3v as a supply voltage and the 3.3v device can't run with a 5v supply (although the I/O pins are 5v tolerant). If I were to use them all on the same (Nano) I2C bus, I'm still unclear what the voltage on the SCL / SDA lines would be.
Do you mean the Nano's pullups on the SDA / SCL lines?

You have a group of three 5V I2C devices (the Nano and two sensors) and a group with one 3.3V device (the third sensor). The level shifter goes in between the two groups.

If you would have more 3.3V devices, they would go behind the same level shifter, connecting directly to the existing 3.3V sensor.

Mind, that while the 3.3V device's I/O pins are 5V tolerant, its I2C pins are NOT.

For a moment I understood, then realised...

Then how do Sparkfun suggest you can use the 3.3v board with a 5v device (the nano) without a level shifter?