BNO086 with I2C Multiplexer

Hey there,
I am trying to connect 8 BNO086 to an I2C Multiplexer which is connected to the ESP32 C6.
When using the sparkfun BNO08x library to read the Acceleration Data it is not possible to initialize a second Sensor. When using one everything seems to work perfectly fine, but as soon as I add another one the Initialization of the second one fails and the Data output aswell. I have tested all sensors on their own to see if they are working, which is the case. When I try to initialize the Sensors without using the library it also works. But not using the library is not an option for me as I need the functions in it to read the Accel.data. And I am not that informed about the topic, so calling the registers on my own also hasnt worked out. Does anyone have an idea as to why the Initialization fails here? If you need any further explanations please reach out to me. Thank you

#include <Wire.h>
#include <SparkFun_BNO08x_Arduino_Library.h>

#define TCA9548A_ADDRESS 0x70 // Standard address of the TCA9548A
#define BNO086_ADDRESS 0x4B // Standard I2C address of the BNO086

BNO08x bno1; // Object for Sensor 1
BNO08x bno2; // Object for Sensor 2

void setup() {
Serial.begin(115200);
delay(1000);

// Initialize I2C bus (specific for ESP32-C6)
Wire.begin(21, 22); // SDA = GPIO21, SCL = GPIO22

Serial.println(“Starting TCA9548A Test…”);

// Test if the TCA9548A is detected
if (!testMultiplexer()) {
Serial.println(“TCA9548A NOT found!”);
while (true);
}

// Initialize the sensors
if (initializeSensor(bno1, 1)) {
Serial.println(“Sensor 1 successfully initialized.”);
} else {
Serial.println(“Sensor 1 NOT initialized.”);
}

if (initializeSensor(bno2, 2)) {
Serial.println(“Sensor 2 successfully initialized.”);
} else {
Serial.println(“Sensor 2 NOT initialized.”);
}
}

void loop() {
// Read data from Sensor 1
readSensorData(bno1, 1);

// Read data from Sensor 2
readSensorData(bno2, 2);

// End the loop after one iteration
while (true);
}

bool initializeSensor(BNO08x& sensor, uint8_t channel) {
if (!setTCAChannel(channel)) {
Serial.print(“Channel “);
Serial.print(channel);
Serial.println(” NOT activated.”);
return false;
}
delay(100); // Longer stabilization after channel switching

if (sensor.begin(BNO086_ADDRESS, Wire)) {
if (sensor.enableAccelerometer(10)) {
return true;
} else {
Serial.print("Error enabling accelerometer on channel ");
Serial.println(channel);
}
} else {
Serial.print(“Sensor on channel “);
Serial.println(channel);
Serial.println(” NOT found.”);
}
return false;
}

void readSensorData(BNO08x& sensor, uint8_t channel) {
if (!setTCAChannel(channel)) {
Serial.print(“Channel “);
Serial.print(channel);
Serial.println(” NOT activated.”);
return;
}
delay(50); // Stabilization after switching

if (sensor.getSensorEvent()) {
float accelX = sensor.getAccelX();
float accelY = sensor.getAccelY();
float accelZ = sensor.getAccelZ();

Serial.print("Sensor ");
Serial.print(channel);
Serial.print(" - Accel X: ");
Serial.print(accelX);
Serial.print(" | Accel Y: ");
Serial.print(accelY);
Serial.print(" | Accel Z: ");
Serial.println(accelZ);

} else {
Serial.print("No data from sensor ");
Serial.println(channel);
}
}

bool setTCAChannel(uint8_t channel) {
if (channel > 7) {
Serial.println(“Invalid channel (only 0-7 allowed)!”);
return false;
}
// Deactivate all channels
Wire.beginTransmission(TCA9548A_ADDRESS);
Wire.write(0x00); // Turn off all channels
Wire.endTransmission();

delay(10); // Small delay after deactivation

// Activate the desired channel
Wire.beginTransmission(TCA9548A_ADDRESS);
Wire.write(1 << channel);
return (Wire.endTransmission() == 0);
}

bool testMultiplexer() {
Wire.beginTransmission(TCA9548A_ADDRESS);
return (Wire.endTransmission() == 0);
}

Are you using this one? https://www.sparkfun.com/sparkfun-qwiic-mux-breakout-8-channel-tca9548a.html

My first guess is that you’ll need to disable all but one set of i2c pull-up resistors Hardware Overview - SparkFun VR IMU Breakout - BNO086 (Qwiic) Hookup Guide
…so if the mux has a set as well, I’d recommend leaving that one intact and disabling all of the IMU ones

Thank you for your reply. I am using this Multiplexer TCA9548A I2C-Multiplexer Breakout Board - kaufen bei BerryBase.
Yesterday I found this post (Library: Can't initialize two BNO086 on one I2C bus · Issue #3 · sparkfun/SparkFun_BNO08x_Arduino_Library · GitHub) saying, that the library doesnt support more than one sensor. Do you think it could still be a problem coming from the pull ups?

Ah - I was not aware of that…it does appear to be the problem :-/

If the product doesn’t suit your purposes: Was it purchased from us? If so head over to Returns (contact vendor if purchased elsewhere) and we’ll get ya squared away