#include #include #include #include /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), which provides a common 'type' for sensor data and some helper functions. To use this driver you will also need to download the Adafruit_Sensor library and include it in your libraries folder. You should also assign a unique ID to this sensor for use with the Adafruit Sensor API so that you can identify this particular sensor in any data logs, etc. To assign a unique ID, simply provide an appropriate value in the constructor below (12345 is used by default in this example). Connections =========== Connect SCL to analog 5 Connect SDA to analog 4 Connect VDD to 3.3-5V DC Connect GROUND to common ground History ======= 2015/MAR/03 - First release (KTOWN) Modified by Abhishek Kumar for data compatiblility in Unity and Arduino */ /* Set the delay between fresh samples */ #define BNO055_SAMPLERATE_DELAY_MS (100) // Check I2C device address and correct line below (by default address is 0x29 or 0x28) // id, address Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28); /**************************************************************************/ void setup(void) { Serial.begin(9600); /* Initialise the sensor */ if(!bno.begin()) { /* There was a problem detecting the BNO055 ... check your connections */ Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); while(1); } delay(1000); /* Use external crystal for better accuracy */ bno.setExtCrystalUse(true); /**************************************************************************/ /* Arduino loop function, called once 'setup' is complete (your own code should go here) */ /**************************************************************************/ void loop(void) { /* Get a new sensor event */ sensors_event_t event; bno.getEvent(&event); // I changed the data strcture of serial communication to make it compatible with the data strcture being used to read the data in Unity (Visual C#). Serial.print("|"); Serial.print((float)event.orientation.x); Serial.print("|"); Serial.print((float)event.orientation.y); Serial.print("|"); Serial.print((float)event.orientation.z); Serial.println(); /* The processing sketch expects data as roll, pitch, heading */ delay(BNO055_SAMPLERATE_DELAY_MS); }