Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode - MATLAB & Simulink Example - MathWorks 中国 (2024)

Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode

This example shows you how to read and plot calibrated data from a Bosch Sensortec BNO055 a 9-axis absolute orientation sensor in real time. To read the orientation values directly from the BNO055 sensor, configure the sensor in the NDOF operating mode.

BNO055 is a 9-axis sensor with an integrated accelerometer, gyroscope, and magnetometer. The accelerometer measures acceleration, the gyroscope measures angular velocity, and the magnetometer measures the magnetic field along x-, y-, and z-axis. The axis of the sensor depends on the make of the sensor.

Required Products

  • MATLAB®

  • MATLAB Support Package for Arduino® Hardware

Required Hardware

  • Arduino Uno

  • Bosch BNO055 Sensor

Hardware Connection

Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode- MATLAB & Simulink Example- MathWorks 中国 (1)

Connect the SDA, SCL, GND, and the VCC pins of the BNO055 sensor to the corresponding pins on the Arduino hardware. This example uses an Arduino Uno board with the following connections:

  • SDA — A4

  • SCL — A5

  • VCC — +5V

  • GND — GND

Ensure that the connections to the sensor is intact. We recommended that you use a prototype shield and solder the sensor to it to avoid loose connections when moving the sensor. For information on debugging sensor related issues, see Troubleshooting Sensors.

Create Connection to BNO055 Sensor in NDOF Mode

Create a connection to the BNO055 sensor in the NDOF mode. Ensure that you create the arduino object with the library set to 'I2C'.

arduinoObj = arduino('COM7', 'Uno', 'Libraries', 'I2C');bno = bno055(arduinoObj, 'OperatingMode', 'ndof');

Calibrate BNO055 Sensor

Calibrate the sensor using the steps described in Calibrate BNO055 Sensors.

% Accelerometer calibration flagaccCalib = 0; % Gyroscope calibration flaggyrCalib = 0; % Magnetometer calibration flagmagCalib = 0; fprintf('Calibrating the BNO055 sensor . . . \n');while(prod([accCalib, gyrCalib, magCalib]) ~= 1) if strcmpi(bno.readCalibrationStatus.Accelerometer, "full") && isequal(accCalib, 0) accCalib = 1; fprintf('Accelerometer is calibrated! . . .\n'); end if strcmpi(bno.readCalibrationStatus.Gyroscope, "full") && isequal(gyrCalib, 0) gyrCalib = 1; fprintf('Gyroscope is calibrated! . . .\n'); end if(strcmpi(bno.readCalibrationStatus.Magnetometer, "full"))&& isequal(magCalib, 0) magCalib = 1; fprintf('Magnetometer is calibrated! . . .\n'); endendfprintf('BNO055 sensor is fully calibrated!\n');

Read Sensor Data

Read the orientation, acceleration, angular velocity, and magnetic field strength from the BNO055 sensor.

Estimate the time between consecutive read cycles.

% Provide time frame in secondssenseFrame = 60; % Measure approximate execution time of a single read cycletic;readOrientation(bno);readAcceleration(bno);readAngularVelocity(bno);readMagneticField(bno);tDelta = toc;% Number of samples to be collected in the senseFrame time framenumSamples = floor(senseFrame/tDelta); % Time vectortVector = linspace(0, senseFrame, numSamples); tCorrection = 0;recordedData = zeros(numSamples, 3, 4);

Set up the figure handles to plot the change in orientation, acceleration, and magnetic field strength as the device moves.

