read
Read acceleration, angular velocity, magnetic field, time, and overrun data from BNO055 sensor
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Syntax
Description
[
returns the acceleration, magnetic field, angular velocity, and overrun data from
BNO055 in the sensorReadings,overrun] = read(bno055)timetable format. The number of samples depends on
the SamplesPerRead value specified while creating the sensor
object. These output arguments are returned only when the output format is set to
timetable.
[
returns matrices of acceleration, gyroscope, magnetic field, orientation, time
stamps, and overrun data in AMG mode. The number of samples depends on the
accelReadings, gyroReadings, magReadings, timeStamps, overrun] = read(bno055)SamplesPerRead value specified while creating the sensor
object. These output arguments are returned only when the output format is set to
matrix.
[
returns matrices of acceleration, gyroscope, magnetic field, time stamps, and
overrun data in NDOF mode. The number of samples depends on the
accelReadings, gyroReadings, magReadings, orientationReadings,timeStamps, overrun] = read(bno055)SamplesPerRead value specified while creating the sensor
object. These output arguments are returned only when the output format is set to
matrix.Calibrate BNO055 Sensors before using
the read to ensure accurate values are read from sensor in NDOF operating
mode.
Examples
Read Data from Sensor in NDOF Mode as a Timetable
Create an arduino object.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create a sensor object with additional properties.
imu = bno055(a,'OperatingMode','ndof','SamplesPerRead',5,'ReadMode','Latest')
Calibrate the sensor using steps mentioned in Calibrate BNO055 Sensors. Read five
samples of sensor data in datetime format.
sensorReadings = read(imu)
sensorReadings =
5×4 timetable
Time Acceleration AngularVelocity MagneticField Orientation
________________________ _______________________ ______________________________________ ____________________________ ___________________________
21-Jul-2020 16:24:25.538 0 0.35 9.82 0.0032725 -0.0054542 -0.0021817 24.25 -19.375 -2.75 0 -0.035997 0.0021817
21-Jul-2020 16:24:25.548 -0.05 0.32 9.84 -0.0021817 0.0010908 0.0010908 24.25 -19.375 -2.75 0 -0.035997 0.0021817
21-Jul-2020 16:24:25.558 -0.03 0.32 9.75 -0.0010908 0.0010908 -0.0010908 24.25 -19.375 -2.75 0 -0.035997 0.0021817
21-Jul-2020 16:24:25.568 0 0.34 9.82 0.0010908 -0.0021817 0 24.25 -19.375 -2.75 0 -0.035997 0.0021817
21-Jul-2020 16:24:25.578 0 0.36 9.77 0.006545 -0.0010908 -0.0021817 23.063 -20.188 -3.5625 0 -0.035997 0.0021817
Read Data from Sensor in AMG Mode as a Timetable
Create an arduino object.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create a sensor object with additional properties.
imu = bno055(a,'OperatingMode','amg','SampleRate',100,'SamplesPerRead',5)
Read five samples of sensor data in datetime format.
sensorReadings = read(imu)
sensorReadings =
5×3 timetable
Time Acceleration AngularVelocity MagneticField
________________________ _______________________ ______________________________________ ____________________________
21-Jul-2020 16:29:51.323 -0.02 0.32 9.87 0.0032725 -0.01309 0.0021817 24.25 -18.375 -4
21-Jul-2020 16:29:51.333 -0.02 0.32 9.87 0.0032725 -0.0032725 0.0021817 24.25 -18.375 -4
21-Jul-2020 16:29:51.343 0.02 0.35 9.82 -0.0032725 0.0076358 0.0032725 24.25 -18.375 -4
21-Jul-2020 16:29:51.353 0.02 0.35 9.82 -0.0032725 0.0021817 0.0010908 23.125 -19.438 -4
21-Jul-2020 16:29:51.363 -0.03 0.32 9.86 0 -0.0098175 0.0010908 23.125 -19.438 -4
Read Data from Sensor in NDOF Mode as a Matrix
Create an arduino object.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create a sensor object with additional properties.
imu = bno055(a,’SamplesPerRead’,5,’OutputFormat’,’matrix’,’OperatingMode’,’ndof’)
Calibrate the sensor using steps mentioned in Calibrate BNO055 Sensors. Read five samples of sensor data as a matrix.
[accelReadings, gyroReadings, magReadings, orientationReadings,timeStamps, overrun] = read(imu)
accelReadings =
-0.0400 0.3000 9.7500
-0.0500 0.3100 9.8400
-0.0200 0.3300 9.8100
0 0.3400 9.8800
-0.0400 0.3200 9.7700
gyroReadings =
0 0.0098 -0.0011
-0.0022 0.0055 0.0011
0.0022 -0.0022 0
-0.0011 -0.0022 0.0011
-0.0022 -0.0022 -0.0011
magReadings =
23.8750 -20.5625 -4.0000
23.8750 -20.5625 -4.0000
23.8750 -20.5625 -4.0000
23.0625 -20.8750 -4.7500
23.0625 -20.8750 -4.7500
orientationReadings =
0 -0.0338 0.0022
0 -0.0338 0.0022
0 -0.0338 0.0022
0 -0.0338 0.0022
0 -0.0338 0.0022
timeStamps =
5×1 datetime array
31-Jul-2020 19:10:07.196
31-Jul-2020 19:10:07.206
31-Jul-2020 19:10:07.216
31-Jul-2020 19:10:07.226
31-Jul-2020 19:10:07.236
overrun =
10
Read Data from Sensor in AMG Mode as a Matrix
Create an arduino object.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create a sensor object with additional properties.
imu = bno055(a,’SamplesPerRead’,5,’OutputFormat’,’matrix’,’OperatingMode’,’amg’)
Read five samples of sensor data as a matrix.
[accelReadings, gyroReadings, magReadings, orientationReadings,timeStamps, overrun] = read(imu)
accelReadings =
-0.0400 0.3000 9.7500
-0.0500 0.3100 9.8400
-0.0200 0.3300 9.8100
0 0.3400 9.8800
-0.0400 0.3200 9.7700
gyroReadings =
0 0.0098 -0.0011
-0.0022 0.0055 0.0011
0.0022 -0.0022 0
-0.0011 -0.0022 0.0011
-0.0022 -0.0022 -0.0011
magReadings =
23.8750 -20.5625 -4.0000
23.8750 -20.5625 -4.0000
23.8750 -20.5625 -4.0000
23.0625 -20.8750 -4.7500
23.0625 -20.8750 -4.7500
timeStamps =
5×1 datetime array
31-Jul-2020 19:10:07.196
31-Jul-2020 19:10:07.206
31-Jul-2020 19:10:07.216
31-Jul-2020 19:10:07.226
31-Jul-2020 19:10:07.236
overrun =
10
Input Arguments
Output Arguments
More About
Version History
Introduced in R2019a
See Also
bno055 | flush | info | readAcceleration | readAngularVelocity | readCalibrationStatus | readMagneticField | readOrientation | release