Thanks for the answers, but I have now tried to change to native port and changing baudrate, and the desired sample rate is not obtained.
I have simplified the code and tried with this form the programmable port:
#include <Adafruit_LSM6DSOX.h>
Adafruit_LSM6DSOX sox;
void setup(void) {
Serial.begin(115200);
while (!Serial)
//delay(1); // will pause Zero, Leonardo, etc until Serial console opens
Serial.println("Adafruit LSM6DSOX test!");
if (!sox.begin_I2C()) {
}
sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
}
void loop() {
// /* Get a new normalized sensor event */
sensors_event_t accel;
sensors_event_t gyro;
sensors_event_t temp;
sox.getEvent(&accel, &gyro, &temp);
Serial.print(accel.acceleration.x);
Serial.print(","); Serial.print(accel.acceleration.y);
Serial.print(","); Serial.print(accel.acceleration.z);
// Serial.print(",");
Serial.println();
// delayMicroseconds(666);
}
From this, I got a sampling rate of approximately 380hz when I take the numbers copying them into excel and look at how many samples per second.
Then I have tried this code with the Native port:
#include <Adafruit_LSM6DSOX.h>
Adafruit_LSM6DSOX sox;
void setup(void) {
SerialUSB.begin(115200);
while (!SerialUSB)
//delay(1); // will pause Zero, Leonardo, etc until SerialUSB console opens
SerialUSB.println("Adafruit LSM6DSOX test!");
if (!sox.begin_I2C()) {
}
sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
}
void loop() {
// /* Get a new normalized sensor event */
sensors_event_t accel;
sensors_event_t gyro;
sensors_event_t temp;
sox.getEvent(&accel, &gyro, &temp);
SerialUSB.print(accel.acceleration.x);
SerialUSB.print(","); SerialUSB.print(accel.acceleration.y);
SerialUSB.print(","); SerialUSB.print(accel.acceleration.z);
// SerialUSB.print(",");
SerialUSB.println();
// delayMicroseconds(666);
}
From this, I get a sampling rate of approximately 290hz.
When I'm trying with higher Baudrate for the programming port, it will only give useless data or no data. Does someone have a guess of what ells I can try?
P.S.
UKHeliBob I'm sorry about my duplicate, it was not intentionally. I thought I could delete the other post.. But it will not happen again!