readMagneticField
Read one sample of magnetic field strength from BNO055 sensor
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
[
returns the magnetic field along x, y, and z axes of the BNO055 sensor as a 3-by-1
vector read from the sensor in units of µT (microtesla) along with the
magReadings
,timestamp
] = readMagneticField(bno055
)timestamp
. In ndof
mode, the elements of
the vector represent calibrated values, whereas in amg
mode, the
elements represent raw values.
Examples
Read Magnetic Field Strength from Sensor in NDOF Mode
Create an arduino
object
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the BNO055 sensor object.
imu = bno055(a,'OperatingMode','ndof');
Calibrate the sensor using steps mentioned in Calibrate BNO055 Sensors
tic; while (toc < 120) [status,timestamp] = readCalibrationStatus(BNO055Sensor); if strcmpi(status.Magnetometer,'full') break; %If Magnetometer is calibrated proceed further end pause(1); end
Read angular velocity data.
[magReadings,timestamp] = readMagneticField(imu)
magReadings = 3×1 9.5625 18.1875 23.0625 timestamp = datetime 21-Jul-2020 15:00:24.753
Read Magnetic Field Strength from Sensor in AMG Mode
Create an arduino
object
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the BNO055 sensor object.
imu = bno055(a,'OperatingMode','amg');
Read angular velocity data.
[magReadings,timestamp] = readMagneticField(imu)
magReadings = 16.2797 9.1711 -19.0969 timestamp = datetime 21-Jul-2020 15:00:24.753
Input Arguments
Output Arguments
More About
Version History
Introduced in R2019a
See Also
bno055
| flush
| info
| read
| readAcceleration
| readAngularVelocity
| readCalibrationStatus
| readOrientation
| release