Adafruit BNO055 Library
Classes | Public Types | Public Member Functions | List of all members
Adafruit_BNO055 Class Reference

Class that stores state and functions for interacting with BNO055 Sensor. More...

#include <Adafruit_BNO055.h>

Inheritance diagram for Adafruit_BNO055:

Classes

struct  adafruit_bno055_rev_info_t
 

Public Types

enum  adafruit_bno055_reg_t {
  BNO055_PAGE_ID_ADDR = 0X07, BNO055_CHIP_ID_ADDR = 0x00, BNO055_ACCEL_REV_ID_ADDR = 0x01, BNO055_MAG_REV_ID_ADDR = 0x02,
  BNO055_GYRO_REV_ID_ADDR = 0x03, BNO055_SW_REV_ID_LSB_ADDR = 0x04, BNO055_SW_REV_ID_MSB_ADDR = 0x05, BNO055_BL_REV_ID_ADDR = 0X06,
  BNO055_ACCEL_DATA_X_LSB_ADDR = 0X08, BNO055_ACCEL_DATA_X_MSB_ADDR = 0X09, BNO055_ACCEL_DATA_Y_LSB_ADDR = 0X0A, BNO055_ACCEL_DATA_Y_MSB_ADDR = 0X0B,
  BNO055_ACCEL_DATA_Z_LSB_ADDR = 0X0C, BNO055_ACCEL_DATA_Z_MSB_ADDR = 0X0D, BNO055_MAG_DATA_X_LSB_ADDR = 0X0E, BNO055_MAG_DATA_X_MSB_ADDR = 0X0F,
  BNO055_MAG_DATA_Y_LSB_ADDR = 0X10, BNO055_MAG_DATA_Y_MSB_ADDR = 0X11, BNO055_MAG_DATA_Z_LSB_ADDR = 0X12, BNO055_MAG_DATA_Z_MSB_ADDR = 0X13,
  BNO055_GYRO_DATA_X_LSB_ADDR = 0X14, BNO055_GYRO_DATA_X_MSB_ADDR = 0X15, BNO055_GYRO_DATA_Y_LSB_ADDR = 0X16, BNO055_GYRO_DATA_Y_MSB_ADDR = 0X17,
  BNO055_GYRO_DATA_Z_LSB_ADDR = 0X18, BNO055_GYRO_DATA_Z_MSB_ADDR = 0X19, BNO055_EULER_H_LSB_ADDR = 0X1A, BNO055_EULER_H_MSB_ADDR = 0X1B,
  BNO055_EULER_R_LSB_ADDR = 0X1C, BNO055_EULER_R_MSB_ADDR = 0X1D, BNO055_EULER_P_LSB_ADDR = 0X1E, BNO055_EULER_P_MSB_ADDR = 0X1F,
  BNO055_QUATERNION_DATA_W_LSB_ADDR = 0X20, BNO055_QUATERNION_DATA_W_MSB_ADDR = 0X21, BNO055_QUATERNION_DATA_X_LSB_ADDR = 0X22, BNO055_QUATERNION_DATA_X_MSB_ADDR = 0X23,
  BNO055_QUATERNION_DATA_Y_LSB_ADDR = 0X24, BNO055_QUATERNION_DATA_Y_MSB_ADDR = 0X25, BNO055_QUATERNION_DATA_Z_LSB_ADDR = 0X26, BNO055_QUATERNION_DATA_Z_MSB_ADDR = 0X27,
  BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR = 0X28, BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR = 0X29, BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR = 0X2A, BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR = 0X2B,
  BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR = 0X2C, BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR = 0X2D, BNO055_GRAVITY_DATA_X_LSB_ADDR = 0X2E, BNO055_GRAVITY_DATA_X_MSB_ADDR = 0X2F,
  BNO055_GRAVITY_DATA_Y_LSB_ADDR = 0X30, BNO055_GRAVITY_DATA_Y_MSB_ADDR = 0X31, BNO055_GRAVITY_DATA_Z_LSB_ADDR = 0X32, BNO055_GRAVITY_DATA_Z_MSB_ADDR = 0X33,
  BNO055_TEMP_ADDR = 0X34, BNO055_CALIB_STAT_ADDR = 0X35, BNO055_SELFTEST_RESULT_ADDR = 0X36, BNO055_INTR_STAT_ADDR = 0X37,
  BNO055_SYS_CLK_STAT_ADDR = 0X38, BNO055_SYS_STAT_ADDR = 0X39, BNO055_SYS_ERR_ADDR = 0X3A, BNO055_UNIT_SEL_ADDR = 0X3B,
  BNO055_OPR_MODE_ADDR = 0X3D, BNO055_PWR_MODE_ADDR = 0X3E, BNO055_SYS_TRIGGER_ADDR = 0X3F, BNO055_TEMP_SOURCE_ADDR = 0X40,
  BNO055_AXIS_MAP_CONFIG_ADDR = 0X41, BNO055_AXIS_MAP_SIGN_ADDR = 0X42, BNO055_SIC_MATRIX_0_LSB_ADDR = 0X43, BNO055_SIC_MATRIX_0_MSB_ADDR = 0X44,
  BNO055_SIC_MATRIX_1_LSB_ADDR = 0X45, BNO055_SIC_MATRIX_1_MSB_ADDR = 0X46, BNO055_SIC_MATRIX_2_LSB_ADDR = 0X47, BNO055_SIC_MATRIX_2_MSB_ADDR = 0X48,
  BNO055_SIC_MATRIX_3_LSB_ADDR = 0X49, BNO055_SIC_MATRIX_3_MSB_ADDR = 0X4A, BNO055_SIC_MATRIX_4_LSB_ADDR = 0X4B, BNO055_SIC_MATRIX_4_MSB_ADDR = 0X4C,
  BNO055_SIC_MATRIX_5_LSB_ADDR = 0X4D, BNO055_SIC_MATRIX_5_MSB_ADDR = 0X4E, BNO055_SIC_MATRIX_6_LSB_ADDR = 0X4F, BNO055_SIC_MATRIX_6_MSB_ADDR = 0X50,
  BNO055_SIC_MATRIX_7_LSB_ADDR = 0X51, BNO055_SIC_MATRIX_7_MSB_ADDR = 0X52, BNO055_SIC_MATRIX_8_LSB_ADDR = 0X53, BNO055_SIC_MATRIX_8_MSB_ADDR = 0X54,
  ACCEL_OFFSET_X_LSB_ADDR = 0X55, ACCEL_OFFSET_X_MSB_ADDR = 0X56, ACCEL_OFFSET_Y_LSB_ADDR = 0X57, ACCEL_OFFSET_Y_MSB_ADDR = 0X58,
  ACCEL_OFFSET_Z_LSB_ADDR = 0X59, ACCEL_OFFSET_Z_MSB_ADDR = 0X5A, MAG_OFFSET_X_LSB_ADDR = 0X5B, MAG_OFFSET_X_MSB_ADDR = 0X5C,
  MAG_OFFSET_Y_LSB_ADDR = 0X5D, MAG_OFFSET_Y_MSB_ADDR = 0X5E, MAG_OFFSET_Z_LSB_ADDR = 0X5F, MAG_OFFSET_Z_MSB_ADDR = 0X60,
  GYRO_OFFSET_X_LSB_ADDR = 0X61, GYRO_OFFSET_X_MSB_ADDR = 0X62, GYRO_OFFSET_Y_LSB_ADDR = 0X63, GYRO_OFFSET_Y_MSB_ADDR = 0X64,
  GYRO_OFFSET_Z_LSB_ADDR = 0X65, GYRO_OFFSET_Z_MSB_ADDR = 0X66, ACCEL_RADIUS_LSB_ADDR = 0X67, ACCEL_RADIUS_MSB_ADDR = 0X68,
  MAG_RADIUS_LSB_ADDR = 0X69, MAG_RADIUS_MSB_ADDR = 0X6A
}
 