subplot(4, 1, 1)hold on% Create handle to Azimuth animatedline objecthAzimuth = animatedline('color', 'r', 'linewidth', 1.25); % Create handle to Pitch animatedline object hPitch = animatedline('color', 'k', 'linewidth', 1.25); % Create handle to Roll animatedline object hRoll = animatedline('color', 'b', 'linewidth', 1.25); legend('Azimuth (rad)','Pitch (rad)','Roll (rad)');ylabel('Euler Angles (rad)');xlabel('Time (s)');title('Reading Orientation of the BNO055 sensor', 'fontsize', 12);axis([0 senseFrame -6.5 6.5])grid minorhold offsubplot(4, 1, 2)hold on% Create handle to X-axis acceleration animatedline objecthAx = animatedline('color', 'r', 'linewidth', 1.25); % Create handle to Y-axis acceleration animatedline objecthAy = animatedline('color', 'k', 'linewidth', 1.25); % Create handle to Z-axis acceleration animatedline objecthAz = animatedline('color', 'b', 'linewidth', 1.25); legend('A_x (m/s^2)','A_y (m/s^2)','A_z (m/s^2)');ylabel('Acceleration (m/s^2)');xlabel('Time (s)');title('Reading Accelerometer values from BNO055 sensor', 'fontsize', 12);axis([0 senseFrame -30 30]);hold offgrid minorsubplot(4, 1, 3)% Create handle to X-axis angular velocity animatedline objecthVx = animatedline('color', 'r', 'linewidth', 1.25); % Create handle to Y-axis angular velocity animatedline objecthVy = animatedline('color', 'k', 'linewidth', 1.25); % Create handle to Z-axis angular velocity animatedline objecthVz = animatedline('color', 'b', 'linewidth', 1.25); legend('\omega_x (rad/s)','\omega_y (rad/s)','\omega_z (rad/s)');ylabel('Angular Velocity (rad/s)');xlabel('Time (s)');title('Reading Angular velocity values from BNO055 sensor', 'fontsize', 12);axis([0 senseFrame -10 10]);hold offgrid minorsubplot(4, 1, 4)% Create handle to X-axis magnetic field animatedline objecthMagx = animatedline('color', 'r', 'linewidth', 1.25); % Create handle to Y-axis magnetic field animatedline objecthMagy = animatedline('color', 'k', 'linewidth', 1.25); % Create handle to Z-axis magnetic field animatedline objecthMagz = animatedline('color', 'b', 'linewidth', 1.5); legend('\mu_x (\muT)','\mu_y (\muT)','\mu_z (\muT)');ylabel('Magnetic Field (\muT)');xlabel('Time (s)');title('Reading Magnetometer values from BNO055 sensor', 'fontsize', 12);axis([0 senseFrame -50 50]);hold offgrid minor

Read and plot the calibrated data from the sensor.

for i = 1:numSamples % Read Orientation values (Euler angles) from the sensor [sensorVal, ~] = readOrientation(bno); % Read Acceleration values from the sensor [AccelVal, ~] = readAcceleration(bno); % Read Angular velocity values from the sensor [AngVelVal, ~] = readAngularVelocity(bno); % Read Magnetic field strength values from the sensor [MagVal, ~] = readMagneticField(bno); tic; addpoints(hAzimuth, tVector(i) + tCorrection,sensorVal(1)); addpoints(hPitch, tVector(i) + tCorrection,sensorVal(2)); addpoints(hRoll, tVector(i) + tCorrection,sensorVal(3)); addpoints(hAx, tVector(i) + tCorrection, AccelVal(1)); addpoints(hAy, tVector(i) + tCorrection, AccelVal(2)); addpoints(hAz, tVector(i) + tCorrection, AccelVal(3)); addpoints(hVx, tVector(i) + tCorrection, AngVelVal(1)); addpoints(hVy, tVector(i) + tCorrection, AngVelVal(2)); addpoints(hVz, tVector(i) + tCorrection, AngVelVal(3)); addpoints(hMagx, tVector(i) + tCorrection, MagVal(1)); addpoints(hMagy, tVector(i) + tCorrection, MagVal(2)); addpoints(hMagz, tVector(i) + tCorrection, MagVal(3)); recordedData(i, :, 1) = sensorVal; recordedData(i, :, 2) = AccelVal; recordedData(i, :, 3) = AngVelVal; recordedData(i, :, 4) = MagVal; tCorrection = toc; drawnow;end
Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode- MATLAB & Simulink Example- MathWorks 中国 (2)

