Wiring and Test

Wiring for Arduino

You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C capability, then port the code - its pretty simple stuff!

To connect the assembled BNO055 breakout to an Arduino Uno, follow the wiring diagram below.

  • Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
  • Connect GND to common power/data ground
  • Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
  • Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
If you're using a Genuino Zero or Arduino Zero with the built in EDBG interface you may need to use I2C address 0x29 since 0x28 is 'taken' by the DBG chip

Software

The Adafruit_BNO055 driver supports reading raw sensor data, or you can use the Adafruit Unified Sensor system to retrieve orientation data in a standard data format.

Download the Driver from Github

To begin controling the motor chip, you will need to download the Adafruit_BNO055 Library from our github repository. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip

Rename the uncompressed folder Adafruit_BNO055 and check that the Adafruit_BNO055 folder contains Adafruit_BNO055.cpp and Adafruit_BNO055.h

Place the Adafruit_BNO055 library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

Download Adafruit_Sensor

We also have a core sensor library that helps manage sensor readings. So, just like the BNO055 library, download Adafruit_Sensor

Install just like you did with Adafruit_BNO055

Adafruit Unified Sensor System

Since the Adafruit_BNO055 driver is based on the Adafruit Unified Sensor system, you can retrieve your three axis orientation data (in Euler angles) using the standard types and functions described in the Adafruit Sensor learning guide (.getEvent, .getSensor, etc.).

This is probably the easiest option if all you care about is absolute orientation data across three axis.

For example, the following code snippet shows the core of what is needed to start reading data using the Unified Sensor System:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
  
Adafruit_BNO055 bno = Adafruit_BNO055(55);

void setup(void) 
{
  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");
  
  /* 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);
    
  bno.setExtCrystalUse(true);
}

void loop(void) 
{
  /* Get a new sensor event */ 
  sensors_event_t event; 
  bno.getEvent(&event);
  
  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(event.orientation.x, 4);
  Serial.print("\tY: ");
  Serial.print(event.orientation.y, 4);
  Serial.print("\tZ: ");
  Serial.print(event.orientation.z, 4);
  Serial.println("");
  
  delay(100);
}

'sensorapi' Example

To test the Unified Sensor System output, open the sensorapi demo in the Adafruit_BNO055 examples folder:

This should produce the following output on the Serial Monitor:

Raw Sensor Data

If you don't want to use the Adafruit Unified Sensor system (for example if you want to access the raw accelerometer, magnetometer or gyroscope data directly before the sensor fusion algorithms process it), you can use the raw helper functions in the driver.

The key raw data functions are:

  • getVector (adafruit_vector_type_t vector_type)
  • getQuat (void)
  • getTemp (void)

.getVector ( adafruit_vector_type_t vector_type )

The .getVector function accepts a single parameter (vector_type), which indicates what type of 3-axis vector data to return.  

The vector_type field can be one of the following values:

  • VECTOR_MAGNETOMETER (values in uT, micro Teslas)
  • VECTOR_GYROSCOPE (values in rps, radians per second)
  • VECTOR_EULER (values in Euler angles or 'degrees', from 0..359)
  • VECTOR_ACCELEROMETER (values in m/s^2)
  • VECTOR_LINEARACCEL (values in m/s^2)
  • VECTOR_GRAVITY (values in m/s^2)

For example, to get the Euler angles vector, we could run the following code:

imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
  
/* Display the floating point data */
Serial.print("X: ");
Serial.print(euler.x());
Serial.print(" Y: ");
Serial.print(euler.y());
Serial.print(" Z: ");
Serial.print(euler.z());
Serial.println("");

.getQuat(void)

The .getQuat function returns a Quaternion, which is often easier and more accurate to work with than Euler angles when doing sensor fusion or data manipulation with raw sensor data.

You can get a quaternion data sample via the following code:

imu::Quaternion quat = bno.getQuat();

/* Display the quat data */
Serial.print("qW: ");
Serial.print(quat.w(), 4);
Serial.print(" qX: ");
Serial.print(quat.y(), 4);
Serial.print(" qY: ");
Serial.print(quat.x(), 4);
Serial.print(" qZ: ");
Serial.print(quat.z(), 4);
Serial.println("");

.getTemp(void)

The .getTemp helper returns the current ambient temperature in degrees celsius, and can be read via the following function call:

/* Display the current temperature */
int8_t temp = bno.getTemp();

Serial.print("Current Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.println("");

'rawdata' Example

To test the raw data ouput, open the rawdata demo in the Adafruit_BNO055 examples folder:

This should produce the following output on the Serial Monitor:

By default, the sketch generates Euler angle absolute orientation data, but you can easily modify the data displayed by changing the value provided to .getVector below:

  // Possible vector values can be:
  // - VECTOR_ACCELEROMETER - m/s^2
  // - VECTOR_MAGNETOMETER  - uT
  // - VECTOR_GYROSCOPE     - rad/s
  // - VECTOR_EULER         - degrees
  // - VECTOR_LINEARACCEL   - m/s^2
  // - VECTOR_GRAVITY       - m/s^2
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
  
  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(euler.x());
  Serial.print(" Y: ");
  Serial.print(euler.y());
  Serial.print(" Z: ");
  Serial.print(euler.z());
  Serial.println("");
Last updated on 2016-02-06 at 02.21.21 PM Published on 2015-04-22 at 02.24.11 PM