enum  adafruit_bno055_powermode_t { POWER_MODE_NORMAL = 0X00, POWER_MODE_LOWPOWER = 0X01, POWER_MODE_SUSPEND = 0X02 }
 
enum  adafruit_bno055_axis_remap_config_t {
  REMAP_CONFIG_P0 = 0x21, REMAP_CONFIG_P1 = 0x24, REMAP_CONFIG_P2 = 0x24, REMAP_CONFIG_P3 = 0x21,
  REMAP_CONFIG_P4 = 0x24, REMAP_CONFIG_P5 = 0x21, REMAP_CONFIG_P6 = 0x21, REMAP_CONFIG_P7 = 0x24
}
 
enum  adafruit_bno055_axis_remap_sign_t {
  REMAP_SIGN_P0 = 0x04, REMAP_SIGN_P1 = 0x00, REMAP_SIGN_P2 = 0x06, REMAP_SIGN_P3 = 0x02,
  REMAP_SIGN_P4 = 0x03, REMAP_SIGN_P5 = 0x01, REMAP_SIGN_P6 = 0x07, REMAP_SIGN_P7 = 0x05
}
 
enum  adafruit_vector_type_t {
  VECTOR_ACCELEROMETER = BNO055_ACCEL_DATA_X_LSB_ADDR, VECTOR_MAGNETOMETER = BNO055_MAG_DATA_X_LSB_ADDR, VECTOR_GYROSCOPE = BNO055_GYRO_DATA_X_LSB_ADDR, VECTOR_EULER = BNO055_EULER_H_LSB_ADDR,
  VECTOR_LINEARACCEL = BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR, VECTOR_GRAVITY = BNO055_GRAVITY_DATA_X_LSB_ADDR
}
 