Clean Up

When the connection is no longer needed, release and clear the objects.

release(bno);clear arduinoObj;clear bno;

MATLAB 命令

您点击的链接对应于以下 MATLAB 命令:

 

请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。

Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode- MATLAB & Simulink Example- MathWorks 中国 (3)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

Europe

Asia Pacific

Contact your local office

Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode
- MATLAB & Simulink Example
- MathWorks 中国 (2024)

FAQs

How does BNO055 work? ›

BNO055 is a 9-axis sensor with an integrated accelerometer, gyroscope, and magnetometer. The accelerometer measures acceleration, the gyroscope measures angular velocity, and the magnetometer measures the magnetic field along x-, y-, and z-axis. The axis of the sensor depends on the make of the sensor.

What is the range of the accelerometer on the BNO055? ›

BNO055 Accelerometer: Acceleration ranges ±2g/±4g/±8g/±16. Low-pass filter bandwidths 1kHz~<8Hz. Operation modes: normal, suspend, low power, standby, deep suspend.

How to use BNO055 with raspberry pi? ›

You'll need to connect the PS1 pin from the top row to 3.3V power to put the BNO055 into UART mode. Once in UART mode the BNO055's SCL and SDA pins will become serial RX and TX pins. When using a serial UART device with the Raspberry Pi you'll need to make sure you disable the kernel's use of the Pi's serial port.

How accurate is the BNO055 magnetometer? ›

The BNO055 is accurate to +/- 1 degree at best, so "jumps" of 0.3 degrees are meaningless. It has a built in sensor fusion algorithm, and I doubt if you could improve on it by external manipulations. However, you could average a number of readings and display those.

References

Top Articles
Johnny Cash fans treated to batch of unreleased songs in new posthumous album
(Kreuz-König) &quot;Alexandre&quot; - King of Clubs / Roi de trèfle / playing card carte …
Ron Martin Realty Cam
Toyota Campers For Sale Craigslist
What Happened To Dr Ray On Dr Pol
Black Gelato Strain Allbud
How Much Is 10000 Nickels
Urinevlekken verwijderen: De meest effectieve methoden - Puurlv
Campaign Homecoming Queen Posters
Day Octopus | Hawaii Marine Life
Olivia Ponton On Pride, Her Collection With AE & Accidentally Coming Out On TikTok
Kinkos Whittier
Meritas Health Patient Portal
Mani Pedi Walk Ins Near Me
Cambridge Assessor Database
Quadcitiesdaily
Iroquois Amphitheater Louisville Ky Seating Chart
Canvasdiscount Black Friday Deals
Getmnapp
Sensual Massage Grand Rapids
Jurassic World Exhibition Discount Code
Grave Digger Wynncraft
Phoenixdabarbie
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Where to eat: the 50 best restaurants in Freiburg im Breisgau
Toonkor211
Sinfuldeed Leaked
Die wichtigsten E-Nummern
Hoofdletters voor God in de NBV21 - Bijbelblog
Dubois County Barter Page
Aladtec Login Denver Health
Soiza Grass
Great Clips On Alameda
Workday Latech Edu
Darrell Waltrip Off Road Center
Kelsey Mcewen Photos
Devotion Showtimes Near Mjr Universal Grand Cinema 16
How to Destroy Rule 34
Collier Urgent Care Park Shore
Poe Flameblast
NHL training camps open with Swayman's status with the Bruins among the many questions
South Bend Tribune Online
The All-New MyUMobile App - Support | U Mobile
Wal-Mart 140 Supercenter Products
Patricia And Aaron Toro
Swsnj Warehousing Inc
Playboi Carti Heardle
Www.homedepot .Com
Join MileSplit to get access to the latest news, films, and events!
Vrca File Converter
7 Sites to Identify the Owner of a Phone Number
Worlds Hardest Game Tyrone
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 5481

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.