Skip to content

Commit

Permalink
Merge pull request #105 from sparkfun/release-candidate
Browse files Browse the repository at this point in the history
v1.1.12
  • Loading branch information
PaulZC authored Jan 23, 2023
2 parents 24603cc + 8e5a9b8 commit b9b359f
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 5 deletions.
87 changes: 87 additions & 0 deletions examples/Example22-Tare/Example22-Tare.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Using the BNO080 IMU
Example : Tare function
By: Sofian Audry
Date: March 2nd, 2022
Based on: Example9-Calibrate
By: Nathan Seidle
SparkFun Electronics
Date: December 21st, 2017
SparkFun code, firmware, and software is released under the MIT License.
Please see LICENSE.md for further details.
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/14586
This example shows how to use the tare functionalities.
It is best to run a calibration before using the tare functions.
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
Hardware Connections:
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
Plug the sensor onto the shield
Serial.print it out at 115200 baud to serial monitor.
*/
#include <Wire.h>

#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
BNO080 myIMU;

void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("BNO080 Read Example");

Wire.begin();

myIMU.begin();

Wire.setClock(400000); //Increase I2C data rate to 400kHz

//Enable Game Rotation Vector output
myIMU.enableRotationVector(100); //Send data update every 100ms

//Once magnetic field is 2 or 3, run the Save DCD Now command
Serial.println(F("'t' to tare according to xyz"));
Serial.println(F("'z' to tare according to z axis only"));
Serial.println(F("'s' to save tare settings"));
Serial.println(F("'r' to reset/clear tare orientation registry"));
Serial.println(F("Output in form x, y, z, in uTesla"));
}

void loop()
{
if(Serial.available())
{
byte incoming = Serial.read();

switch (incoming) {
case 't': myIMU.tareNow(); break;
case 'z': myIMU.tareNow(true); break;
case 's': myIMU.saveTare(); break;
case 'r': myIMU.clearTare(); break;
default:;
}
}

//Look for reports from the IMU
if (myIMU.dataAvailable() == true)
{
float roll = (myIMU.getRoll()) * 180.0 / PI; // Convert roll to degrees
float pitch = (myIMU.getPitch()) * 180.0 / PI; // Convert pitch to degrees
float yaw = (myIMU.getYaw()) * 180.0 / PI; // Convert yaw / heading to degrees

Serial.print(roll, 1);
Serial.print(F(","));
Serial.print(pitch, 1);
Serial.print(F(","));
Serial.print(yaw, 1);

Serial.println();
}
}
81 changes: 81 additions & 0 deletions examples/Example23-Gravity/Example23-Gravity.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Using the BNO085 for finding the direction of gravity.
By: Anant Sharma
Date: January 23rd, 2023
SparkFun code, firmware, and software is released under the MIT License.
Please see LICENSE.md for further details.
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/14586
This example outputs a vector pointing towards the ground.
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
Hardware Connections:
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
Plug the sensor onto the shield
Serial.print it out at 9600 baud to serial monitor.
*/

#include <Wire.h>
#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
BNO080 myIMU;



void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("BNO080 Read Example");

Wire.begin();

//Are you using a ESP? Check this issue for more information: https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/16
// //=================================
// delay(100); // Wait for BNO to boot
// // Start i2c and BNO080
// Wire.flush(); // Reset I2C
// IMU.begin(BNO080_DEFAULT_ADDRESS, Wire);
// Wire.begin(4, 5);
// Wire.setClockStretchLimit(4000);
// //=================================

if (myIMU.begin() == false)
{
Serial.println("BNO080 not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
while (1);
}

Wire.setClock(400000); //Increase I2C data rate to 400kHz

myIMU.enableGravity(10); //Send data update every 50ms

Serial.println(F("Rotation vector enabled"));
Serial.println(F("Output in form i, j, k, real, accuracy"));

}

