Skip to content

Connecting multiple SPI sensors to Arduino Nano #26

@d-blaise

Description

@d-blaise

Subject of the issue

I cannot receive SPI data from multiple ICM-20948 sensors. I have four ICM-20948 sensors soldered to a custom PCB which connects to an Arduino Nano. The PCB layout is nearly identical to the Adafruit TDK InvenSense ICM-20948 9-DoF IMU board. Each sensor has its own CS line.

Your workbench

  • Windows 10
  • Arduino IDE 1.8.13
  • Arduino Nano
  • Custom PCB board, very similar to Adafruit TDK InvenSense ICM-20948 9-DoF IMU
  • Power from USB, dropped to 1.8 V on custom board using LDO regulator and logic level converter
  • Each ICM-20948 has its own CS line

Steps to reproduce

I am using the Example1_Basics.ino code, but I include three additional ICM_20948 objects and CS lines:

`#include "ICM_20948.h" // Click here to get the library: http://librarymanager/All#SparkFun_ICM_20948_IMU

#define USE_SPI
#define SERIAL_PORT Serial
#define SPI_PORT SPI // Your desired SPI port. Used only when "USE_SPI" is defined

#define CS_PIN 10 // Which pin you connect CS to. Used only when "USE_SPI" is defined
#define CS_PIN_orange 9
#define CS_PIN_white 8
#define CS_PIN_gray 7

#define WIRE_PORT Wire // Your desired Wire port. Used when "USE_SPI" is not defined
#define AD0_VAL 1 // The value of the last bit of the I2C address.
// On the SparkFun 9DoF IMU breakout the default is 1, and when
// the ADR jumper is closed the value becomes 0

#ifdef USE_SPI
ICM_20948_SPI myICM; // If using SPI create an ICM_20948_SPI object
ICM_20948_SPI orange;
ICM_20948_SPI white;
ICM_20948_SPI gray;
#else
ICM_20948_I2C myICM; // Otherwise create an ICM_20948_I2C object
#endif

void setup() {

SERIAL_PORT.begin(115200);
while(!SERIAL_PORT){};

pinMode (CS_PIN, OUTPUT);
pinMode (CS_PIN_orange, OUTPUT);
pinMode (CS_PIN_white, OUTPUT);
pinMode (CS_PIN_gray, OUTPUT);

#ifdef USE_SPI
SPI_PORT.begin();
#else
WIRE_PORT.begin();
WIRE_PORT.setClock(400000);
#endif

bool initialized = false;
while( !initialized ){

#ifdef USE_SPI
myICM.begin( CS_PIN, SPI_PORT );
orange.begin( CS_PIN_orange, SPI_PORT );
white.begin( CS_PIN_white, SPI_PORT );
gray.begin( CS_PIN_gray, SPI_PORT );

#else
myICM.begin( WIRE_PORT, AD0_VAL );
#endif

  initialized = true;

}
}

void loop() {

Serial.println("1st Sensor:");
myICM.getAGMT();                // The values are only updated when you call 'getAGMT'
printRawAGMT( myICM.agmt );     // Uncomment this to see the raw values, taken directly from the agmt structure

Serial.println("2nd Sensor:");
orange.getAGMT();                // The values are only updated when you call 'getAGMT'
printRawAGMT( orange.agmt );     // Uncomment this to see the raw values, taken directly from the agmt structure

Serial.println("3rd Sensor:");
white.getAGMT();                // The values are only updated when you call 'getAGMT'
printRawAGMT( white.agmt );     // Uncomment this to see the raw values, taken directly from the agmt structure

Serial.println("4th Sensor:");
gray.getAGMT();                // The values are only updated when you call 'getAGMT'
printRawAGMT( gray.agmt );     // Uncomment this to see the raw values, taken directly from the agmt structure

delay(30);

}`

Expected behaviour

I should expect to receive nonzero values from my serial monitor from each ICM-20948 sensor.

Actual behaviour

Only the first ICM-20948 sensor produces a nonzero reading. My serial monitor data look like this:

1st Sensor:
RAW. Acc [ 02264, -07008, 15064 ], Gyr [ 00167, 00075, 00021 ], Mag [ 00072, -00211, 00299 ], Tmp [ 03232 ]
2nd Sensor:
RAW. Acc [ -00000, -00000, -00000 ], Gyr [ -00000, -00000, -00000 ], Mag [ -00000, -00000, -00000 ], Tmp [ -00000 ]
3rd Sensor:
RAW. Acc [ -00000, -00000, -00000 ], Gyr [ -00000, -00000, -00000 ], Mag [ -00000, -00000, -00000 ], Tmp [ -00000 ]
4th Sensor:
RAW. Acc [ -00000, -00000, -00000 ], Gyr [ -00000, -00000, -00000 ], Mag [ -00000, -00000, -00000 ], Tmp [ -00000 ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions