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