void loop() {
//Look for reports from the IMU
if (myIMU.dataAvailable() == true)
{
float gravityX = myIMU.getGravityX();
float gravityY = myIMU.getGravityY();
float gravityZ = myIMU.getGravityZ();
float gravityAccuracy = myIMU.getGravityAccuracy();

Serial.print(gravityX, 2);
Serial.print(F(","));
Serial.print(gravityY, 2);
Serial.print(F(","));
Serial.print(gravityZ, 2);
Serial.print(F(","));
Serial.print(gravityAccuracy, 2);
Serial.print(F(","));


Serial.println();
}
}
74 changes: 74 additions & 0 deletions examples/Example24-UncalibratedGyro/Example24-UncalibratedGyro.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Using the BNO080 IMU
By: Bastien Boudet
Date: February 3rd, 2022
SparkFun code, firmware, and software is released under the MIT License.
Please see LICENSE.md for further details.
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/14586
This example shows how to output the parts of the uncalibrated gyro.
It takes about 1ms at 400kHz I2C to read a record from the sensor, but we are polling the sensor continually
between updates from the sensor. Use the interrupt pin on the BNO080 breakout to avoid polling.
Hardware Connections:
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
Plug the sensor onto the shield
Serial.print it out at 115200 baud to serial monitor.
*/

#include <Wire.h>

#include "SparkFun_BNO080_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_BNO080
BNO080 myIMU;

void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("BNO080 Read Example");

Wire.begin();

myIMU.begin();

Wire.setClock(400000); //Increase I2C data rate to 400kHz

myIMU.enableUncalibratedGyro(50); //Send data update every 50ms

Serial.println(F("Uncalibrated Gyro enabled"));
Serial.println(F("Output in form x, y, z, bx, by, bz in radians per second"));
}

void loop()
{
//Look for reports from the IMU
if (myIMU.dataAvailable() == true)
{
float x = myIMU.getUncalibratedGyroX();
float y = myIMU.getUncalibratedGyroY();
float z = myIMU.getUncalibratedGyroZ();
float bx = myIMU.getUncalibratedGyroBiasX();
float by = myIMU.getUncalibratedGyroBiasY();
float bz = myIMU.getUncalibratedGyroBiasZ();


Serial.print(x, 2);
Serial.print(F(","));
Serial.print(y, 2);
Serial.print(F(","));
Serial.print(z, 2);
Serial.print(F(","));

Serial.print(bx, 2);
Serial.print(F(","));
Serial.print(by, 2);
Serial.print(F(","));
Serial.print(bz, 2);
Serial.print(F(","));

Serial.println();
}
}
22 changes: 22 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ enableARVRStabilizedRotationVector KEYWORD2
enableARVRStabilizedGameRotationVector KEYWORD2
enableAccelerometer KEYWORD2
enableGyro KEYWORD2
enableUncalibratedGyro KEYWORD2
enableGravity KEYWORD2
enableMagnetometer KEYWORD2
enableTapDetector KEYWORD2
enableStepCounter KEYWORD2
Expand Down Expand Up @@ -75,6 +77,21 @@ getGyroY KEYWORD2
getGyroZ KEYWORD2
getGyroAccuracy KEYWORD2

getUncalibratedGyro KEYWORD2
getUncalibratedGyroX KEYWORD2
getUncalibratedGyroY KEYWORD2
getUncalibratedGyroZ KEYWORD2
getUncalibratedGyroAccuracy KEYWORD2
getUncalibratedGyroBiasX KEYWORD2
getUncalibratedGyroBiasY KEYWORD2
getUncalibratedGyroBiasZ KEYWORD2

getGravity KEYWORD2
getGravityX KEYWORD2
getGravityY KEYWORD2
getGravityZ KEYWORD2
getGravityAccuracy KEYWORD2

getFastGyro KEYWORD2
getFastGyroX KEYWORD2
getFastGyroY KEYWORD2
Expand Down Expand Up @@ -102,6 +119,11 @@ saveCalibration KEYWORD2
requestCalibrationStatus KEYWORD2
calibrationComplete KEYWORD2

tareNow KEYWORD2
saveTare KEYWORD2
clearTare KEYWORD2
sendTareCommand KEYWORD2

getTapDetector KEYWORD2
getTimeStamp KEYWORD2
getStepCount KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun BNO080 Cortex Based IMU
version=1.1.11
version=1.1.12
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the SparkFun Qwiic VR IMU - BNO080/BNO085
Expand Down
Loading

0 comments on commit b9b359f

Please sign in to comment.