UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

BNO055 Class

Module: bno055
  • ID: bno055
  • Name: Intelligent 9-axis Absolute Orientation Sensor
  • Category: accelerometer compass
  • Manufacturer: bosch adafruit
  • Connection: i2c gpio
  • Link: https://www.adafruit.com/products/2472

The BNO055 is a System in Package (SiP), integrating a triaxial 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of +/- 2000 degrees per second, a triaxial geomagnetic sensor and a 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor fusion software, in a single package.
This sensor handles the hard problem of combining various sensor information into a reliable measurement of sensor orientation (refered to as 'sensor fusion'). The onboard MCU runs this software and can provide fusion output in the form of Euler Angles, Quaternions, Linear Acceleration, and Gravity Vectors in 3 axes.
The focus on this driver has been on supporting the fusion components. Less support is available for use of this device as a generic accelerometer, gyroscope and magnetometer, however enough infrastructure is available to add any missing functionality.
This device requires calibration in order to operate accurately. Methods are provided to retrieve calibration data (once calibrated) to be stored somewhere else, like in a file. A method is provided to load this data as well. Calibration data is lost on a power cycle. See one of the examples for a description of how to calibrate the device, but in essence:
There is a calibration status register available ( getCalibrationStatus() ) that returns the calibration status of the accelerometer (ACC), magnetometer (MAG), gyroscope (GYR), and overall system (SYS). Each of these values range from 0 (uncalibrated) to 3 (fully calibrated). Calibration involves certain motions to get all 4 values at 3. The motions are as follows (though see the datasheet for more information):
GYR: Simply let the sensor sit flat for a few seconds.
ACC: Move the sensor in various positions. Start flat, then rotate slowly by 45 degrees, hold for a few seconds, then continue rotating another 45 degrees and hold, etc. 6 or more movements of this type may be required. You can move through any axis you desire, but make sure that the device is lying at least once perpendicular to the x, y, and z axis.
MAG: Move slowly in a figure 8 pattern in the air, until the calibration values reaches 3.
SYS: This will usually reach 3 when the other items have also reached 3. If not, continue slowly moving the device though various axes until it does.

Methods

BNO055

(
  • bus
  • addr
)
Number

BNO055 constructor.
By default, the constructor sets the acceleration units to m/s^2, gyro and Euler units to degrees, and temperature to celsius. It then enters the NDOF fusion mode.
In addition, the internal clock is used so that compatibility with other implementations is assured. If you are using a device with an external clock, call setClockExternal(true) to enable it.

Parameters:

  • bus Number

    I2C bus to use.

  • addr Number

    undefined

Returns:

Number:

update

()

Update the internal stored values from sensor data.

getChipID

() Number

Return the chip ID.

Returns:

Number:

The chip ID (BNO055_CHIPID).

getACCID

() Number

Return the accelerometer chip ID.

Returns:

Number:

The chip ID.

getMAGID

() Number

Return the magnetometer chip ID.

Returns:

Number:

The chip ID.

getGYRID

() Number

Return the gyroscope chip ID.

Returns:

Number:

The chip ID.

getSWRevID

() Number

Return the fusion firmware revison.

Returns:

Number:

The firmware revison.

getBootLoaderID

() Number

Return the bootloader ID.

Returns:

Number:

The bootloader ID.

setClockExternal

(
  • extClock
)

Enable or disables the use of the external clock. The Adafruit device does contain an external clock which might be more stable. By default, the internal clock is used.

Parameters:

  • extClock Boolean

    true to use external clock, false otherwise.

setTemperatureSource

(
  • src
)

Select the temperature source. This can be the accelerometer or the gyroscope. By default, the accelerometer temperature is used as the source.

Parameters:

  • src BNO055_TEMP_SOURCES_T

    One of the BNO055_TEMP_SOURCES_T values.

setOperationMode

(
  • mode
)

Set the operating mode for the device. This places the device into a config mode, one of 7 non-fusion modes, or one of 5 fusion modes. All stored sensor data is cleared when switching modes. The device must be in config mode for most configuration operations. See the datasheet for details.

Parameters:

  • mode BNO055_OPERATION_MODES_T

    One of the BNO055_OPERATION_MODES_T values.

resetSystem

()

Reboot the sensor. This is equivalent to a power on reset. All calibration data will be lost, and the device must be recalibrated.

getCalibrationStatus

(
  • mag
  • acc
  • gyr
  • sys
)

Read the calibration status registers and return them. The values range from 0 (uncalibrated) to 3 (fully calibrated).

Parameters:

  • mag Int *

    The calibration status of the overall system.

  • acc Int *

    The calibration status of the accelerometer.

  • gyr Int *

    undefined

  • sys Int *

    undefined

