Use the IMU through I2C, SPI and another I2C sensor on the Seeedstudio xiao nRF52840 sense

Hello everyone,

just new to the SeeedStudio and Xiao dev community.
I want to access the IMU data on a xiao sense BLE while connected to another sensor via the I2C. That doesn’t seem to work. Has anyone done this before so I short out that this is not a hardware limitation and focus on how to make the code work?

Thank you!

Hi There, Welcome.
You absolutly can do That!, The IMU is internal,(under the hood with fixed address)
ie.

//Create a instance of class LSM6DS3
LSM6DS3 myIMU(I2C_MODE, 0x6A);  //I2C device address 0x6A  // IMU

the I2C “BUS” pins are available and you can pick from many to be the CS ,or a different Address, what is the Sensors address?
Take a look at this and You’ll see the light Basics of the I2C Communication Protocol
and
Understanding the I2C Bus
should help also the WIKI for the Xiao Line of MCU’s is their…

INTERFACE RICH
1x Reset button, Ix UART, 1x I2C, 1x SPI, 1x NFC, 1x SWD, 11x GPIO,
 6x ADC, 1x Three-in-one LED, 1x User LED

for example…
HTH
GL :slight_smile: PJ

I don’t see any code so these are truths. :relieved:

Thank you so much PJ for your prompt reply and willingness to help! :slight_smile:

I connected my external I2C device on the dedicated default pins (SDA, 4 ; SCL 5) and then I have an Interrupt pin at (pin 1) and a SD (pin 2). The address of the I2C sensor is 0x2B.

Here is the code I am using for I2C scanning and displaying the IMU data for my test bed.
Although IMU is sending data it does not appear at the list of found I2C devices (possibly because it is on its own internal address as you mentioned) but my main issue is that I cannot see my I2C external sensor connected at 0x2B :frowning:

#include <Wire.h>
#include “LSM6DS3.h”

LSM6DS3 myIMU(I2C_MODE, 0x6A); //I2C device address 0x6A

void setup()
{
Wire.begin();

Serial.begin(9600);
while (!Serial); // Wait for serial monitor
Serial.println("---I2C Scanner---");
    //Call .begin() to configure the IMUs
if (myIMU.begin() != 0) { 
    Serial.println("Device error");
} else {
    Serial.println("Device OK!");
}

}

void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    Wire.beginTransmission(address+1);

if (error == 0 && Wire.endTransmission() != 0 ) // Special flag for SAMD Series
{
    Serial.print("I2C device found at address 0x");
    if (address<16)
        Serial.print("0");
    Serial.print(address,HEX);
    Serial.println("!");

    nDevices++;
}
else if (error==4) 
{
    Serial.print("Unknown error at address 0x");
    if (address<16) 
        Serial.print("0");
    Serial.println(address,HEX);
}
}
if (nDevices == 0)
    Serial.println("No I2C devices found\n");
else
    Serial.println("done\n");

    //Accelerometer
Serial.print("\nAccelerometer:\n");
Serial.print(" X1 = ");
Serial.println(myIMU.readFloatAccelX(), 4);
Serial.print(" Y1 = ");
Serial.println(myIMU.readFloatAccelY(), 4);
Serial.print(" Z1 = ");
Serial.println(myIMU.readFloatAccelZ(), 4);

//Gyroscope
Serial.print("\nGyroscope:\n");
Serial.print(" X1 = ");
Serial.println(myIMU.readFloatGyroX(), 4);
Serial.print(" Y1 = ");
Serial.println(myIMU.readFloatGyroY(), 4);
Serial.print(" Z1 = ");
Serial.println(myIMU.readFloatGyroZ(), 4);

//Thermometer
Serial.print("\nThermometer:\n");
Serial.print(" Degrees C1 = ");
Serial.println(myIMU.readTempC(), 4);
Serial.print(" Degrees F1 = ");
Serial.println(myIMU.readTempF(), 4);


delay(5000);           // wait 5 seconds for next scan

}

Alright :slight_smile: solved!

apparently the D2 pin that was connected to the SD of the sensor needed to be set LOW for the sensor device to power up its I2C. All working now.
Thanks again PJ for your message!
v

1 Like