Xiao Seeed nRF52840 Sense Sending accelerometer data through BLE not working

Hi, I am trying to send the IMU data specifically for the accelerometer through BLE and i get it to show up of the NRF connect app however i cant connect to it and when i look at the server for user data i get some random name : " Natenczas wojski male" and then a service predefined called heart rate and the accelerometer readings are not shown as a service at all. If someone could help me out on this would be much appreciated i am new to the xiao seeed chips and BLE. Here is the code :

#include <ArduinoBLE.h>
#include "LSM6DS3.h"
#include "Wire.h"
LSM6DS3 myIMU(I2C_MODE, 0x6A);    

BLEService accelerometer("E95D0753-251D-470A-A062-FA1922DFA9A8");
 

long previousMillis = 0;  
 
 
void setup()
{
  Serial.begin(9600);    
  
 
  pinMode(LED_BUILTIN, OUTPUT); 
  // begin initialization
  if (!BLE.begin()) 
  {
    Serial.println("starting BLE failed!");
 
    while (1);
  }
 
  BLE.setLocalName("AccelerometerSensor");
  BLE.setAdvertisedService(accelerometer); // add the service UUID
   // add the battery level characteristic
  BLE.addService(accelerometer);
  // set initial value for this characteristic
 
  // start advertising
  BLE.advertise();
 
  Serial.println("Bluetooth® device active, waiting for connections...");
}
 
 
void loop()
{
  // wait for a Bluetooth® Low Energy central
  BLEDevice central = BLE.central();
 
  // if a central is connected to the peripheral:
  if (central)
  {
    Serial.print("Connected to central: ");
    // print the central's BT address:
    Serial.println(central.address());
    // turn on the LED to indicate the connection:
    digitalWrite(LED_BUILTIN, HIGH);
 
   
    // while the central is connected:
    while (central.connected())
    {
      long currentMillis = millis();
      
      if (currentMillis - previousMillis >= 200)
      {
        previousMillis = currentMillis;
        updateSensorLevel();
      }
    }
    // when the central disconnects, turn off the LED:
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}
 
void updateSensorLevel()
{
  
  float ax,ay,az;

  ax =myIMU.readFloatAccelX();
  ay= myIMU.readFloatAccelY();
  az =myIMU.readFloatAccelZ();
  
  Serial.print("Accelerometer Readings: ");
  Serial.print("X: ");
  Serial.print(ax);
  Serial.print(", Y: ");
  Serial.print(ay);
  Serial.print(", Z: ");
  Serial.println(az);
 
}

At the very least, myIMU.begin() is required.

  Serial.begin(9600);
  while(!Serial);

  if (myIMU.begin() != 0) 
  {                                      
    Serial.println("IMU Device error");
    while(1);
  }
 

Hi there,
May I suggest you start with the Battery Service BLE demo. minimum requirements but shows what necessary for a basic one way data.

HTH
GL :slight_smile: PJ :v: