XIAO ble nrf52840 increase sampling frequency

Hi everyone, I have a seeeduino XIAO ble nrf52840 with integrated LSM6DS3 sensor, I’m trying to use the sensor with a circular buffer to store the data made up of 5000 samples and I want to use at least 1000 Hz of sampling frequency. I tried everything, but it seems that the sampling frequency of the sensor is still always 100 Hz. I can tell because I’ve added a debug print of the increasing size of the buffer while filling, and it increases at 100 samples per second. Can someone help me ?

Hi there, g,
Let see some code, What do you initialize it with?

 // Double Tap Config
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, 0x60); //* Acc = 416Hz (High-Performance mode)// Turn on the accelerometer
  // ODR_XL = 416 Hz, FS_XL = 2g
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_TAP_CFG1, 0x8E);// INTERRUPTS_ENABLE, SLOPE_FDS// Enable interrupts and tap detection on X, Y, Z-axis
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_TAP_THS_6D, 0x85);// Set tap threshold 8C
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_INT_DUR2, 0x7F);// Set Duration, Quiet and Shock time windows 7F
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_WAKE_UP_THS, 0x80);// Single & double-tap enabled (SINGLE_DOUBLE_TAP = 1)
  myIMU.writeRegister(LSM6DS3_ACC_GYRO_MD1_CFG, 0x08);// Double-tap interrupt driven to INT1 pin

Are you using the fifo or a dma buffer ?
HTH
GL :slight_smile: PJ

Hi, this is my buffer, i’m trying to save the IMU variables in 6 different buffers of 5000 samples, and send them through BLE. Code :
const int BUFFER_SIZE = 5000;

CircularBuffer<int16_t> axBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> ayBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> azBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wxBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wyBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wzBuffer(BUFFER_SIZE);

i have then a function to update the buffer data every ms with a function like this in the loop
if (millis() - last_buffer_sample >= 1) {
last_buffer_sample = millis();
acquireBufferData();
}

void acquireBufferData() {
int16_t axValue = myIMU.readFloatAccelX();
int16_t ayValue = myIMU.readFloatAccelY();
int16_t azValue = myIMU.readFloatAccelZ();
int16_t wxValue = myIMU.readFloatGyroX();
int16_t wyValue = myIMU.readFloatGyroY();
int16_t wzValue = myIMU.readFloatGyroZ();

axBuffer.write(axValue);
ayBuffer.write(ayValue);
azBuffer.write(azValue);
wxBuffer.write(wxValue);
wyBuffer.write(wyValue);
wzBuffer.write(wzValue);
}
But i’m struggling to change the sampling frequency even rewriting the register, i have added also a count variable to count the current size of the buffer, but it updates at 100 Hz.

Hi ther,
Well I see the reads ok, but what mode are you putting the IMU in ?

 //Setup the accelerometer******************************
    dataToWrite = 0; //Start Fresh!
    dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_100Hz;
    dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_8g;
    //dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_104Hz;
    dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_13Hz; // changed from 104 to 13 as show in the 

just defaults or are you setting any parms?
GL :slight_smile: PJ

Yes i’m using the default : LSM6DS3 myIMU(I2C_MODE, 0x6A); // I2C device address 0x6A

Hi there,
So you probably want to oversample or set it to a multiple of your buffer, are you using the on chip fifo? things like the performance mode can be turn up , defaults are 104Hz and 100hz accelerometer and gyroscope. for example the fifo can also be adjusted if you use it.

