Problem reading two MinIMU-9 v5 with Arduino Due via I2C

Hello,

I want to read two MinIMU-9 v5 with the Arduino Due via I2C. I am able to read the sensors individually but not, if they are connected both. The sensors must have a different address to differentiate between them. So, I have connected the SA0 pin of one IMU to ground, which makes it the LOW IMU, the other is the HIGH IMU.

The following code is a slightly modified version of the example code “Serial”. It works perfectly for one IMU initialized with either LSM6::sa0_high or LSM6::sa0_low, if you connect the corresponding HIGH IMU or LOW IMU:

#include <Wire.h>
#include <LSM6.h>

LSM6 imu;

char report[80];

void setup()
{
  Serial.begin(115200);
  Wire.begin();

  if (!imu.init(LSM6::device_DS33, LSM6::sa0_high))
  {
    Serial.println("Failed to detect and initialize IMU!");
    while (1);
  }
  imu.enableDefault();
}

void loop()
{
  imu.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    G: %6d %6d %6d",
    imu.a.x, imu.a.y, imu.a.z,
    imu.g.x, imu.g.y, imu.g.z);
  Serial.println(report);

  delay(100);
}

However, I get no output, if I connect both IMUs and run the following code for two IMUs:

#include <Wire.h>
#include <LSM6.h>

LSM6 imu,imu2;

char report[80];

void setup()
{
  Serial.begin(115200);
  Wire.begin();

  if (!imu.init(LSM6::device_DS33, LSM6::sa0_low))
  {
    Serial.println("Failed to detect and initialize IMU!");
    while (1);
  }
  imu.enableDefault();

  if (!imu2.init(LSM6::device_DS33, LSM6::sa0_high))
  {
    Serial.println("Failed to detect and initialize IMU2!");
    while (1);
  }
  imu2.enableDefault();
}

void loop()
{
  imu.read();
  imu2.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    G: %6d %6d %6d",
    imu.a.x, imu.a.y, imu.a.z,
    imu2.g.x, imu2.g.y, imu2.g.z);
  Serial.println(report);

  delay(100);
}

If you can help me I would be very happy.

Thank you in advance,

rafaelri

Hello.

I am sorry you are having trouble getting data from both your MinIMU-9s. I was able to test your code with an A-Star 32U4 robot controller (which uses the same processor as an Arduino Leonardo, the ATmega32U4), and I was able to get data from the sensors. If you have access to another Arduino that is not a Due (like an Arduino UNO), can you try running your sketch on that board to see if it works?

Regardless, can you tell me how you are supplying power to both your MinIMU-9’s when they are connected? Can you post pictures that clearly show all of those devices connected together?

By the way, it looks like the report generated in your second sketch combines gyroscope and accelerometer data from both IMU’s, which I do not think you want.

-Jon

Hi Jon,

Thank you for responding. I will try to get my hands on an other board.

On the image below you will not see much, but on sketch the wiring should be clear.

The combined gyroscope and accelerometer report was out of laziness, just for testing.

Regards,
Rafael

I was able to find an Arduino Due today and test your code; I am able to get data from the sensors in that setup, too. Can you send more closeup pictures of your IMU boards? In particular, images that show the soldered joints and SA0 connection.

By the way, power supplied to VIN is regulated by an onboard 3.3V LDO regulator, and since you already have a regulated 3.3V supply, you can bypass the LDO by connecting to the VDD pin, instead. Also, I cannot tell how your MinIMU is mounted from your picture, but be sure to take precaution and ensure your setup does not allow different components or pins on the MinIMUs to short by touching metal or otherwise conductive surfaces.

-Jon

Thank you for your advice, Jon. My Arduino Due must have a bug. I have bought a Leonardo and now everything is working fine.

-Rafael