Skip to content

Instantly share code, notes, and snippets.

@dj1711572002
Created November 22, 2023 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj1711572002/872715399d810dc6401a403c96edf77e to your computer and use it in GitHub Desktop.
Save dj1711572002/872715399d810dc6401a403c96edf77e to your computer and use it in GitHub Desktop.
Adafrui BNO085 UART-RVC MODE ESP32D BlueTOOTH monitor
/* Test sketch for Adafruit BNO08x sensor in UART-RVC mode */
#include "Adafruit_BNO08x_RVC.h"
Adafruit_BNO08x_RVC rvc = Adafruit_BNO08x_RVC();
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif
BluetoothSerial SerialBT;
uint64_t chipid;
char chipname[256];
//===============================================
void setup() {
// Wait for serial monitor to open
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println("Adafruit BNO08x IMU - UART-RVC mode");
Serial1.begin(115200,SERIAL_8N1,16,17); // RX16,TX17 This is the baud rate specified by the datasheet
while (!Serial1)
delay(10);
if (!rvc.begin(&Serial1)) { // connect to the sensor over hardware serial
Serial.println("Could not find BNO08x!");
while (1)
delay(10);
}
Serial.println("BNO08x found!");
//Bluetooth setup
delay(1000);
chipid = ESP.getEfuseMac();
sprintf( chipname, "ESP32D_%04X", (uint16_t)(chipid >> 32));
SerialBT.begin(chipname);
Serial.print("BT chipname:");
Serial.println(chipname);
}
void loop() {
BNO08x_RVC_Data heading;
if (!rvc.read(&heading)) {
return;
}
delay(20);
Serial.printf("%4.2f,%4.2f,%4.2f\n\r",heading.yaw,heading.pitch,heading.roll);
SerialBT.printf("%4.2f,%4.2f,%4.2f\n\r",heading.yaw,heading.pitch,heading.roll);
/*
Serial.println();
Serial.println(F("---------------------------------------"));
Serial.println(F("Principal Axes:"));
Serial.println(F("---------------------------------------"));
Serial.print(F("Yaw: "));
Serial.print(heading.yaw);
Serial.print(F("\tPitch: "));
Serial.print(heading.pitch);
Serial.print(F("\tRoll: "));
Serial.println(heading.roll);
Serial.println(F("---------------------------------------"));
Serial.println(F("Acceleration"));
Serial.println(F("---------------------------------------"));
Serial.print(F("X: "));
Serial.print(heading.x_accel);
Serial.print(F("\tY: "));
Serial.print(heading.y_accel);
Serial.print(F("\tZ: "));
Serial.println(heading.z_accel);
Serial.println(F("---------------------------------------"));
*/
// delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment