Using two sensors in I2C with TCA9548A

HELLO !

I’m using myAHRS+ and BMP180 in I2C but have some crash in addresses.

so I bought a I2C multiplexer, TCA9548A but couldn’t understand how it works.

I want to get Eulerian angle and temperature with myAHRS+ and altitude with BMP180

but the OUTPUT data have not updated and print wrong data.

add some code about it. please take a look at the code ! :sweat_smile:

myAHRS__i2c.ino (2.03 KB)

The BMP180 uses 0x77 as I2C address and if the myAHRS+ uses 0x70, then there is no conflict.
What makes you think the address make it crash ?

Can you tell which modules you use ? please give a link to them.
Which Arduino board do you use ?
Do you use a 5V or 3.3V I2C bus ?
Did you run the i2c_scanner ? http://playground.arduino.cc/Main/I2cScanner

Your code is not okay. Did you copy it from somewhere ?
Replace this:

  Wire.beginTransmission(TCAADDR);
  Wire.requestFrom(TCAADDR, 1);

  while(!Wire.available()) {};

  #if ARDUINO >= 100
    value = Wire.read();
  #else                     
    value = Wire.receive(); 
  #endif; 

  Wire.endTransmission(); 

  return value;

With this:

  Wire.requestFrom(TCAADDR, 1);

  value = Wire.read();

  return value;

Perhaps you might have to change the name of a few functions. The readRegister8() is often used in Adafruit library, it might even be in the BMP180 library as well.