SparkFun Qwiic 6DoF - ISM330DHCX - High Sampling Rate?

Hello guys!

I have a Sparkfun thing plus c connected using the qwiic system to a SparkFun Qwiic 6DoF - ISM330DHCX.

I am using the following code, which suppose to output 416hz but I get the same 135hz s without using the commands:

#define ISM_XL_ODR_416Hz 6

#define ISM_GY_ODR_416Hz 6

Any suggestions? Here is the code:

/******************************************************************************
Basic_Readings.ino

https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO
https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO_Arduino_Library

Description:
Most basic example of use.

Example using the LSM6DSO with basic settings.  This sketch collects Gyro and
Accelerometer data every second, then presents it on the serial monitor.

Development environment tested:
Arduino IDE 1.8.2

This code is released under the [MIT License](http://opensource.org/licenses/MIT).
Please review the LICENSE.md file included with this example. If you have any questions 
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/

#include "SparkFunLSM6DSO.h"
#include "Wire.h"

#define ISM_XL_ODR_416Hz   6
#define ISM_GY_ODR_416Hz   6


LSM6DSO myIMU; //Default constructor is I2C, addr 0x6B

void setup() {


  Serial.begin(115200);
  delay(500); 
  
  Wire.begin();
  delay(10);
  if( myIMU.begin() )
    Serial.println("Ready.");
  else { 
    Serial.println("Could not connect to IMU.");
    Serial.println("Freezing");
  }

  if( myIMU.initialize(BASIC_SETTINGS) )
    Serial.println("Loaded Settings.");

}


void loop()
{
  //Get all parameters
  
//  Serial.print("\nAccelerometer:\n");
//  Serial.print(" X = ");
  Serial.println(myIMU.readFloatAccelX(), 3);
   Serial.print("\t");
//  Serial.print(" Y = ");
  Serial.print(myIMU.readFloatAccelY(), 3);
     Serial.print("\t");
//  Serial.print(" Z = ");
  Serial.print(myIMU.readFloatAccelZ(), 3);
     Serial.print("\t");

//  Serial.print("\nGyroscope:\n");
//  Serial.print(" X = ");
  Serial.print(myIMU.readFloatGyroX(), 3);
     Serial.print("\t");
//  Serial.print(" Y = ");
  Serial.print(myIMU.readFloatGyroY(), 3);
     Serial.print("\t");
//  Serial.print(" Z = ");
  Serial.print(myIMU.readFloatGyroZ(), 3);
     Serial.print("\t");


//  Serial.print("\nThermometer:\n");
//  Serial.print(" Degrees F = ");
//  Serial.println(myIMU.readTempF(), 3);
//  
  //delay(10);
}

Thanks! Have a great day!

Sorry, here is the updated code which still gives me 135hz instead of 416hz:

#include "SparkFunLSM6DSO.h"
#include "Wire.h"

#define ISM_GY_ODR_416Hz   6
#define ISM_XL_ODR_416Hz   6


LSM6DSO myIMU; //Default constructor is I2C, addr 0x6B

void setup() {


  Serial.begin(115200);
  delay(500); 
  
  Wire.begin();
  delay(10);
  if( myIMU.begin() )
    Serial.println("Ready.");
  else { 
    Serial.println("Could not connect to IMU.");
    Serial.println("Freezing");
  }

  if( myIMU.initialize(BASIC_SETTINGS) )
    Serial.println("Loaded Settings.");

  myIMU.setGyroDataRate(ISM_GY_ODR_416Hz);
  myIMU.setAccelDataRate(ISM_XL_ODR_416Hz);

}


void loop()
{
  //Get all parameters
  
//  Serial.print("\nAccelerometer:\n");
//  Serial.print(" X = ");
  Serial.println(myIMU.readFloatAccelX(), 3);
   Serial.print("\t");
//  Serial.print(" Y = ");
  Serial.print(myIMU.readFloatAccelY(), 3);
     Serial.print("\t");
//  Serial.print(" Z = ");
  Serial.print(myIMU.readFloatAccelZ(), 3);
     Serial.print("\t");

//  Serial.print("\nGyroscope:\n");
//  Serial.print(" X = ");
  Serial.print(myIMU.readFloatGyroX(), 3);
     Serial.print("\t");
//  Serial.print(" Y = ");
  Serial.print(myIMU.readFloatGyroY(), 3);
     Serial.print("\t");
//  Serial.print(" Z = ");
  Serial.print(myIMU.readFloatGyroZ(), 3);
     Serial.print("\t");


//  Serial.print("\nThermometer:\n");
//  Serial.print(" Degrees F = ");
//  Serial.println(myIMU.readTempF(), 3);
//  
  //delay(10);
}

That’s a ton of serial data you’re printing, I’m thinking that is your bottleneck.

Try just printing the accelerometer X value and nothing else and see if you get a speed increase.

You are absolutely correct. Thank you!

Though now I get a much higher sample rate then I asked for around 864 Hz.

Am I using the commands for setting the sample rate correctly and at the right location in the code?

I just realized i have the LSM6DOF and not the 330 as in the title :expressionless:

https://www.sparkfun.com/products/18020

I tried looking at the github repo with no luck figuring out what numbers to send in the setGyroDataRate/setAccelDataRate :

https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO

#include "SparkFunLSM6DSO.h"
#include "Wire.h"

#define ISM_GY_ODR_416Hz   416
#define ISM_XL_ODR_416Hz   416


LSM6DSO myIMU; //Default constructor is I2C, addr 0x6B

void setup() {


  Serial.begin(115200);
  delay(500); 
  
  Wire.begin();
  delay(10);
  if( myIMU.begin() )
    Serial.println("Ready.");
  else { 
    Serial.println("Could not connect to IMU.");
    Serial.println("Freezing");
  }

  if( myIMU.initialize(BASIC_SETTINGS) )
    Serial.println("Loaded Settings.");

// Set Sample Rates //
myIMU.setGyroDataRate(ISM_GY_ODR_416Hz);
myIMU.setAccelDataRate(ISM_XL_ODR_416Hz);

}


void loop()
{
  //Get all parameters
  
//  Serial.print("\nAccelerometer:\n");
//  Serial.print(" X = ");
  Serial.println(myIMU.readFloatAccelX(), 3);
//   Serial.print("\t");
////  Serial.print(" Y = ");
//  Serial.print(myIMU.readFloatAccelY(), 3);
//     Serial.print("\t");
////  Serial.print(" Z = ");
//  Serial.print(myIMU.readFloatAccelZ(), 3);
//     Serial.print("\t");
//
////  Serial.print("\nGyroscope:\n");
////  Serial.print(" X = ");
//  Serial.print(myIMU.readFloatGyroX(), 3);
//     Serial.print("\t");
////  Serial.print(" Y = ");
//  Serial.print(myIMU.readFloatGyroY(), 3);
//     Serial.print("\t");
////  Serial.print(" Z = ");
//  Serial.print(myIMU.readFloatGyroZ(), 3);
//     Serial.print("\t");

}