Skip to content

BNO055 Module

This module contains the driver for BOSCH BNO055 9-axis Absolute Orientation Sensor. 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 (datasheet).

class BNO055

class BNO055(i2cdrv, addr=0x28, clk=100000)

Creates an intance of a new BNO055.

Arguments:

  • i2cdrv – I2C Bus used ‘( I2C0, … )’
  • addr – Slave address, default 0x28
  • clk– Clock speed, default 100kHz

Example:

from bosch.bno055 import bno055

...

bno = bno055.BNO055(I2C0)
bno.start()
bno.init()
abs_orientation = bno.get_euler()
BNO055.init

init(mode=None)

Initialize the BNO055 setting the mode value.

Arguments: - mode – Mode value selectable from Mode table (refer to page 20 of the BNO055 datasheet), default None

BNO055.set_mode

set_mode(mode)

Sets the Mode value of the BNO055.

Arguments: mode – Mode value (refer to page 20 of the BNO055 datasheet)

Note

The BNO055 provides a variety of output signals, which can be chosen by selecting the appropriate operation mode. The table below lists the different modes and the available sensor signals.

Mode Available Library Functions
Value Name get_acc() get_magn() get_gyro() get_euler()
acc ACCONLY Yes No No No
magn MAGONLY No Yes No No
gyro GYROONLY No No Yes No
accmag ACCMAG Yes Yes No No
accgyro ACCGYRO Yes No Yes No
maggyro MAGGYRO No Yes Yes No
amg AMG No Yes Yes No
imu IMU Yes No Yes Yes
comp COMPASS Yes Yes No Yes
m4g M4G Yes Yes Yes Yes
ndof_off NDOF_FMC_OFF No Yes Yes Yes
ndof NDOF Yes Yes Yes Yes
BNO055.get_calibration_status

get_calibration_status()

Retrieves the current calibration status of the BNO055 main components:

  • System
  • Accelerometer
  • Gyroscope
  • Magnetometer

Note

Read: 3 indicates fully calibrated; 0 indicates not calibrated.

Returns [sys_cal_sts, acc_cal_sts, gyro_cal_sts, magn_cal_sts].

BNO055get_calibration

get_calibration(raw=False)

Retrieves the calibration values of the BNO055 main components (list of 11 elements):

  • Accelerometer Offset for X, Y, Z axes (values in m/s²) - list elements 0,1,2;
  • Magnetometer Offset for X, Y, Z axes (values in uT) - list elements 3,4,5;
  • Gyroscope Offset for X, Y, Z axes (values in Dps) - list elements 6,7,8;
  • Accelerometer Radius - list element 9;
  • Magnetometer Radius - list element 10.

Note

If raw parameter is set to True, returns a list of 22 raw bytes.

Returns [list of calibration values]

set_calibration

set_calibration(data, raw=False)

Sets the calibration values of the BNO055 main components.

Arguments: data – List of values (11 elements) representing the sensors offsets and radius.

Data list must follow this order:

  • Accelerometer Offset for X, Y, Z axes (values in m/s²) - list elements 0,1,2;
  • Magnetometer Offset for X, Y, Z axes (values in uT) - list elements 3,4,5;
  • Gyroscope Offset for X, Y, Z axes (values in Dps) - list elements 6,7,8;
  • Accelerometer Radius - list element 9;
  • Magnetometer Radius - list element 10.

Note

If raw parameter is set to True, following rules are required:

  • data list must have 22 elements;
  • each element must be a byte (value 0 to 255);
  • data list must be a sequence of [lsb1, msb1, lsb2, msb2, …, …];
  • data list order is the same described above (elem0 and elem1 of data list are respectively lsb and msb of accelerometer offset in x axis).
BNO055.get_acc

get_acc()

Retrieves the current absolute acceleration as a list of X, Y, Z values in m/s².

Returns [acc_x, acc_y, acc_z].

BNO055.get_gyro

get_gyro()

Retrieves the current gyroscope data reading as a list of X, Y, Z values in degrees per second.

Returns [gyro_x, gyro_y, gyro_z].

BNO055.get_magn

get_magn()

Retrieves the current magnetometer reading as a list of X, Y, Z values in micro-Teslas.

Returns [value_magn_x, value_magn_y, value_magn_z].

BNO055.get_euler

get_euler()

Retrieves the current orientation as a list of heading, roll, and pitch euler angles in degrees.

Returns [abs_or_h, abs_or_r, abs_or_p].

BNO055.get_lin_acc

get_lin_acc()

Retrieves the current linear acceleration (acceleration from movement, not from gravity) as a list of X, Y, Z values in m/s².

Returns [lin_acc_x, lin_acc_y, lin_acc_z].

BNO055.get_grav

get_grav()

Retrieves the current gravity acceleration as a list of X, Y, Z values in m/s².

Returns [grav_x, grav_y, grav_z].

BNO055.get_quaternion

get_quaternion()

Retrieves the current orientation as a list of X, Y, Z, W quaternion values.

Returns [w, x, y, z].

BNO055.get_temp

get_temp()

Retrieves the current temperature in Celtius.

Returns temp.