SPARKFUN ICM_20948 SPI CONNECTION TO UNO R4 Minima RETURNING WRONG ID

Hi

I have seen similar threads but my scenario is a little different.

I am using the ICM 20948 mounted to a generic prototyping shield and the SPI connections wires soldered to the correct pins. CS is pin 2. The shield is installed on a UNO R4 Minima and has been working fine.

I just removed the SparkFun SD module that was on I2C, and replaced it with an Adafruit 254 SD module on SPI. I have used this module before and have it wired with CS on pin 10.

Now when I run my sketch the initialization of the ICM 20948 says “Wrong ID”.

I can only guess there is some collision in the libraries or how SPI is getting shared. Unfortunately I don’t know enough about that to figure out what the problem could be.

Thanks in advance for any help with this.

Johnny

I have absolutely no idea how I would verify the libraries are compatible. I don’t even know where I would start.

Has anyone got this ICM to work with a SPI connected SD card module?

I see this:

#include “ICM_20948.h” // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU
#define USE_SPI // Uncomment this to use SPI
#define SPI_PORT SPI // Your desired SPI port. Used only when “USE_SPI” is defined
#define CS_PIN 2 // Which pin you connect CS to. Used only when “USE_SPI” is defined

and this:

#include <SPI.h> //Needed for the Adafruit SPI SD module
#include <SD.h> //https://www.arduino.cc/reference/en/libraries/sd/

and this:

SPI_PORT.begin();
//myICM.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
bool initialized = false;
while (!initialized)
{
myICM.begin(CS_PIN, SPI_PORT);
Serial.print(F("Initialization of the sensor returned: "));
Serial.println(myICM.statusString());
delay(3000);
if (myICM.status != ICM_20948_Stat_Ok)
{
Serial.println(“Trying again…”);
delay(500);
}
else
{
initialized = true;
}
}

And I get “Wrong ID”.

To me it looks like ICM_20948.h includes a SPI library because it works without loading a separate one. That might be where the conflict lies.

Any ideas appreciated.

Johnny