Hello there friend! SparkFun will be closed on 8/17/2018 @2pm for a company event. We will not be offering our normal Friday tour or Local Pickups during this time. We will resume normal operations on Monday 8/20/2018. Any orders placed after 2pm MT on 8/17/2018 will be processed when we resume normal operations. Have a great day!

All the Ports! And I2C Multiplexing

Want to talk to multiple I2C sensors but have only one address? No problem.

Favorited Favorite 1

We posted the Robotic Finger Sensor two weeks ago. The VCNL4040 only has one set I2C address. What if you want to have a robot with multiple fingers?

Qwiic Mux Shield for Arduino - PCA9548A

1 Retired

The Qwiic Multiplexer Shield solves it! Easily too. The PCA9548A has 8 to 1 I2C buses. It takes a second to wrap your head around what it’s doing but once you get it, it’s brilliantly simple.

The PCA9548A is an I2C device that connects to the Arduino. Its default address is 0x70. If you read from this device it will give you one byte: 0b.0000.0000. If you write a 1 into bit 3 (0b.0000.1000) then the mux will connect the Arduino SDA/SCL pins to Port 3.

enableMuxPort(3); //Connect to port 3

Whatever your Arduino code does after that function call the Arduino I2C lines will talk back/forth with whatever is connected on port 3. It’s that simple.

Talking to two devices with the same I2C address looks something like this:

int myX = getAccelX();
int myY = getAccelY();
int myZ = getAccelZ();

int myOtherX = getAccelX();
int myOtherY = getAccelY();
int myOtherZ = getAccelZ();

It’s a neat little part that opens the door to deploy vast arrays of the same sensor. Hope you enjoy!

Comments 0 comments