using Arduino code, create code for a Nicla Sense Me that connects to a device via BLE and, when connected, displays the quaternion data of Nicla's built-in IMU.
system
Arduino code kaa upyog karte hue, ek niklaa sens me ke liye code banaaen jo BLE ke madhyam se ek divaais se judata he or, jab judaa hua he, to niklaa ke antarnihit IMU ke kwaternian data ko pradarshit karata he.
user
avashya!yahan code he jo niklaa sens mujhe BLE ke madhyam se ek divaais se jodta he:

#include "arduino_bhy2.h"

// kwaternian data ke liye object inishilise karen
Sensorquaternion roteshan (Sensor_id_rv);


// aavriti ki IMU data ko matdaan kiya jaataa he (Hz main)
int poll_time = 1;

vyarth vyavastha(){
  serial.bin (115200);
  // BLE ke madhyam se IMU data bhejein
  Bhy2.begin ();
  roteshan.bin ();
}

shunya loop () {
  static auto lastche = milis ();
  Bhy2.update ();

  // pole IMU data or serial monitor ke liye print karen
  if (milis () - lastCheck> = 1000/poll_time)
  {
    LastCheck = Millis ();
    Serial.println (string ("divaais 1: roteshan:") + roteshan.taustring ());
  }
}

yahaan ham dekh sakate hai ki code IMU se kwaternian data ko padhane ke liye "BHY2HOST.H" librari kaa upyog karata he or saath hi BLE kaa upyog karke ek seva kaa vigyaapan karata he.
assistant
<|system|>
</s>
<|user|>
Arduino code kaa upyog karte hue, ek niklaa sens me ke liye code banaaen jo BLE ke madhyam se ek divaais se judata he or, jab judaa hua he, to niklaa ke antarnihit IMU ke kwaternian data ko pradarshit karata he.</s>
<|assistant|>
avashya!yahan code he jo niklaa sens mujhe BLE ke madhyam se ek divaais se jodta he:

#include "arduino_bhy2.h"

// kwaternian data ke liye object inishilise karen
Sensorquaternion roteshan (Sensor_id_rv);


// aavriti ki IMU data ko matdaan kiya jaataa he (Hz main)
int poll_time = 1;

vyarth vyavastha(){
  serial.bin (115200);
  // BLE ke madhyam se IMU data bhejein
  Bhy2.begin ();
  roteshan.bin ();
}

shunya loop () {
  static auto lastche = milis ();
  Bhy2.update ();

  // pole IMU data or serial monitor ke liye print karen
  if (milis () - lastCheck> = 1000/poll_time)
  {
    LastCheck = Millis ();
    Serial.println (string ("divaais 1: roteshan:") + roteshan.taustring ());
  }
}

yahaan ham dekh sakate hai ki code IMU se kwaternian data ko padhane ke liye "BHY2HOST.H" librari kaa upyog karata he or saath hi BLE kaa upyog karke ek seva kaa vigyaapan karata he.</s>