getCalibrationStatus

() Std::vector int

Read the calibration status registers and return them as an integer vector. The values range from 0 (uncalibrated) to 3 (fully calibrated).

Returns:

Std::vector int :

An integer vector containing the values in the order: mag, acc, gyr, and sys.

isFullyCalibrated

() Boolean

Read the calibration status registers and return true or false, indicating whether all of the calibration parameters are fully calibrated.

Returns:

Boolean:

True if all 4 calibration parameters are fully calibrated, else false.

readCalibrationData

() Std::vector uint8_t

Read the calibration data and return it as a string. This data can then be saved for later reuse by writeCalibrationData() to restore calibration data after a reset. The sensor must be fully calibrated before calibration data can be read.

Returns:

Std::vector uint8_t :

A vector of uint8_t's representing the calibration data. This vector will always be exactly BNO055_CALIBRATION_DATA_SIZE in size.

writeCalibrationData

(
  • calibrationData
)

Write previously saved calibration data to the calibration registers.

Parameters:

  • calibrationData Std::vector uint8_t

    A vector of uint8_t (bytes) representing calibration data as returned by readCalibrationData() . It's length must always be exactly BNO055_CALIBRATION_DATA_SIZE.

getTemperature

(
  • fahrenheit
)
Number

Return the current measured temperature. Note, this is not ambient temperature - this is the temperature of the selected source on the chip. update() must have been called prior to calling this method.

Parameters:

  • fahrenheit Boolean

    true to return data in Fahrenheit, false for Celicus. Celsius is the default.

Returns:

Number:

The temperature in degrees Celsius or Fahrenheit.

getEulerAngles

(
  • heading
  • roll
  • pitch
)

Return current orientation fusion data in the form of Euler Angles. By default, the returned values are in degrees. update() must have been called prior to calling this method.

Parameters:

  • heading Float *

    Pointer to a floating point value that will have the current heading angle placed into it.

  • roll Float *

    Pointer to a floating point value that will have the current roll angle placed into it.

  • pitch Float *

    Pointer to a floating point value that will have the current pitch angle placed into it.

getEulerAngles

() Std::vector float

Return current orientation fusion data in the form of Euler Angles as a floating point vector. By default, the returned values are in degrees. update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing heading, roll, and pitch, in that order.

getQuaternions

(
  • w
  • x
  • y
  • z
)

Return current orientation fusion data in the form of Quaternions. update() must have been called prior to calling this method.

Parameters:

  • w Float *

    Pointer to a floating point value that will have the current w component placed into it.

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getQuaternions

() Std::vector float

Return current orientation fusion data in the form of Quaternions, as a floating point vector. update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing w, x, y, and z in that order.

getLinearAcceleration

(
  • x
  • y
  • z
)

Return current orientation fusion data in the form of Linear Acceleration. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getLinearAcceleration

() Std::vector float

Return current orientation fusion data in the form of Linear Acceleration, as a floating point vector. update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing x, y, and z in that order.

getGravityVectors

(
  • x
  • y
  • z
)

Return current orientation fusion data in the form of a Gravity Vector per-axis. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getGravityVectors

() Std::vector float

Return current orientation fusion data in the form of a Gravity Vector per-axis as a floating point vector. update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing x, y, and z in that order.

getAccelerometer

(
  • x
  • y
  • z
)

Return uncompensated accelerometer data (non-fusion). In fusion modes, this data will be of little value. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getAccelerometer

() Std::vector float

Return current uncompensated accelerometer (non-fusion) data in the form of a floating point vector. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing x, y, and z in that order.

getMagnetometer

(
  • x
  • y
  • z
)

Return uncompensated magnetometer data (non-fusion). In fusion modes, this data will be of little value. The returned values are in micro-teslas (uT). update() must have been called prior to calling this method.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getMagnetometer

() Std::vector float

Return current uncompensated magnetometer (non-fusion) data in the form of a floating point vector. The returned values are in micro-teslas (uT). update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing x, y, and z in that order.

getGyroscope

(
  • x
  • y
  • z
)

Return uncompensated gyroscope data (non-fusion). In fusion modes, this data will be of little value. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Parameters:

  • x Float *

    Pointer to a floating point value that will have the current x component placed into it.

  • y Float *

    Pointer to a floating point value that will have the current y component placed into it.

  • z Float *

    Pointer to a floating point value that will have the current z component placed into it.

getGyroscope

() Std::vector float

Return current uncompensated gyroscope (non-fusion) data in the form of a floating point vector. By default the returned values are in meters per-second squared (m/s^2). update() must have been called prior to calling this method.

Returns:

Std::vector float :

A floating point vector containing x, y, and z in that order.

