Multiple Qwiic ICM20948 sensors with Qwiic Mux Breakout TCA9548A

Hello,

I am encountering a problem when trying to read data from multiple Qwiic ICM20948 sensors attached to different channels of a Qwiic Mux Breakout TCA9548A. The problem is that only one Qwiic ICM20948 sensor appears in the list_devices.

Running the following code:

test = qwiic.QwiicTCA9548A()
test.enable_all()
results = qwiic.list_devices()
print(results)

I get as output:

[(105, ‘Qwiic ICM20948’, ‘QwiicIcm20948’), (112, ‘Qwiic Mux’, ‘QwiicTCA9548A’)]

despite two sensors are connected (one to channel 0 and one to channel 1).

How can I access both sensors and simultaneously read from them?

Thank you for your help.

You can’t. You must select one channel and read that sensor then select a second channel and read that sensor.

If you connect both sensors at the same time their i2c address will conflict with one another since they have the same address.

Thank you very much. I wrote the folling code and it seems to work. However, the delays are approx. 0.02 seconds per cycle. Is there a more efficint way to read the sensors to reduce the delay? Thank you very much

test = qwiic.QwiicTCA9548A()
test.disable_all()

test.enable_channels([0])
IMU = qwiic.create_device('QwiicIcm20948')
if IMU.connected == False:
    print("The Qwiic ICM20948 device isn't connected to the system. Please check your connection", \
    file=sys.stderr)
else:
    IMU.begin()
test.disable_channels([0])

while True:
    test.enable_channels([0])
    if IMU.dataReady():
        IMU.getAgmt()
    test.disable_channels([0])

    test.enable_channels([1])     
    if IMU.dataReady():
        IMU.getAgmt() 
    test.disable_channels([1])