Accessing Raw IMU Documentation

ThirdEye Gen, Inc.

How to access the raw IMU

Useful Resources:

Accessing IMU

The raw IMU uses I2C communication. The IMU is in normal power mode by default. In  order to customize the IMU settings, change the sensor configuration variables in  “initSensor()” function in “java_interface.c.” “initSensor()” is run only if the sensor has not  already been initiated. The BMI driver then sets all the settings defined in the function on  the IMU.

Java_interface uses the BMI160 driver code to get the data from the IMU. The BMI160 driver  code uses “bmi160_user_functions.c” to interact with the I2C bus. The app must have  read/write access to /dev/i2c-n.

The C library is called “native-lib” and needs to be loaded into the java portion of the app.  See ​here ​on how to do this.

To retrieve the gyroscope and accelerometer data, call the C function called  “sensorDataFromJNI()” in java. This function returns an array of integers. The values of the  array are as follows:

0 – Accel X

1 – Accel Y

2 – Accel Z

3 – Gyr X

4 – Gyr Y

5 – Gyr Z


  • If the IMU data does not change between calls, it is possible that the app does not  have access to the /dev/i2c-n file
  • SLAM uses this IMU and so if SLAM is running, trying to access this IMU will corrupt  the data. DO NOT access this IMU if SLAM is running.