– Using the TCA9548A I2C Multiplexer –
To connect multiple I2C module with the same address
All my content is free.
If you feel that my videos are helping and you would like to contribute, you can toss some coins in the Tip Jar via PayPal.
Select amount then click the “Donate” button.
In the last tutorial we looked at how the I2C protocol works and saw that one thing it needs is that each of the connected i2c module have a unique address.
This is important for the Arduino to select which of the connected i2c devices it want to talk to.
Now most of the time this isn’t a problem since most module have some way to select the i2c address by way of dip switches, like the I2C Expander module we looked at, or by soldering some pads on the PCB.
But some module have a Fixed i2c address and don’t have any way to change it.
This is when the I2C Multiplexer comes into play!
In this tutorial we will use two Oled Displays which have a Fixed i2c address of 0x3C.
Quick overview of the TCA9548A I2C Multiplexer
The i2c multiplexer enables you to use up to eight i2c module with the same address.
It connect to the Arduino using the SDA and SCL pins and itself has the i2c address of 0x70, which can be changed by soldering some pads on the PCB (A0-A1-A3), or by sending HIGH or LOW signal to the corresponding pins. Check out the tutorial video for more information on that function.
You then connect the i2c modules you want to use to the I2C Multiplexer using any of the eight available I2C channels:
SD0-SC0 – i2c Channel #0
SD1-SC1 – i2c Channel #1
SD7-SC7 – i2c Channel #7
When you want the Arduino to talk to a specific module you switch to the channel the module is connected to.
One thing to take note of is that even though the I2C Multiplexer uses the i2c address of 0x70, went you switch to a channel to communicate with a module, you will still need to know that module’s i2c address in the Arduino Code.
If you’re using multiple i2c modules that are all set at the same i2c address, then you use that address when communicating with any of those modules after changing the channel.
Technically you can use i2c modules that don’t share the same address if you wanted to as well, although you can do that without using this I2C Multiplexer, but if you wanted to connect all the module (those sharing i2c address + some more that don’t) you could do that to simplify the wiring I guess.
As you can see we are only using 2 Pins on the Arduino to connect the I2C Multiplexer and both OLED displays.
I2C Multiplexer module connections:
5V and Ground from the Arduino and A4 – A5 to SDA and SCL on the module
5v and Ground from the Arduino and SD2-SC2 to SDA and SCL of OLED #1
5v and Ground from the Arduino and SD7-SC7 to SDA and SCL of OLED #2
Ground from the Arduino on one leg of the switches
Pin 10 of the Arduino to switch #1 other leg
Pin 11 of the Arduino to switch #2 other leg
In this tutorial we are using two OLED display which have a fixed I2C address of 0x3c and using the I2C Multiplexer which has a default address of 0x70.
We are using a library to communicate and switch channels on the I2C Multiplexer.
Also using the U8Glib library for the OLED displays.
By default the U8Glib library is configured to use the I2C address 0x3c for the displays, but if the display you’re using have a different address, you will need to edit this file: arduino library folder/u8glib/csrc/u8g_com_i2c.c to change it. Make sure to check out the tutorial video for more information on this.
As always to get more information on the code check out the tutorial video as well.
So if you have some I2C modules that have fixed address and you want to use more than one of them, this I2C Multiplexer board will enable you to do that pretty easily!
Like I mentionned in the tutorial video, you still need to know the address of the modules even if they are connected to the I2C Multiplexer, since changing the channel only connects the SDA and SCL lines and does not transfer the I2C address.
Thank you for stopping by!