Connecting two LSM6DS33 to the same Arduino NANO

Hi! :slight_smile:
I’m using the Arduino NANO, and the LSM6DS33 IMU with the LSM6 example code.
My connection set-up is:
VIN - 3.3V
GND - GND
SDA - A4
SCL - A5

I want to connect another LSM6DS33 IMU to it.
Do any of you know what is the pinout for the second connection, and are there any changes to the code needed to be made, for it to run two IMU simultaneously?
BTW, this is my code for now:


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

LSM6 imu;

char report[80];

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

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

void loop()
{
  imu.read();

  snprintf(report, sizeof(report), "%6d %6d %6d %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);
}

Thanks in advance!

Hi.

To connect a second LSM6DS33 carrier you should connect it to the same 4 pins as your first carrier plus connect its SA0 pin to ground to change its slave address. More details about changing the address are available in the “I²C communication” section of the carrier’s product page.

Then, you will also need to create two instances of the LSM6 class and initialize both sensors in your code with both arguments of the init function specified. For example:

imu1.init(LSM6::device_DS33, LSM6::sa0_high);
imu2.init(LSM6::device_DS33, LSM6::sa0_low);

After that, you can access each sensor through the corresponding object.

-Claire

OMG, Claire - You’re the queen!
It worked!
For future users - I did as Claire said:
Connected one of the SD0 to ground, and by that set its address to 0x6A [The other sensor is at 0x6B].
The difference from Claires’ advice, was that I used the init function with different variables:

imu_A.init(LSM6::device_auto,  LSM6::sa0_low)
imu_B.init(LSM6::device_auto, LSM6::sa0_high)

As in, device_auto and not device_DS33.
Anyhow, now it works (:
Thanks again Claire

1 Like