readAcceleration

Read acceleration data from sensor

Description

example

[data,timestamp] = readAcceleration(BNO055Sensor) returns the acceleration as measured by the accelerometer along x-, y-, and z- axes. The function returns acceleration data with respect to the acceleration due to gravity, which is +9.8 m/s2 along the z- axis.

Examples

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 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.

tic; 
while (toc < 120)
    [status,timestamp] = readCalibrationStatus(BNO055Sensor); 
    if strcmpi(status.Accelerometer,'full')
        break; %Accelerometer is calibrated proceed further
    end
    pause(1);
end

Read acceleration data.

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

   -1.4600    0.4300   -9.6000

timestamp = datetime
   29-Jul-2019 15:47:59.835

Input Arguments

collapse all

BNO055 sensor connection, specified as an addon object.

Output Arguments

collapse all

Acceleration data in m/s2 along the x-,y-, and z- axes, returned as a 1-by-3 vector.

Data Types: double

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

Data Types: datetime

Introduced in R2019b