Public Member Functions

 Adafruit_BNO055 (int32_t sensorID=-1, uint8_t address=BNO055_ADDRESS_A, TwoWire *theWire=&Wire)
 Instantiates a new Adafruit_BNO055 class. More...
 
bool begin (adafruit_bno055_opmode_t mode=OPERATION_MODE_NDOF)
 Sets up the HW. More...
 
void setMode (adafruit_bno055_opmode_t mode)
 Puts the chip in the specified operating mode. More...
 
adafruit_bno055_opmode_t getMode ()
 Gets the current operating mode of the chip. More...
 
void setAxisRemap (adafruit_bno055_axis_remap_config_t remapcode)
 Changes the chip's axis remap. More...
 
void setAxisSign (adafruit_bno055_axis_remap_sign_t remapsign)
 Changes the chip's axis signs. More...
 
void getRevInfo (adafruit_bno055_rev_info_t *)
 Gets the chip revision numbers. More...
 
void setExtCrystalUse (boolean usextal)
 Use the external 32.768KHz crystal. More...
 
void getSystemStatus (uint8_t *system_status, uint8_t *self_test_result, uint8_t *system_error)
 Gets the latest system status info. More...
 
void getCalibration (uint8_t *system, uint8_t *gyro, uint8_t *accel, uint8_t *mag)
 Gets current calibration state. Each value should be a uint8_t pointer and it will be set to 0 if not calibrated and 3 if fully calibrated. See section 34.3.54. More...
 
imu::Vector< 3 > getVector (adafruit_vector_type_t vector_type)
 Gets a vector reading from the specified source. More...
 
imu::Quaternion getQuat ()
 Gets a quaternion reading from the specified source. More...
 
int8_t getTemp ()
 Gets the temperature in degrees celsius. More...
 
bool getEvent (sensors_event_t *)
 Reads the sensor and returns the data as a sensors_event_t. More...
 
bool getEvent (sensors_event_t *, adafruit_vector_type_t)
 Reads the sensor and returns the data as a sensors_event_t. More...
 
void getSensor (sensor_t *)
 Provides the sensor_t data for this sensor. More...
 
bool getSensorOffsets (uint8_t *calibData)
 Reads the sensor's offset registers into a byte array. More...
 
bool getSensorOffsets (adafruit_bno055_offsets_t &offsets_type)
 Reads the sensor's offset registers into an offset struct. More...
 
void setSensorOffsets (const uint8_t *calibData)
 Writes an array of calibration values to the sensor's offset. More...
 
void setSensorOffsets (const adafruit_bno055_offsets_t &offsets_type)
 Writes to the sensor's offset registers from an offset struct. More...
 
bool isFullyCalibrated ()
 Checks of all cal status values are set to 3 (fully calibrated) More...
 
void enterSuspendMode ()
 Enter Suspend mode (i.e., sleep)
 
