Javadoc link

I2cMux is a service that can be used if you have several i2c devices that share the same address. The hardware needed is a TCA9548A and can be found as a breakout board here :I2cMux

The example script and the picture below use one I2cMux ( TCA9548A ) and two GY-521 ( MPU-6050 ) gyroscope / accelerometer boards.

The I2cMux has a default i2c address of 0x70 but that can be changed in the range 0x70-0x77. If you are using a Adafruit 16 Channel Servo driver, be aware that it doesn't only use the configured address (0x40 - 0x5F ) but also a broadcast address 0x70 that you can't change. So it you use I2cMux together with the Adafruit16CServoDriver you need to change the I2cMux address to something different than 0x70. That can easily be done by connecting one or more of the address pins A0-A2 to VCC.

The GY-521 has a default address of 0x68 that also can be changed, but in this example both use the default address. More info on the MPU6050 can be found here:MPU-6050

[[/service/I2cMux.py]]

Example code (from branch develop):
#file : I2cMux.py (github)
port="COM3"
#
if ('virtual' in globals() and virtual):
    virtualArduino = runtime.start("virtualArduino", "VirtualArduino")
    virtualArduino.connect(port)
ard = runtime.start("Arduino","Arduino")
ard.connect(port)
#
i2cmux = runtime.start("i2cMux","I2cMux")
# From version 1.0.2316 use attach instead of setController
# i2cmux.setController(ard,"1","0x70")
i2cmux.attach(ard,"1","0x70")
#
mpu6050_0 = runtime.start("Mpu6050-0","Mpu6050")
mpu6050_0.attach(i2cmux,"0","0x68")
 
mpu6050_1 = runtime.start("Mpu6050-1","Mpu6050")
mpu6050_1.attach(i2cmux,"1","0x68")
Example configuration (from branch develop):
#file : I2cMux.py (github)
!!org.myrobotlab.service.config.I2cMuxConfig
address: '0x70'
bus: '1'
controller: null
i2cDevices: {
  }
listeners: null
peers: null
type: I2cMux