I am interfacing to the Invensense ICM-20948 9-DOF IMU chip using an ESP8266, and a 1.8V level shifter & regulator, which works fine.

I am trying to get quaternions from the internal DMP using full 9-axis sensor fusion, as according to the datasheet the ICM has an AK09916 magnetometer on board, which should allow for drift-free rotations.

The "library" for that chip I am using is an ESP8266-adjusted version of this one from GitHub, however the relevant code in there is actually from Invensense's official code.

The problem that I am facing is, that I cannot get the ICM to work with its own internal magnetometer.

I tried every magnetometer option that the library has to offer, as well as all official I²C addresses of the magnetometer, but every time the Invensense library returns an error when trying to init the compass and the mag data is always 32767 on all axis, so no valid data. Reading the gyro and accelerometer, as well as quaternions using the DMP and 6-axis fusion works.

Has anyone worked with the ICM before, and knows why this happens, and what I could try to troubleshoot this further?

I have also ran an I²C scanner, and I found two devices, one on 0x68 (the IMU chip) and one on 0xE8 (Don't know what that is). I tried 0xE8 as the magnetometer address for the ICM, but still get that same error.

Any help is much appreciated.

Update 1: I've changed from 0x68 to 0x69 by pulling AD0 HIGH, and now it detects the mag but it's stuck at "[4915.049805,-4915.049805,-4915.049805]"

  • 2
    \$\begingroup\$ 0x68 is the 7-bit address for the IMU, the 8-bit write adderss is 0xD0 and 8-bit read address is 0xD1. Since 7-bit addresses are used, 0xE8 is the same 0x68 address and the highest bit is ignored, so it wraps around to IMU address. \$\endgroup\$
    – Justme
    Commented Sep 27, 2020 at 13:10
  • \$\begingroup\$ @Justme ok thx that explains the 0xE8, but why don't any of the magnetometer addresses work? \$\endgroup\$
    – Twometer
    Commented Sep 27, 2020 at 14:34
  • 2
    \$\begingroup\$ The AK09916 magnetometer is not on the same I2C bus, at least not by default. The ICM-20948 has itself an MCU of some sorts, and it has a internal I2C master, connected to AK09916 silicon die. So the accesses to AK09916 happen by controlling the I2C master of ICM-20948 over I2C bus, and it is meant to be handled by the internal processing unit. For initialization purposes, there is a bypass switch that can connect the auxiliary bus where AK09916 is to the main I2C bus, but doing that means the internal I2C master must be disabled and the internal bypass switch must be turned on via I2C writes. \$\endgroup\$
    – Justme
    Commented Sep 27, 2020 at 18:46
  • \$\begingroup\$ @Twometer, has the issue got resolved? We are facing same issue using ICM-20948. \$\endgroup\$
    – Dong Zhou
    Commented Jan 21, 2021 at 9:14
  • \$\begingroup\$ @DongZhou Yes, I have resolved the issue, my ICMs now work (well, one of them because one arrived damaged..). iirc, it was a library issue with initializing the compass. I have wrapped the original lib here github.com/Twometer/ICM-20948-Arduino - with that it works. I think I also have some schematics somewhere how I wired it up, if you're interested. \$\endgroup\$
    – Twometer
    Commented Jan 21, 2021 at 14:04


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.