void enterNormalMode ()
 Enter Normal mode (i.e., wake)
 

Detailed Description

Class that stores state and functions for interacting with BNO055 Sensor.

Member Enumeration Documentation

◆ adafruit_bno055_reg_t

BNO055 Registers

◆ adafruit_bno055_powermode_t

BNO055 power settings

◆ adafruit_bno055_axis_remap_config_t

Remap settings

◆ adafruit_bno055_axis_remap_sign_t

Remap Signs

◆ adafruit_vector_type_t

Vector Mappings

Constructor & Destructor Documentation

◆ Adafruit_BNO055()

Adafruit_BNO055::Adafruit_BNO055 ( int32_t  sensorID = -1,
uint8_t  address = BNO055_ADDRESS_A,
TwoWire *  theWire = &Wire 
)

Instantiates a new Adafruit_BNO055 class.

Parameters
sensorIDsensor ID
addressi2c address
theWireWire object

Member Function Documentation

◆ begin()

bool Adafruit_BNO055::begin ( adafruit_bno055_opmode_t  mode = OPERATION_MODE_NDOF)

Sets up the HW.

Parameters
modemode values [OPERATION_MODE_CONFIG, OPERATION_MODE_ACCONLY, OPERATION_MODE_MAGONLY, OPERATION_MODE_GYRONLY, OPERATION_MODE_ACCMAG, OPERATION_MODE_ACCGYRO, OPERATION_MODE_MAGGYRO, OPERATION_MODE_AMG, OPERATION_MODE_IMUPLUS, OPERATION_MODE_COMPASS, OPERATION_MODE_M4G, OPERATION_MODE_NDOF_FMC_OFF, OPERATION_MODE_NDOF]
Returns
true if process is successful

◆ setMode()

void Adafruit_BNO055::setMode ( adafruit_bno055_opmode_t  mode)

Puts the chip in the specified operating mode.

Parameters
modemode values [OPERATION_MODE_CONFIG, OPERATION_MODE_ACCONLY, OPERATION_MODE_MAGONLY, OPERATION_MODE_GYRONLY, OPERATION_MODE_ACCMAG, OPERATION_MODE_ACCGYRO, OPERATION_MODE_MAGGYRO, OPERATION_MODE_AMG, OPERATION_MODE_IMUPLUS, OPERATION_MODE_COMPASS, OPERATION_MODE_M4G, OPERATION_MODE_NDOF_FMC_OFF, OPERATION_MODE_NDOF]

◆ getMode()

adafruit_bno055_opmode_t Adafruit_BNO055::getMode ( )

Gets the current operating mode of the chip.

Returns
operating_mode in integer which can be mapped in Section 3.3 for example: a return of 12 (0X0C) => NDOF

◆ setAxisRemap()

void Adafruit_BNO055::setAxisRemap ( adafruit_bno055_axis_remap_config_t  remapcode)

Changes the chip's axis remap.

Parameters
remapcoderemap code possible values [REMAP_CONFIG_P0 REMAP_CONFIG_P1 (default) REMAP_CONFIG_P2 REMAP_CONFIG_P3 REMAP_CONFIG_P4 REMAP_CONFIG_P5 REMAP_CONFIG_P6 REMAP_CONFIG_P7]

◆ setAxisSign()

void Adafruit_BNO055::setAxisSign ( adafruit_bno055_axis_remap_sign_t  remapsign)

Changes the chip's axis signs.

Parameters
remapsignremap sign possible values [REMAP_SIGN_P0 REMAP_SIGN_P1 (default) REMAP_SIGN_P2 REMAP_SIGN_P3 REMAP_SIGN_P4 REMAP_SIGN_P5 REMAP_SIGN_P6 REMAP_SIGN_P7]

◆ getRevInfo()

void Adafruit_BNO055::getRevInfo ( adafruit_bno055_rev_info_t info)

Gets the chip revision numbers.

Parameters
inforevision info

◆ setExtCrystalUse()

void Adafruit_BNO055::setExtCrystalUse ( boolean  usextal)

Use the external 32.768KHz crystal.

Parameters
usextaluse external crystal boolean

◆ getSystemStatus()

