I am trying to interface with the ICM-20789 over I2C. DataSheet
I have been successfully able to get all three gyroscope readings and all three accelerometer readings. I am now trying to get the pressure readings from the device, since it has a built-in pressure sensor, but cannot seem to get it working.
In the datasheet, it says to enable Bypass Mode.
Bypass Mode: Set register INT_PIN_CFG (Address: 55 (Decimal); 37 (Hex)) bit 1 to value 1 and I2C_MST_EN bit is ‘0’ (Address: 106 (Decimal); 6A (Hex). Pressure sensor data can then be accessed using the procedure described in Section 10
In the setup I use this code:
Wire.beginTransmission(gyro_address);
Wire.write(0x37); //INT_PIN_CFG
Wire.write(0x02); //00000010
Wire.endTransmission();
I am having trouble finding I2C_MST_EN in the datasheet as well, as I cannot find it in the 6A Address.
Once I have the bypass bit enabled, I try to request the pressure and temperature data from the sensor using this code:
Wire.beginTransmission(0x63);
Wire.write(0x7866);
Wire.endTransmission();
Wire.requestFrom(0x63, 16);
while (Wire.available() < 16);
pressure = Wire.read() << 16 | Wire.read() << 8 | Wire.read();
temp_2 = Wire.read() << 16 | Wire.read() << 8 | Wire.read();
Unfortunately, the device freezes when I try to run this code. I know I am obviously doing something wrong here, just don't know exactly what yet.
Wire.write(0x7866);
will truncate your value to just 0x66. You can onlywrite
8 bits at a time.