- MPU9255
- MPU9250
- MPU6886
- MPU6515
- MPU6500
- MPU6050
- ICM20689
- ICM20690
- ICM20948
- BMI055
- BMX055 (Magnetometer currently untested)
- BMI160
- LSM6DS3 (And some of it's variants)
- LSM6DSL (currently untested)
- QMI8658
- QMC5883L
- HMC5883L
- AK8975
- AK8963
- AK09918
- BMM150
If you're planning on using an IMU on a non-default I2C port, you can specify the port in the constructor of your IMU, for example:
ICM20689 IMU1(Wire);
MPU6500 IMU2(Wire1); creates two IMU objects, ICM20689 will be using the I2C port assigned to Wire and MPU6500 will be on the I2C port assigned to Wire1.
You can also use Hybrid IMU's, which means you can add any supported magnetometer to any supported IMU by using the IMU_HYBRID class as follows:
IMU_HYBRID<IMU, MAG> IMU(Wire);For example
IMU_HYBRID<MPU6050, QMC5883L> IMU(Wire);creates a hybrid MPU6050 and QMC5883L IMU object that behaves as a single IMU, that returns accel and gyro values from the MPU6050 and magnetometer values from the QMC5883L respectively
- BNO080 (probably soonish)
- GY-85
- BNO055 (the one I bought is DOA... might take a bit)
- BMI270 (if I can get my hands on one)
-
AccelDataContains all three axis of Accelerometer data, these are namedaccelX,accelYandaccelZ. Also contains atimestampfield (uint32_t, microseconds frommicros()) updated only when the sensor has new data. -
GyroDataContains all three axis of Gyroscope data, these are namedgyroX,gyroYandgyroZ. Also contains atimestampfield updated independently ofAccelData. -
MagDataContains all three axis of Magnetometer data, these are namedmagX,magYandmagZ. Also contains atimestampfield updated only when the magnetometer has new data. -
QuaternionContains Quaternion data, the components are namedqW,qX,qYandqZ. Also contains atimestampfield. -
CalDataContains a boolean component namedvalidthat must be set totrueif the data is valid, it contains float array namedaccelBiasfor accelerometer biases, one namedgyroBiasfor gyroscope bias, one namedmagBiasfor magnetometer biases and one namedmagScalefor magnetometer scaling.
-
initTakes in acalDatafunction and an optionalbyteaddress, this function initializes the IMU, it defaults to the maximum ranges allowed by the IMU. This function will return a 0 if initialization was successful and a negative number if it failed to connect to the IMU. if no address is provided, the default for the selected IMU will be used. -
updateReads new IMU data if available. -
getAccelTakes in a pointer toAccelDataand copies new accelerometer data to it, should be called after update. -
getGyroTakes in a pointer toGyroDataand copies new gyroscope data to it, should be called after update. -
getMagTakes in a pointer toMagDataand copies new magnetometer data to it, should be called after update. Will only return new magnetometer data if the IMU has a magnetometer. -
getQuatTakes in a pointer to aQuaternionand copies new quaternion data to it, should be called after update. Will only return new Quaternion data if the IMU has a Quaternion output. -
getTempReturns temperature float data in °C, should be called after update, isn't very accurate. -
setGyroRangeTakes in an integer with the dps range wanted, (for example 2000 for ±2000dps), returns 0 if successful, returns -1 if the input range is not valid. -
setAccelRangeTakes in an integer with the dps range wanted, (for example 8 for ±8g), returns 0 if successful, returns -1 if the input range is not valid. -
setIMUGeometryTakes in an integer with the wanted geometry index, rotates IMU measurements to match vr headset IMU mount. (see chart below). -
setAccelODRTakes in an integer target output data rate in Hz and sets the accelerometer ODR to the nearest supported rate greater than or equal to the requested value. Returns the actual ODR that was set, or -1 if the sensor does not support configurable ODR. -
setGyroODRSame assetAccelODRbut for the gyroscope. On some sensors (e.g. MPU6050-family) accel and gyro share a rate divider so setting one affects both. -
setMagODRSame assetAccelODRbut for the magnetometer. Returns -1 if the IMU has no magnetometer or if it does not support a configurable continuous ODR (e.g. AK8975). -
getAccelODRReturns the current accelerometer ODR in Hz as last set bysetAccelODR, or -1 if not supported. -
getGyroODRReturns the current gyroscope ODR in Hz as last set bysetGyroODR, or -1 if not supported. -
getMagODRReturns the current magnetometer ODR in Hz as last set bysetMagODR, or -1 if not supported. -
setAccelLPFTakes in an integer target low-pass filter cutoff frequency in Hz and sets the accelerometer LPF to the nearest available value. Returns the actual cutoff frequency that was set, 0 if the filter was disabled, or -1 if the sensor does not support a configurable accelerometer LPF (e.g. MPU6050, BMI055/BMX055 accel). Passing 0 disables the filter or sets the widest available bandwidth on sensors where bypass is not possible. -
setGyroLPFSame assetAccelLPFbut for the gyroscope. On sensors where the available bandwidths are ODR-dependent (e.g. LSM6DS3/DSL, QMI8658, BMI160, BMI055/BMX055), the nearest available bandwidth at the current ODR is selected without changing the ODR. -
getAccelLPFReturns the accelerometer LPF cutoff frequency in Hz as last set bysetAccelLPF, 0 if disabled, or -1 if not supported. -
getGyroLPFReturns the gyroscope LPF cutoff frequency in Hz as last set bysetGyroLPF, 0 if disabled, or -1 if not supported. -
calibrateAccelGyroTakes in a pointer to calibration data and runs a Accelerometer and Gyroscope calibration, storing the new accelerometer and gyroscope calibration data in it. the IMU should be kept completely still and level during this. -
calibrateMagTakes in a pointer to Calibration data and runs a Accelerometer and Gyroscope calibration, storing the new accelerometer and gyroscope calibration data in it. the IMU should be moved in a figure eight pattern while calibrating, calibration takes around 15 seconds. -
hasMagnetometerReturns true if the IMU has a magnetometer. -
hasTemperatureReturns true if the IMU has a thermometer. -
hasQuatOutputReturns true if the IMU has a direct quaternion output. -
IMUNameReturns a string containing the IMU's name. -
IMUTypeReturns a string containing the IMU's type. -
IMUManufacturerReturns a string containing the IMU's manufacturer.