setAccelerationConfig

(
  • range
  • bw
  • pwr
)

Set the bandwidth, range, and power modes of the accelerometer. In fusion modes, these values will be ignored.

Parameters:

  • range BNO055_ACC_RANGE_T

    One of the BNO055_ACC_RANGE_T values.

  • bw BNO055_ACC_BW_T

    One of the BNO055_ACC_BW_T values.

  • pwr BNO055_ACC_PWR_MODE_T

    One of the BNO055_ACC_PWR_MODE_T values.

setMagnetometerConfig

(
  • odr
  • opr
  • pwr
)

Set the output data rate, operating mode and power mode of the magnetometer. In fusion modes, these values will be ignored.

Parameters:

  • odr BNO055_MAG_ODR_T

    One of the BNO055_MAG_ODR_T values.

  • opr BNO055_MAG_OPR_T

    One of the BNO055_MAG_OPR_T values.

  • pwr BNO055_MAG_POWER_T

    One of the BNO055_MAG_POWER_T values.

setGyroscopeConfig

(
  • range
  • bw
  • pwr
)

Set the range, bandwidth and power modes of the gyroscope. In fusion modes, these values will be ignored.

Parameters:

  • range BNO055_GYR_RANGE_T

    One of the BNO055_GYR_RANGE_T values.

  • bw BNO055_GYR_BW_T

    One of the BNO055_GYR_BW_T values.

  • pwr BNO055_GYR_POWER_MODE_T

    One of the BNO055_GYR_POWER_MODE_T values.

setAccelerometerUnits

(
  • mg
)

Set the unit of measurement for the accelerometer related sensor values. The choices are mg (milligravities) or meters per-second squared (m/s^2). The default is m/s^2.

Parameters:

  • mg Boolean

    true for mg, false for m/s^2.

setGyroscopeUnits

(
  • radians
)

Set the unit of measurement for the gyroscope related sensor values. The choices are degrees and radians. The default is degrees.

Parameters:

  • radians Boolean

    true for radians, false for degrees.

setEulerUnits

(
  • radians
)

Set the unit of measurement for the Euler Angle related sensor values. The choices are degrees and radians. The default is degrees.

Parameters:

  • radians Boolean

    true for radians, false for degrees.

resetInterruptStatus

()

Reset all interrupt status bits and interrupt output.

getInterruptStatus

() Number

Return the interrupt status register. This is a bitmask of the BNO055_INT_STA_BITS_T bits.

Returns:

Number:

a bitmask of BNO055_INT_STA_BITS_T bits.

getInterruptEnable

() Number

Return the interrupt enables register. This is a bitmask of the BNO055_INT_STA_BITS_T bits.

Returns:

Number:

a bitmask of BNO055_INT_STA_BITS_T bits currently set in the enable register.

setInterruptEnable

(
  • enables
)

Set the interrupt enable register. This is composed of a bitmask of the BNO055_INT_STA_BITS_T bits.

Parameters:

  • enables Number

    a bitmask of BNO055_INT_STA_BITS_T bits to enable

getInterruptMask

() Number

Return the interrupt mask register. This is a bitmask of the BNO055_INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.

Returns:

Number:

a bitmask of BNO055_INT_STA_BITS_T bits currently set in the interrupt mask register.

setInterruptMask

(
  • mask
)

Set the interrupt mask register. This is a bitmask of the BNO055_INT_STA_BITS_T bits. The interrupt mask is used to mask off enabled interrupts from generating a hardware interrupt. The interrupt status register can still be used to detect masked interrupts if they are enabled.

Parameters:

  • mask Number

    A bitmask of BNO055_INT_STA_BITS_T bits to set in the interrupt mask register.

getSystemStatus

() BNO055_SYS_STATUS_T

Return the value of the system status register. This method can be used to determine the overall status of the device.

Returns:

BNO055_SYS_STATUS_T:

One of the BNO055_SYS_STATUS_T values.

getSystemError

() BNO055_SYS_ERR_T

Return the value of the system error register. This mathod can be used to determine a variety of system related error conditions.

Returns:

BNO055_SYS_ERR_T:

One of the BNO055_SYS_ERR_T values.

installISR

(
  • gpio
  • level
  • isr
  • arg
)

install an interrupt handler.

Parameters:

  • gpio Number

    gpio pin to use as interrupt pin

  • level Mraa_gpio_edge_t

    the interrupt trigger level (one of mraa_gpio_edge_t values). Make sure that you have configured the interrupt pin properly for whatever level you choose.

  • isr Function

    the interrupt handler, accepting a void * argument

  • arg Void *

    the argument to pass the the interrupt handler

uninstallISR

()

uninstall a previously installed interrupt handler