Arduino/BNO055 example code not working, "Command logs are not supported for sensors. Create the hardware Object with property 'TraceOn' disabled." error.

9 views (last 30 days)
Chris Briar
Chris Briar on 26 Jan 2022
Answered: Gayatri Menon on 13 Mar 2022
Hey everyone,
I am having an error running the example code for using the arduino with the BNO055 sensor.
I have had to change the code slightly as I am connecting to a COM port as well as using an arduino Nano 3.
The code starts to run but then prompts me with the following error;
"Command logs are not supported for sensors. Create the hardware Object with property 'TraceOn' disabled."
I have removed and replaced the twi.h and twi.c folders at the following path (C:\ProgramData\MATLAB\SupportPackages\R2021a\aIDE\hardware\arduino\avr\libraries\Wire\src\utility) as suggested on another mathworks forum for a problem with the board but the command
which returns the error prompt;
"Cannot program board Nano3 (COM5). Please make sure the board is supported and the port and board type are correct. For more information, see Arduino Hardware Troubleshooting."
The board is connected and at COM5 as confirmed by using:
I have already uninstalled/reinstalled the Arduino support package for Matlab. Still no luck.
Any advice would be greatly appreciated!
Thank you
Full example code used by me:
a = arduino('COM5', 'Nano3'); %This is the part of the code that I changed
%a = arduino('btspp://001908361009'); %Original example code
fs = 100; % Sample Rate in Hz
imu = bno055(a,'SampleRate',fs,'OutputFormat','matrix','OperatingMode','amg');
ts = tic;
stopTimer = 50;
while(toc(ts) < stopTimer)
% Rotate the sensor along x axis from 0 to 360 degree.
% Take 2-3 rotations to improve accuracy.
% For other axes, rotate along that axes.
[accel,gyro,mag] = read(imu);
magReadings = [magReadings;mag];
[A, b] = magcal(magReadings); % A = 3x3 matrix for soft iron correction
% b = 3x1 vector for hard iron correction
% GyroscopeNoise, AccelerometerNoise and MagnetometerNoise are determined from the BNO055 datasheet using the following formula
% NoisePower = OutputNoisePowerDensityrms^2 * Bandwidth
GyroscopeNoiseBNO055 = 3.05e-06; % GyroscopeNoise (variance value) in units of (rad/s)^2
AccelerometerNoiseBNO055 = 67.53e-06; % AccelerometerNoise (variance value)in units of (m/s^2)^2
MagnetometerNoiseBNO055 = 1; %MagnetometerNoise (variance value) in units of uT^2
viewer = HelperOrientationViewer('Title',{'AHRS Filter'});
FUSE = ahrsfilter('SampleRate',imu.SampleRate,'GyroscopeNoise',GyroscopeNoiseBNO055,'AccelerometerNoise',AccelerometerNoiseBNO055,'MagnetometerNoise',MagnetometerNoiseBNO055);
magx_correction = b(1);
magy_correction = b(2);
magz_correction = b(3);
ts = tic;
while(toc(ts) < stopTimer)
[accel,gyro,mag] = read(imu);
% Align coordinates in accordance with NED convention
accel = [-accel(:,1), accel(:,2), accel(:,3)];
gyro = [gyro(:,1), -gyro(:,2), -gyro(:,3)];
mag = [(mag(:,1)-magx_correction), -(mag(:,2)- magy_correction), -(mag(:,3)-magz_correction)] * A;
rotators = FUSE(accel,gyro,mag);
for j = numel(rotators)

Answers (1)

Gayatri Menon
Gayatri Menon on 13 Mar 2022
Trace is not supported for read(imu) . Create the arduino object with 'TraceOn' set as false and then try the rest of the code, the error should not be there.
a = arduino('COM9','Uno','TraceOn',false,'ForceBuild',true);
Hope this helps

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by