-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from sparkfun/release-candidate
v1.1.10
- Loading branch information
Showing
5 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Using the BNO080 IMU | ||
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 output the i/j/k/real parts of the rotation vector. | ||
https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation | ||
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(115200); | ||
Serial.println(); | ||
Serial.println("BNO080 Sleep 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.enableRotationVector(50); //Send data update every 50ms | ||
|
||
Serial.println(F("Rotation vector enabled")); | ||
Serial.println(F("Output in form i, j, k, real, accuracy")); | ||
} | ||
|
||
unsigned long lastMillis = 0; // Keep track of time | ||
bool lastPowerState = true; // Toggle between "On" and "Sleep" | ||
|
||
void loop() | ||
{ | ||
//Look for reports from the IMU | ||
if (myIMU.dataAvailable() == true) | ||
{ | ||
float quatI = myIMU.getQuatI(); | ||
float quatJ = myIMU.getQuatJ(); | ||
float quatK = myIMU.getQuatK(); | ||
float quatReal = myIMU.getQuatReal(); | ||
float quatRadianAccuracy = myIMU.getQuatRadianAccuracy(); | ||
|
||
Serial.print(quatI, 2); | ||
Serial.print(F(",")); | ||
Serial.print(quatJ, 2); | ||
Serial.print(F(",")); | ||
Serial.print(quatK, 2); | ||
Serial.print(F(",")); | ||
Serial.print(quatReal, 2); | ||
Serial.print(F(",")); | ||
Serial.print(quatRadianAccuracy, 2); | ||
Serial.print(F(",")); | ||
|
||
Serial.println(); | ||
} | ||
|
||
//Check if it is time to change the power state | ||
if (millis() > (lastMillis + 5000)) // Change state every 5 seconds | ||
{ | ||
lastMillis = millis(); // Keep track of time | ||
|
||
if (lastPowerState) // Are we "On"? | ||
{ | ||
myIMU.modeSleep(); // Put BNO to sleep | ||
} | ||
else | ||
{ | ||
myIMU.modeOn(); // Turn BNO back on | ||
} | ||
|
||
lastPowerState ^= 1; // Invert lastPowerState (using ex-or) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=SparkFun BNO080 Cortex Based IMU | ||
version=1.1.9 | ||
version=1.1.10 | ||
author=SparkFun Electronics <[email protected]> | ||
maintainer=SparkFun Electronics <sparkfun.com> | ||
sentence=Library for the SparkFun Qwiic VR IMU - BNO080/BNO085 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters