11-15-2022 06:33 PM
Hello,
I am using two BNO055 sensors, and I just want to get the raw data from the accelerometer and gyroscope for my project. Randomly, one or both of the senors will suddenly start to display all zeros (see image below).
I am assuming this is occuring because the device is put into suspension mode, but I do not know what would cause this. My code is below for reference.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <EEPROM.h>
Adafruit_BNO055 bnoA = Adafruit_BNO055(-1, BNO055_ADDRESS_A);
Adafruit_BNO055 bnoB = Adafruit_BNO055(-1, BNO055_ADDRESS_B);
#define BNO055_SAMPLERATE_DELAY_MS (100)
/**************************************************************************/
/* Non-Fusion
* Configuration mode = CONFIG (default)
* Accel and gyro = ACCGYRO
* Initialize and Calibrate IMU */
/**************************************************************************/
void setup(void)
{
Serial.begin(115200);
bnoA.begin(OPERATION_MODE_ACCGYRO);
bnoA.setExtCrystalUse(true);
bnoA.setRanges();
bnoB.begin(OPERATION_MODE_ACCGYRO);
bnoB.setExtCrystalUse(true);
bnoB.setRanges();
delay(500);
}
void loop(void)
{
//Functions to retrieve and send serial data
getAcc();
getGyro();
delay(BNO055_SAMPLERATE_DELAY_MS);
}
void getAcc() {
double xA = -1000, yA = -1000 , zA = -1000 , xB = -1000 , yB = -1000 , zB = -1000; //dumb values, easy to spot problem
imu::Vector<3> accA = bnoA.getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);
xA = accA.x();
yA = accA.y();
zA = accA.z();
imu::Vector<3> accB = bnoB.getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);
xB = accB.x();
yB = accB.y();
zB = accB.z();
Serial.print("Acc 1:");
Serial.print(" | x= ");
Serial.print(xA);
Serial.print(" | y= ");
Serial.print(yA);
Serial.print(" | z= ");
Serial.print(zA);
Serial.print(" | Acc 2:");
Serial.print(" | x= ");
Serial.print(xB);
Serial.print(" | y= ");
Serial.print(yB);
Serial.print(" | z= ");
Serial.print(zB);
}
void getGyro() {
double xA = -1000, yA = -1000 , zA = -1000 , xB = -1000 , yB = -1000 , zB = -1000;
imu::Vector<3> gyroA = bnoA.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
xA = gyroA.x();
yA = gyroA.y();
zA = gyroA.z();
imu::Vector<3> gyroB = bnoB.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
xB = gyroB.x();
yB = gyroB.y();
zB = gyroB.z();
Serial.print(" | Gyro 1:");
Serial.print(" | x= ");
Serial.print(xA);
Serial.print(" | y= ");
Serial.print(yA);
Serial.print(" | z= ");
Serial.print(zA);
Serial.print(" | Gyro 2:");
Serial.print(" | x= ");
Serial.print(xB);
Serial.print(" | y= ");
Serial.print(yB);
Serial.print(" | z= ");
Serial.println(zB);
}
11-21-2022 07:16 AM
Dear user, unfortunately this product is no longer available for new designs. Please contact one of our official distributors or sales representatives for alternative products. Thank you!