I2CΒΆ

The I2C class allows you to communicate with any I2C sensors on the board. Reading and writing data is done with the readData and writeData methods. Unlike other sensors, the I2C module directly returns the data to the user in an AsyncOperation object rather than routing the data through a data route.

import com.mbientlab.metawear.module.I2C;

// On MetaWear R boards, this reads the WHO_AM_I register from the accelerometer
I2C i2cModule= mwBoard.getModule(I2C.class);
i2cModule.readData((byte) 0x1c, (byte) 0xd, (byte) 1).onComplete(new CompletionHandler<byte[]>() {
    @Override
    public void success(byte[] result) {
        Log.i("MainActivity", String.format("WHO_AM_I= %d", result[0]));
    }
});