Skip to content

Commit b9b359f

Browse files
authored
Merge pull request #105 from sparkfun/release-candidate
v1.1.12
2 parents 24603cc + 8e5a9b8 commit b9b359f

File tree

7 files changed

+472
-5
lines changed

7 files changed

+472
-5
lines changed
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Using the BNO080 IMU
3+
4+
Example : Tare function
5+
By: Sofian Audry
6+
Date: March 2nd, 2022
7+
8+
Based on: Example9-Calibrate
9+
By: Nathan Seidle
10+
SparkFun Electronics
11+
Date: December 21st, 2017
12+
SparkFun code, firmware, and software is released under the MIT License.
13+
Please see LICENSE.md for further details.
14+
15+
Feel like supporting our work? Buy a board from SparkFun!
16+
https://www.sparkfun.com/products/14586
17+
18+
This example shows how to use the tare functionalities.
19+
It is best to run a calibration before using the tare functions.
20+
21+
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
22+
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
23+
24+
Hardware Connections:
25+
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
26+
Plug the sensor onto the shield
27+
Serial.print it out at 115200 baud to serial monitor.
28+
*/
29+
#include <Wire.h>
30+
31+
#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
32+
BNO080 myIMU;
33+
34+
void setup()
35+
{
36+
Serial.begin(115200);
37+
Serial.println();
38+
Serial.println("BNO080 Read Example");
39+
40+
Wire.begin();
41+
42+
myIMU.begin();
43+
44+
Wire.setClock(400000); //Increase I2C data rate to 400kHz
45+
46+
//Enable Game Rotation Vector output
47+
myIMU.enableRotationVector(100); //Send data update every 100ms
48+
49+
//Once magnetic field is 2 or 3, run the Save DCD Now command
50+
Serial.println(F("'t' to tare according to xyz"));
51+
Serial.println(F("'z' to tare according to z axis only"));
52+
Serial.println(F("'s' to save tare settings"));
53+
Serial.println(F("'r' to reset/clear tare orientation registry"));
54+
Serial.println(F("Output in form x, y, z, in uTesla"));
55+
}
56+
57+
void loop()
58+
{
59+
if(Serial.available())
60+
{
61+
byte incoming = Serial.read();
62+
63+
switch (incoming) {
64+
case 't': myIMU.tareNow(); break;
65+
case 'z': myIMU.tareNow(true); break;
66+
case 's': myIMU.saveTare(); break;
67+
case 'r': myIMU.clearTare(); break;
68+
default:;
69+
}
70+
}
71+
72+
//Look for reports from the IMU
73+
if (myIMU.dataAvailable() == true)
74+
{
75+
float roll = (myIMU.getRoll()) * 180.0 / PI; // Convert roll to degrees
76+
float pitch = (myIMU.getPitch()) * 180.0 / PI; // Convert pitch to degrees
77+
float yaw = (myIMU.getYaw()) * 180.0 / PI; // Convert yaw / heading to degrees
78+
79+
Serial.print(roll, 1);
80+
Serial.print(F(","));
81+
Serial.print(pitch, 1);
82+
Serial.print(F(","));
83+
Serial.print(yaw, 1);
84+
85+
Serial.println();
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
Using the BNO085 for finding the direction of gravity.
3+
By: Anant Sharma
4+
5+
Date: January 23rd, 2023
6+
SparkFun code, firmware, and software is released under the MIT License.
7+
Please see LICENSE.md for further details.
8+
Feel like supporting our work? Buy a board from SparkFun!
9+
https://www.sparkfun.com/products/14586
10+
This example outputs a vector pointing towards the ground.
11+
12+
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
13+
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
14+
15+
Hardware Connections:
16+
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
17+
Plug the sensor onto the shield
18+
19+
Serial.print it out at 9600 baud to serial monitor.
20+
*/
21+
22+
#include <Wire.h>
23+
#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
24+
BNO080 myIMU;
25+
26+
27+
28+
void setup() {
29+
Serial.begin(9600);
30+
Serial.println();
31+
Serial.println("BNO080 Read Example");
32+
33+
Wire.begin();
34+
35+
//Are you using a ESP? Check this issue for more information: https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/16
36+
// //=================================
37+
// delay(100); // Wait for BNO to boot
38+
// // Start i2c and BNO080
39+
// Wire.flush(); // Reset I2C
40+
// IMU.begin(BNO080_DEFAULT_ADDRESS, Wire);
41+
// Wire.begin(4, 5);
42+
// Wire.setClockStretchLimit(4000);
43+
// //=================================
44+
45+
if (myIMU.begin() == false)
46+
{
47+
Serial.println("BNO080 not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
48+
while (1);
49+
}
50+
51+
Wire.setClock(400000); //Increase I2C data rate to 400kHz
52+
53+
myIMU.enableGravity(10); //Send data update every 50ms
54+
55+
Serial.println(F("Rotation vector enabled"));
56+
Serial.println(F("Output in form i, j, k, real, accuracy"));
57+
58+
}
59+
60+
void loop() {
61+
//Look for reports from the IMU
62+
if (myIMU.dataAvailable() == true)
63+
{
64+
float gravityX = myIMU.getGravityX();
65+
float gravityY = myIMU.getGravityY();
66+
float gravityZ = myIMU.getGravityZ();
67+
float gravityAccuracy = myIMU.getGravityAccuracy();
68+
69+
Serial.print(gravityX, 2);
70+
Serial.print(F(","));
71+
Serial.print(gravityY, 2);
72+
Serial.print(F(","));
73+
Serial.print(gravityZ, 2);
74+
Serial.print(F(","));
75+
Serial.print(gravityAccuracy, 2);
76+
Serial.print(F(","));
77+
78+
79+
Serial.println();
80+
}
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Using the BNO080 IMU
3+
By: Bastien Boudet
4+
Date: February 3rd, 2022
5+
SparkFun code, firmware, and software is released under the MIT License.
6+
Please see LICENSE.md for further details.
7+
8+
Feel like supporting our work? Buy a board from SparkFun!
9+
https://www.sparkfun.com/products/14586
10+
11+
This example shows how to output the parts of the uncalibrated gyro.
12+
13+
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
14+
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
15+
16+
Hardware Connections:
17+
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
18+
Plug the sensor onto the shield
19+
Serial.print it out at 115200 baud to serial monitor.
20+
*/
21+
22+
#include <Wire.h>
23+
24+
#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
25+
BNO080 myIMU;
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
Serial.println();
31+
Serial.println("BNO080 Read Example");
32+
33+
Wire.begin();
34+
35+
myIMU.begin();
36+
37+
Wire.setClock(400000); //Increase I2C data rate to 400kHz
38+
39+
myIMU.enableUncalibratedGyro(50); //Send data update every 50ms
40+
41+
Serial.println(F("Uncalibrated Gyro enabled"));
42+
Serial.println(F("Output in form x, y, z, bx, by, bz in radians per second"));
43+
}
44+
45+
void loop()
46+
{
47+
//Look for reports from the IMU
48+
if (myIMU.dataAvailable() == true)
49+
{
50+
float x = myIMU.getUncalibratedGyroX();
51+
float y = myIMU.getUncalibratedGyroY();
52+
float z = myIMU.getUncalibratedGyroZ();
53+
float bx = myIMU.getUncalibratedGyroBiasX();
54+
float by = myIMU.getUncalibratedGyroBiasY();
55+
float bz = myIMU.getUncalibratedGyroBiasZ();
56+
57+
58+
Serial.print(x, 2);
59+
Serial.print(F(","));
60+
Serial.print(y, 2);
61+
Serial.print(F(","));
62+
Serial.print(z, 2);
63+
Serial.print(F(","));
64+
65+
Serial.print(bx, 2);
66+
Serial.print(F(","));
67+
Serial.print(by, 2);
68+
Serial.print(F(","));
69+
Serial.print(bz, 2);
70+
Serial.print(F(","));
71+
72+
Serial.println();
73+
}
74+
}

keywords.txt

+22
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ enableARVRStabilizedRotationVector KEYWORD2
3939
enableARVRStabilizedGameRotationVector KEYWORD2
4040
enableAccelerometer KEYWORD2
4141
enableGyro KEYWORD2
42+
enableUncalibratedGyro KEYWORD2
43+
enableGravity KEYWORD2
4244
enableMagnetometer KEYWORD2
4345
enableTapDetector KEYWORD2
4446
enableStepCounter KEYWORD2
@@ -75,6 +77,21 @@ getGyroY KEYWORD2
7577
getGyroZ KEYWORD2
7678
getGyroAccuracy KEYWORD2
7779

80+
getUncalibratedGyro KEYWORD2
81+
getUncalibratedGyroX KEYWORD2
82+
getUncalibratedGyroY KEYWORD2
83+
getUncalibratedGyroZ KEYWORD2
84+
getUncalibratedGyroAccuracy KEYWORD2
85+
getUncalibratedGyroBiasX KEYWORD2
86+
getUncalibratedGyroBiasY KEYWORD2
87+
getUncalibratedGyroBiasZ KEYWORD2
88+
89+
getGravity KEYWORD2
90+
getGravityX KEYWORD2
91+
getGravityY KEYWORD2
92+
getGravityZ KEYWORD2
93+
getGravityAccuracy KEYWORD2
94+
7895
getFastGyro KEYWORD2
7996
getFastGyroX KEYWORD2
8097
getFastGyroY KEYWORD2
@@ -102,6 +119,11 @@ saveCalibration KEYWORD2
102119
requestCalibrationStatus KEYWORD2
103120
calibrationComplete KEYWORD2
104121

122+
tareNow KEYWORD2
123+
saveTare KEYWORD2
124+
clearTare KEYWORD2
125+
sendTareCommand KEYWORD2
126+
105127
getTapDetector KEYWORD2
106128
getTimeStamp KEYWORD2
107129
getStepCount KEYWORD2

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun BNO080 Cortex Based IMU
2-
version=1.1.11
2+
version=1.1.12
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for the SparkFun Qwiic VR IMU - BNO080/BNO085

0 commit comments

Comments
 (0)