Main Content


Read angular velocity from sensor



[data,timestamp] = readAngularVelocity(BNO055Sensor) returns the angular velocity in rad/s along x-, y-, and z- axes.


collapse all

Create an arduino object.

arduinoObj = arduino("COM7","MKR1000","Libraries","Adafruit/BNO055")
arduinoObj = 
  arduino with properties:

                  Port: 'COM7'
                 Board: 'MKR1000'
         AvailablePins: {'D0-D14', 'A0-A6'}
  AvailableDigitalPins: {'D0-D14', 'A0-A6'}
      AvailablePWMPins: {'D0-D8', 'D10', 'A3-A4'}
   AvailableAnalogPins: {'A0-A6'}
    AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [1]
             Libraries: {'Adafruit/BNO055', 'I2C'}

Create a BNO055Sensor object.

BNO055Sensor = addon(arduinoObj,'Adafruit/BNO055')
BNO055Sensor = 
  BNO055 with properties:

               SCLPin: 'D12'
               SDAPin: 'D11'
                  Bus: 0
           I2CAddress: 40 ('0x28')

Calibrate the sensor using steps mentioned in this Calibrate BNO055 Sensors.

while (toc < 50)
    [status,timestamp] = readCalibrationStatus(BNO055Sensor); 
    if strcmpi(status.Gyroscope,'full')
        break; %If Gyroscope is calibrated proceed further

Read angular velocity data.

[data,timestamp] = readAngularVelocity(BNO055Sensor)
data = 1×3

    0.0011    0.0011         0

timestamp = datetime datetime
   29-Jul-2019 14:53:36.836

Input Arguments

collapse all

BNO055 sensor connection, specified as an addon object.

Output Arguments

collapse all

Angular velocity in rad/s along x-, y-, and z- axes, returned as a 1-by-3 vector. Angular velocity is positive for a counterclockwise rotation around the axis.

Data Types: double

The time at which MATLAB® receives angular velocity data, specified as a datetime.

Data Types: datetime

Introduced in R2019b