/*******************************************************************************
* Register      : FIFO_CTRL5
* Address       : 0X0A
* Bit Group Name: ODR_FIFO
* Permission    : RW
*******************************************************************************/
typedef enum {
    LSM6DS3_ACC_GYRO_ODR_FIFO_10Hz       = 0x08,
    LSM6DS3_ACC_GYRO_ODR_FIFO_25Hz       = 0x10,
    LSM6DS3_ACC_GYRO_ODR_FIFO_50Hz       = 0x18,
    LSM6DS3_ACC_GYRO_ODR_FIFO_100Hz          = 0x20,
    LSM6DS3_ACC_GYRO_ODR_FIFO_200Hz          = 0x28,
    LSM6DS3_ACC_GYRO_ODR_FIFO_400Hz          = 0x30,
    LSM6DS3_ACC_GYRO_ODR_FIFO_800Hz          = 0x38,
    LSM6DS3_ACC_GYRO_ODR_FIFO_1600Hz         = 0x40,
    LSM6DS3_ACC_GYRO_ODR_FIFO_3300Hz         = 0x48,
    LSM6DS3_ACC_GYRO_ODR_FIFO_6600Hz         = 0x50,
    LSM6DS3_ACC_GYRO_ODR_FIFO_13300Hz        = 0x58,
} LSM6DS3_ACC_GYRO_ODR_FIFO_t;