void Adafruit_BNO055::getSystemStatus ( uint8_t *  system_status,
uint8_t *  self_test_result,
uint8_t *  system_error 
)

Gets the latest system status info.

Parameters
system_statussystem status info
self_test_resultself test result
system_errorsystem error info

◆ getCalibration()

void Adafruit_BNO055::getCalibration ( uint8_t *  sys,
uint8_t *  gyro,
uint8_t *  accel,
uint8_t *  mag 
)

Gets current calibration state. Each value should be a uint8_t pointer and it will be set to 0 if not calibrated and 3 if fully calibrated. See section 34.3.54.

Parameters
sysCurrent system calibration status, depends on status of all sensors, read-only
gyroCurrent calibration status of Gyroscope, read-only
accelCurrent calibration status of Accelerometer, read-only
magCurrent calibration status of Magnetometer, read-only

◆ getVector()

imu::Vector< 3 > Adafruit_BNO055::getVector ( adafruit_vector_type_t  vector_type)

Gets a vector reading from the specified source.

Parameters
vector_typepossible vector type values [VECTOR_ACCELEROMETER VECTOR_MAGNETOMETER VECTOR_GYROSCOPE VECTOR_EULER VECTOR_LINEARACCEL VECTOR_GRAVITY]
Returns
vector from specified source

Convert the value to an appropriate range (section 3.6.4) and assign the value to the Vector type

◆ getQuat()

imu::Quaternion Adafruit_BNO055::getQuat ( )

Gets a quaternion reading from the specified source.

Returns
quaternion reading

Assign to Quaternion See https://cdn-shop.adafruit.com/datasheets/BST_BNO055_DS000_12.pdf 3.6.5.5 Orientation (Quaternion)

◆ getTemp()

int8_t Adafruit_BNO055::getTemp ( )

Gets the temperature in degrees celsius.

Returns
temperature in degrees celsius

◆ getEvent() [1/2]

bool Adafruit_BNO055::getEvent ( sensors_event_t *  event)

Reads the sensor and returns the data as a sensors_event_t.

Parameters
eventEvent description
Returns
always returns true

◆ getEvent() [2/2]

bool Adafruit_BNO055::getEvent ( sensors_event_t *  event,
adafruit_vector_type_t  vec_type 
)

Reads the sensor and returns the data as a sensors_event_t.

Parameters
eventEvent description
vec_typespecify the type of reading
Returns
always returns true

◆ getSensor()

void Adafruit_BNO055::getSensor ( sensor_t *  sensor)

Provides the sensor_t data for this sensor.

Parameters
sensorSensor description

◆ getSensorOffsets() [1/2]

bool Adafruit_BNO055::getSensorOffsets ( uint8_t *  calibData)

Reads the sensor's offset registers into a byte array.

Parameters
calibDataCalibration offset (buffer size should be 22)
Returns
true if read is successful

◆ getSensorOffsets() [2/2]

bool Adafruit_BNO055::getSensorOffsets ( adafruit_bno055_offsets_t offsets_type)

Reads the sensor's offset registers into an offset struct.

Parameters
offsets_typetype of offsets
Returns
true if read is successful

◆ setSensorOffsets() [1/2]

void Adafruit_BNO055::setSensorOffsets ( const uint8_t *  calibData)

Writes an array of calibration values to the sensor's offset.

Parameters
calibDatacalibration data

◆ setSensorOffsets() [2/2]

void Adafruit_BNO055::setSensorOffsets ( const adafruit_bno055_offsets_t offsets_type)

Writes to the sensor's offset registers from an offset struct.

Parameters
offsets_typeaccel_offset_x = acceleration offset x accel_offset_y = acceleration offset y accel_offset_z = acceleration offset z

mag_offset_x = magnetometer offset x mag_offset_y = magnetometer offset y mag_offset_z = magnetometer offset z

gyro_offset_x = gyroscrope offset x gyro_offset_y = gyroscrope offset y gyro_offset_z = gyroscrope offset z

◆ isFullyCalibrated()

bool Adafruit_BNO055::isFullyCalibrated ( )

Checks of all cal status values are set to 3 (fully calibrated)

Returns
status of calibration

The documentation for this class was generated from the following files: