5 Replies Latest reply on Jan 17, 2015 1:19 AM by freshbird

    fail to connect multiple I2C sensors


      I want to connect two sensors (MPU-6050, CJMCJ-43) on EDISON FOR ARDUINO* BOARD.

      When I enable one of them, it works well. But when I connect both into SCL/SDA, only one (CJMCJ-43) is accesible.

      I use the mraa library which connect the sensors via I2C-smbus protocol.


      int tempAddr = 0x68;
      int opticalAddr = 0x23;

      void test_mraa()
            mraa_i2c_context i2c;
            i2c = mraa_i2c_init(6);
            int tempAddr = 0x68;
            char txbuf[1];
            char rxbuf[1];
            // init temp sensor
            txbuf[0] = 0x75; 
            mraa_i2c_address(i2c, tempAddr);
            mraa_i2c_write(i2c, txbuf, 1);//On error "Failed to write to i2c" returned
            mraa_i2c_address(i2c, tempAddr);
            mraa_i2c_read(i2c, rxbuf, 1);
            if (rxbuf[0] != 0x68)
                printf("No MPU-6050");

         mraa_i2c_address(i2c, opticalAddr);
            txbuf[0] = 0x01;     // power on
            mraa_i2c_write(i2c, txbuf, 1);