/****************************************************************************

I would take a look at the Sparkfun and Adafruit tutorials that are more in-depth for things like what you want. The BLE however I believe will be the limiting factor, payload size and Peripheral or Central roles, and receiver quality are important if your planning on “Streaming” the IMU data.
HTH
GL :slight_smile: PJ

Hi, Here’s the entire code :

 #define XIAO_MOUTHGUARD
//==============================================================================
// Includes
//==============================================================================
#include <ArduinoBLE.h> // to provide standard Bluetooth services
#include <Wire.h> // for I2C
#include "LSM6DS3.h"
//==============================================================================
// General global stuff
//==============================================================================
const int SAMPLE_INTERVAL_MS = 1000; // 1 sample per second
bool was_connected = false;

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

int16_t ax, ay, az, wx, wy, wz;
bool getBufferFlag = false;
// Circular buffer to store 4096 samples of sensor data
const int SAMPLE_BUFFER = 0.1; 

template <typename T>
class CircularBuffer {
public:
  CircularBuffer(int size) : size(size), buffer(new T[size]), head(0), tail(0), is_full(false) {}

  ~CircularBuffer() {
    delete[] buffer;
  }

  void write(T data) {
    buffer[tail] = data;
    tail = (tail + 1) % size;
    if (tail == head) {
      head = (head + 1) % size; // Overwrite from the last sample
      is_full = true;
    }
  }

  T read() {
    if (is_empty()) {
      // Handle empty buffer as needed
      // For example, return a default value or throw an exception
      Serial.println("Buffer is Empty");
    }
    T data = buffer[head];
    head = (head + 1) % size;
    is_full = false;
    return data;
  }

  bool is_empty() const {
    return !is_full && head == tail;
  }

  int count() const {
    if (is_full) {
      return size;
    } else if (tail >= head) {
      return tail - head;
    } else {
      return size - head + tail;
    }
  }

  bool is_full;

private:
  int size;
  T* buffer;
  int head;
  int tail;
};


// Define the buffers for each acceleration 
const int BUFFER_SIZE = 5000;
CircularBuffer<int16_t> axBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> ayBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> azBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wxBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wyBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wzBuffer(BUFFER_SIZE);

// Bluetooth low energy stuff
BLEService HRigService("39f17f86-d750-4b1b-9cb6-50f2c2647c5f");
BLECharacteristic sendStream("39f17f86-0001-4b1b-9cb6-50f2c2647c5f", BLERead | BLENotify,12);
BLECharacteristic getBuffer("39f17f86-0002-4b1b-9cb6-50f2c2647c5f", BLERead | BLEWrite, true);
BLECharacteristic sendBuffer("39f17f86-0003-4b1b-9cb6-50f2c2647c5f", BLERead | BLENotify, BUFFER_SIZE*12);


void rgbLedRed() {
  digitalWrite(LEDG, HIGH);  // common anode, so high = off
  digitalWrite(LEDB, HIGH);  // common anode, so high = off
  digitalWrite(LEDR, LOW);   // common anode, so high = off
}

void rgbLedBlue() {
  digitalWrite(LEDG, HIGH);  // common anode, so high = off
  digitalWrite(LEDB, LOW);   // common anode, so high = off
  digitalWrite(LEDR, HIGH);  // common anode, so high = off
}

void setup() {
  rgbLedRed();
  Serial.begin(9600);
  // Initialize the IMU sensor
  if (myIMU.begin() != 0) {
    Serial.println("IMU initialized");
  }
  else {
    Serial.println("Failed initializing IMU");
  }

  // Initialize the BLE module 
  if (!BLE.begin()) {
    Serial.println("BLE failed to initialize");
    while (1)
      ; // stop here!
  }
  BLE.setDeviceName("XIAO-BLE-Sense");
  BLE.setLocalName("XIAO-BLE-Sense");
  BLE.setAdvertisedService(HRigService);
  HRigService.addCharacteristic(sendStream);
  HRigService.addCharacteristic(getBuffer);
  HRigService.addCharacteristic(sendBuffer);
  BLE.addService(HRigService);
  BLE.setConnectionInterval(6, 12); // 7.5ms to 15 ms
  BLE.advertise();
}

void loop() {
  static uint32_t last_sample = 0;
  static uint32_t last_buffer_sample = 0; // New time variable for buffer stacking
  if (BLE.connected()) {
//int axOccupancy = axBuffer.count();
//Serial.println("axBuffer samples: " + String(axOccupancy));

    if (!was_connected) {
      was_connected = true;
      rgbLedBlue();
    }
    // Send 1 sample per second on the GUI in matlab
    if (millis() - last_sample >= SAMPLE_INTERVAL_MS) {
      last_sample = millis();
      sendSensorData();
    }
    // Stack the buffer data one by an other
    if (millis() - last_buffer_sample >= SAMPLE_BUFFER) {
      last_buffer_sample = millis();
      acquireBufferData();
    }
  }

  if(getBuffer.written()){
    getBufferFlag = true;
    Serial.println("I'm sending the buffer");
  }
  if (!BLE.connected() && was_connected) {
    was_connected = false;
    rgbLedRed();
  }
}

void sendSensorData() {
  // Your code to read sensor data
  int16_t data[6]; // Create an array to hold the 1x6 data

  // Populate the data array with your sensor data
  data[0] = myIMU.readFloatAccelX();
  data[1] = myIMU.readFloatAccelY();
  data[2] = myIMU.readFloatAccelZ();
  data[3] = myIMU.readFloatGyroX();
  data[4] = myIMU.readFloatGyroY();
  data[5] = myIMU.readFloatGyroZ();

  // Send the data
  sendStream.writeValue(data, sizeof(data));
}

void acquireBufferData() {
  int16_t axValue = myIMU.readFloatAccelX();
  int16_t ayValue = myIMU.readFloatAccelY();
  int16_t azValue = myIMU.readFloatAccelZ();
  int16_t wxValue = myIMU.readFloatGyroX();
  int16_t wyValue = myIMU.readFloatGyroY();
  int16_t wzValue = myIMU.readFloatGyroZ();

  axBuffer.write(axValue);
  ayBuffer.write(ayValue);
  azBuffer.write(azValue);
  wxBuffer.write(wxValue);
  wyBuffer.write(wyValue);
  wzBuffer.write(wzValue);


  if (axBuffer.is_full && ayBuffer.is_full && azBuffer.is_full &&
      wxBuffer.is_full && wyBuffer.is_full && wzBuffer.is_full) {
    Serial.println("Buffer is full");
  }
  if (getBufferFlag) {
    // Send the data over BLE
      int16_t dataBuffer[BUFFER_SIZE * 6]; // Create an array to hold all the data

    for (int i = 0; i < BUFFER_SIZE; i++) {
        dataBuffer[i * 6] = axBuffer.read();
        dataBuffer[i * 6 + 1] = ayBuffer.read();
        dataBuffer[i * 6 + 2] = azBuffer.read();
        dataBuffer[i * 6 + 3] = wxBuffer.read();
        dataBuffer[i * 6 + 4] = wyBuffer.read();
        dataBuffer[i * 6 + 5] = wzBuffer.read();
    }
    sendBuffer.writeValue(dataBuffer, sizeof(dataBuffer));
    getBufferFlag = false; // Reset the flag since data has been sent
    Serial.println("Data has been sent over BLE.");
  }
}

The problem is that I want that when the getBufferFlag is set to True through bluetooth the buffer with all the measurements of ax,ay,az,wx,wy,wz is sent through ble with all the measurements currently stored in the buffer, but the sampling frequency has to be at least 500-1000 Hz. I’m not using the IMU in fifo mode. I’ve also tried rewriting the registers :

myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL2_G, 0x8C); //1.66kHz 2000dps myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, 0x8A); //1.66kHz 4G

Hi there,
OK I’ll give that code a go. Any errors you get?
GL :slight_smile: PJ

Hi There,
Made some tweaks and loaded other LIB’s Seems to work now with Nrf Desktop.

 #define XIAO_MOUTHGUARD
//==============================================================================
// Includes
//==============================================================================
#include <ArduinoBLE.h> // to provide standard Bluetooth services
//#include "LSM6DS3.h"
#include <LSM6DS3.h>
#include <Wire.h> // for I2C
//==============================================================================
// General global stuff
//==============================================================================
const int SAMPLE_INTERVAL_MS = 1000; // 1 sample per second
bool was_connected = false;

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

int16_t ax, ay, az, wx, wy, wz;
bool getBufferFlag = false;
// Circular buffer to store 4096 samples of sensor data
const int SAMPLE_BUFFER = 0.1; 

template <typename T>
class CircularBuffer {
public:
  CircularBuffer(int size) : size(size), buffer(new T[size]), head(0), tail(0), is_full(false) {}

  ~CircularBuffer() {
    delete[] buffer;
  }

  void write(T data) {
    buffer[tail] = data;
    tail = (tail + 1) % size;
    if (tail == head) {
      head = (head + 1) % size; // Overwrite from the last sample
      is_full = true;
    }
  }

  T read() {
    if (is_empty()) {
      // Handle empty buffer as needed
      // For example, return a default value or throw an exception
      Serial.println("Buffer is Empty");
    }
    T data = buffer[head];
    head = (head + 1) % size;
    is_full = false;
    return data;
  }

  bool is_empty() const {
    return !is_full && head == tail;
  }

  int count() const {
    if (is_full) {
      return size;
    } else if (tail >= head) {
      return tail - head;
    } else {
      return size - head + tail;
    }
  }

  bool is_full;

private:
  int size;
  T* buffer;
  int head;
  int tail;
};


// Define the buffers for each acceleration 
const int BUFFER_SIZE = 5000;
CircularBuffer<int16_t> axBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> ayBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> azBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wxBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wyBuffer(BUFFER_SIZE);
CircularBuffer<int16_t> wzBuffer(BUFFER_SIZE);

// Bluetooth low energy stuff
BLEService HRigService("39f17f86-d750-4b1b-9cb6-50f2c2647c5f");
BLECharacteristic sendStream("39f17f86-0001-4b1b-9cb6-50f2c2647c5f", BLERead | BLENotify,12);
BLECharacteristic getBuffer("39f17f86-0002-4b1b-9cb6-50f2c2647c5f", BLERead | BLEWrite, true);
BLECharacteristic sendBuffer("39f17f86-0003-4b1b-9cb6-50f2c2647c5f", BLERead | BLENotify, BUFFER_SIZE*12);


void rgbLedRed() {
  digitalWrite(LED_GREEN, HIGH);  // common anode, so high = off
  digitalWrite(LED_BLUE, HIGH);  // common anode, so high = off
  digitalWrite(LED_RED, LOW);   // common anode, so high = off
}

void rgbLedBlue() {
  digitalWrite(LED_GREEN, HIGH);  // common anode, so high = off
  digitalWrite(LED_BLUE, LOW);   // common anode, so high = off
  digitalWrite(LED_RED, HIGH);  // common anode, so high = off
}

void setup() {
  Serial.begin(9600);
	   delay(2500);  //relax...Get Ready for serial port
   Serial.println();
   Serial.println();
   Serial.println("Power ON ");  // Let's BEGIN!!
   Serial.println(" Program " __FILE__ " compiled on " __DATE__ " at " __TIME__ );
   Serial.println();
 
  // Initialize the IMU sensor
  myIMU.settings.gyroEnabled = 1; // Gyro ON. 
   if (myIMU.begin() != 0) {
        Serial.println("IMU error");
    } else {
        Serial.println("IMU OK!");
    }
 rgbLedRed();
  // Initialize the BLE module 
  if (!BLE.begin()) {
    Serial.println("BLE failed to initialize");
    while (1)
      ; // stop here!
  }
  BLE.setDeviceName("XIAO-BLE-Sense");
  BLE.setLocalName("XIAO-BLE-Sense");
  BLE.setAdvertisedService(HRigService);
  HRigService.addCharacteristic(sendStream);
  HRigService.addCharacteristic(getBuffer);
  HRigService.addCharacteristic(sendBuffer);
  BLE.addService(HRigService);
  BLE.setConnectionInterval(6, 12); // 7.5ms to 15 ms
  BLE.advertise();
}

void loop() {
  static uint32_t last_sample = 0;
  static uint32_t last_buffer_sample = 0; // New time variable for buffer stacking
  if (BLE.connected()) {
    Serial.println("BLE connected");
//int axOccupancy = axBuffer.count();
//Serial.println("axBuffer samples: " + String(axOccupancy));

    if (!was_connected) {
      was_connected = true;
      rgbLedBlue();
    }
    // Send 1 sample per second on the GUI in matlab
    if (millis() - last_sample >= SAMPLE_INTERVAL_MS) {
      last_sample = millis();
      sendSensorData();
    }
    // Stack the buffer data one by an other
    if (millis() - last_buffer_sample >= SAMPLE_BUFFER) {
      last_buffer_sample = millis();
      acquireBufferData();
    }
  }

  if(getBuffer.written()){
    getBufferFlag = true;
    Serial.println("I'm sending the buffer");
  }
  if (!BLE.connected() && was_connected) {
    was_connected = false;
    rgbLedRed();
  }
}

void sendSensorData() {
  // Your code to read sensor data
  int16_t data[6]; // Create an array to hold the 1x6 data

  // Populate the data array with your sensor data
  data[0] = myIMU.readFloatAccelX();
  data[1] = myIMU.readFloatAccelY();
  data[2] = myIMU.readFloatAccelZ();
  data[3] = myIMU.readFloatGyroX();
  data[4] = myIMU.readFloatGyroY();
  data[5] = myIMU.readFloatGyroZ();

  // Send the data
  sendStream.writeValue(data, sizeof(data));
}

void acquireBufferData() {
  int16_t axValue = myIMU.readFloatAccelX();
  int16_t ayValue = myIMU.readFloatAccelY();
  int16_t azValue = myIMU.readFloatAccelZ();
  int16_t wxValue = myIMU.readFloatGyroX();
  int16_t wyValue = myIMU.readFloatGyroY();
  int16_t wzValue = myIMU.readFloatGyroZ();

  axBuffer.write(axValue);
  ayBuffer.write(ayValue);
  azBuffer.write(azValue);
  wxBuffer.write(wxValue);
  wyBuffer.write(wyValue);
  wzBuffer.write(wzValue);


  if (axBuffer.is_full && ayBuffer.is_full && azBuffer.is_full &&
      wxBuffer.is_full && wyBuffer.is_full && wzBuffer.is_full) {
    Serial.println("Buffer is full");
  }
  if (getBufferFlag) {
    // Send the data over BLE
      int16_t dataBuffer[BUFFER_SIZE * 6]; // Create an array to hold all the data

    for (int i = 0; i < BUFFER_SIZE; i++) {
        dataBuffer[i * 6] = axBuffer.read();
        dataBuffer[i * 6 + 1] = ayBuffer.read();
        dataBuffer[i * 6 + 2] = azBuffer.read();
        dataBuffer[i * 6 + 3] = wxBuffer.read();
        dataBuffer[i * 6 + 4] = wyBuffer.read();
        dataBuffer[i * 6 + 5] = wzBuffer.read();
    }
    sendBuffer.writeValue(dataBuffer, sizeof(dataBuffer));
    getBufferFlag = false; // Reset the flag since data has been sent
    Serial.println("Data has been sent over BLE.");
  }
}

here’s the output.

FQBN: Seeeduino:mbed:xiaonRF52840Sense
Using board 'xiaonRF52840Sense' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1
Using core 'arduino' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1

loading library from C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\libraries\Spi_Flash: invalid library: no header files found
Detecting libraries used...
C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -c -w -g3 -nostdlib @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/defines.txt @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_SEEED_XIAO_NRF52840_SENSE -DARDUINO_ARCH_MBED -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=1 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated-avr-comp -iprefixC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/includes.txt C:\Users\Dude\AppData\Local\Temp\arduino\sketches\534911D4F5EC47CA87587FD098646DFD\sketch\sketch_oct24a.ino.cpp -o nul
Alternatives for ArduinoBLE.h: [[email protected]]
ResolveLibrary(ArduinoBLE.h)
  -> candidates: [[email protected]]
C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -c -w -g3 -nostdlib @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/defines.txt @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_SEEED_XIAO_NRF52840_SENSE -DARDUINO_ARCH_MBED -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=1 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE -Id:\Arduino_projects\libraries\ArduinoBLE\src -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated-avr-comp -iprefixC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/includes.txt C:\Users\Dude\AppData\Local\Temp\arduino\sketches\534911D4F5EC47CA87587FD098646DFD\sketch\sketch_oct24a.ino.cpp -o nul
Alternatives for LSM6DS3.h: [Seeed Arduino [email protected]]
ResolveLibrary(LSM6DS3.h)
  -> candidates: [Seeed Arduino [email protected]]
C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -c -w -g3 -nostdlib @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/defines.txt @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_SEEED_XIAO_NRF52840_SENSE -DARDUINO_ARCH_MBED -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=1 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE -Id:\Arduino_projects\libraries\ArduinoBLE\src -Id:\Arduino_projects\libraries\Seeed_Arduino_LSM6DS3 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated-avr-comp -iprefixC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino 
EDIT--- for brevity -----

@C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/includes.txt C:\Users\Dude\AppData\Local\Temp\arduino\sketches\534911D4F5EC47CA87587FD098646DFD\sketch\sketch_oct24a.ino.cpp -o nul
Alternatives for Wire.h: [Wire]
ResolveLibrary(Wire.h)
  -> candidates: [Wire]
C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++ -c -w -g3 -nostdlib @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/defines.txt @C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE/cxxflags.txt -DARDUINO_ARCH_NRF52840 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_SEEED_XIAO_NRF52840_SENSE -DARDUINO_ARCH_MBED -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=1 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\variants\SEEED_XIAO_NRF52840_SENSE -Id:\Arduino_projects\libraries\ArduinoBLE\src -Id:\Arduino_projects\libraries\Seeed_Arduino_LSM6DS3 -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\libraries\Wire -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated -IC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino/api/deprecated-avr-comp -iprefixC:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1\cores\arduino 


"C:\\Users\\Dude\\AppData\\Local\\Temp\\arduino\\sketches\\534911D4F5EC47CA87587FD098646DFD/sketch_oct24a.ino.elf"
Sketch uses 334856 bytes (41%) of program storage space. Maximum is 811008 bytes.
Global variables use 71864 bytes (30%) of dynamic memory, leaving 165704 bytes for local variables. Maximum is 237568 bytes.
Performing 1200-bps touch reset on serial port COM16
Waiting for upload port...
Upload port found on COM6
"C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.1/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe" --verbose dfu serial -pkg "C:\Users\Dude\AppData\Local\Temp\arduino\sketches\534911D4F5EC47CA87587FD098646DFD/sketch_oct24a.ino.zip" -p COM6 -b 115200 --singlebank
Upgrading target on COM6 with DFU package C:\Users\Dude\AppData\Local\Temp\arduino\sketches\534911D4F5EC47CA87587FD098646DFD\sketch_oct24a.ino.zip. Flow control is disabled, Single bank, Touch disabled
Opened serial port COM6
Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 334864
Sending DFU start packet
Sending DFU init packet
Sending firmware file
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################################
###############
Activating new firmware

DFU upgrade took 20.781577348709106s
Device programmed.


I see IMU data in the BLE data, so now it’s a buffer management issue , I think?
Check it out, the IMU test logic was backwards… HTH
GL :slight_smile: PJ