BNO055 problem orientation

Hello.
I bought a BNO055 . I use it with arduino Nano. I tried examples from the Adafruit and DfRobot libraries. I noticed that at every reset it indicates North (0 or 360 degrees), regardless of how the module is positioned. Please, if anyone has encountered the problem, help me to solve it. Thanks.

For informed help, please read and follow the instructions in the "How to get the best out of the forum" post.

https://forums.adafruit.com/viewtopic.php?f=19&t=164992&gclid=Cj0KCQjwyOuYBhCGARIsAIdGQRPR5rMeKIumqf5_05m3JMsskCJR3MbvoDY8OcE0cQHUvTr8lbLJutsaAvTHEALw_wcB

by gammaburst »Fri May 01, 2020 1:45 am

The reset pulse puts the BNO055 into CONFIG mode. That mode allows you to configure things, but all data reads as zero. See section 3.3.1 of the BNO055 data sheet version 1.4.

I'm trying to correct as you said...I first tried the calibration code ..https://gist.github.com/Happsson/bffb41f083b3bb2d88af2b2e27cb3372...which works ok...after that I read the section you specified and I understood the behavior of the module.
I use the DFRobot_BNO055-master library...the EulerAngleDemo example, after installing it I moved the module as in the calibration example and...it calibrated. My question is... is it possible to add a command to the code that, at the end of the calibration, displays the calibration confirmation through a print screen...?

Calibration code...

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver reads raw data from the BNO055
   Connections
   ===========
   Connect SCL to analog 5
   Connect SDA to analog 4
   Connect VDD to 3.3V DC
   Connect GROUND to common ground
   History
   =======
   2015/MAR/03  - First release (KTOWN)
*/

/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS (100)

Adafruit_BNO055 bno = Adafruit_BNO055();

/**************************************************************************/
/*
    Arduino setup function (automatically called at startup)
*/
/**************************************************************************/
void setup(void)
{
  Serial.begin(9600);
  Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");

  /* Initialise the sensor */
  if(!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }

  delay(1000);

  /* Display the current temperature */
  int8_t temp = bno.getTemp();
  Serial.print("Current Temperature: ");
  Serial.print(temp);
  Serial.println(" C");
  Serial.println("");

  bno.setExtCrystalUse(true);

  Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated");
}

void showCalibrationValues(){
    adafruit_bno055_offsets_t calibrationData;
    bno.getSensorOffsets(calibrationData);
    Serial.println("//----Add this code to your setup funciton, after bno is initialized----");
    Serial.println("adafruit_bno055_offsets_t calibrationData;");
    Serial.print("calibrationData.accel_offset_x = "); Serial.print(calibrationData.accel_offset_x); Serial.println(";");
    Serial.print("calibrationData.accel_offset_y = "); Serial.print(calibrationData.accel_offset_y); Serial.println(";");
    Serial.print("calibrationData.accel_offset_z = "); Serial.print(calibrationData.accel_offset_z); Serial.println(";");
    Serial.print("calibrationData.gyro_offset_x = "); Serial.print(calibrationData.gyro_offset_x); Serial.println(";");
    Serial.print("calibrationData.gyro_offset_y = "); Serial.print(calibrationData.gyro_offset_y); Serial.println(";");
    Serial.print("calibrationData.gyro_offset_z = "); Serial.print(calibrationData.gyro_offset_z); Serial.println(";");
    Serial.print("calibrationData.mag_offset_z = "); Serial.print(calibrationData.accel_offset_z); Serial.println(";");
    Serial.print("calibrationData.mag_offset_x = "); Serial.print(calibrationData.gyro_offset_x); Serial.println(";");
    Serial.print("calibrationData.mag_offset_y = "); Serial.print(calibrationData.gyro_offset_y); Serial.println(";");
    Serial.print("calibrationData.accel_radius = "); Serial.print(calibrationData.accel_radius); Serial.println(";");
    Serial.print("calibrationData.mag_radius = "); Serial.print(calibrationData.mag_radius); Serial.println(";");
    Serial.println("bno.setSensorOffsets(calibrationData);"); 
    while(1){
      //Stop here, let user copy and paste the code in peace. 
    }
    
}

/**************************************************************************/
/*
    Arduino loop function, called once 'setup' is complete (your own code
    should go here)
*/
/**************************************************************************/
void loop(void)
{
  // Possible vector values can be:
  // - VECTOR_ACCELEROMETER - m/s^2
  // - VECTOR_MAGNETOMETER  - uT
  // - VECTOR_GYROSCOPE     - rad/s
  // - VECTOR_EULER         - degrees
  // - VECTOR_LINEARACCEL   - m/s^2
  // - VECTOR_GRAVITY       - m/s^2
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);

  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(euler.x());
  Serial.print(" Y: ");
  Serial.print(euler.y());
  Serial.print(" Z: ");
  Serial.print(euler.z());
  Serial.print("\t\t");

  /*
  // Quaternion data
  imu::Quaternion quat = bno.getQuat();
  Serial.print("qW: ");
  Serial.print(quat.w(), 4);
  Serial.print(" qX: ");
  Serial.print(quat.y(), 4);
  Serial.print(" qY: ");
  Serial.print(quat.x(), 4);
  Serial.print(" qZ: ");
  Serial.print(quat.z(), 4);
  Serial.print("\t\t");
  */

  /* Display calibration status for each sensor. */
  uint8_t system, gyro, accel, mag = 0;
  bno.getCalibration(&system, &gyro, &accel, &mag);
  Serial.print("CALIBRATION: Sys=");
  Serial.print(system, DEC);
  Serial.print(" Gyro=");
  Serial.print(gyro, DEC);
  Serial.print(" Accel=");
  Serial.print(accel, DEC);
  Serial.print(" Mag=");
  Serial.println(mag, DEC);
  if(system == 3 && gyro == 3 && accel == 3 && mag == 3){
    showCalibrationValues();
    
  }

  delay(BNO055_SAMPLERATE_DELAY_MS);
}

Euler Angle code

/*
 * file EulerAngleDemo.ino
 *
 * @ https://github.com/DFRobot/DFRobot_BNO055
 *
 * connect BNO055 I2C interface with your board (please reference board compatibility)
 *
 * Gets the Euler angle of the current sensor and prints it out through the serial port.
 *
 *
 * version  V0.1
 * date  2018-1-8
 */
 
#include <Wire.h> 
#include "DFRobot_BNO055.h"

DFRobot_BNO055 mpu;
void setup() 
{
   Serial.begin(115200);
   while (!mpu.init())
   {
     Serial.println("ERROR! Unable to initialize the chip!");
     delay(50);
   }
//   mpu.setMode(mpu.eNORMAL_POWER_MODE, mpu.eFASTEST_MODE);
   delay(100);
   Serial.println("Read euler angles...");
}

void loop() 
{
  mpu.readEuler();  /* read euler angle */
  
  Serial.print("yaw: "); 
  Serial.print(mpu.EulerAngles.x, 3); 
  Serial.print("  "); 
  
  Serial.print("pitch:"); 
  Serial.print(mpu.EulerAngles.y, 3); 
  Serial.print("  ");
  
  Serial.print("roll: "); 
  Serial.print(mpu.EulerAngles.z, 3); 
  Serial.println("  ");
  
  delay(200);
}

Thank you for your patience.

You can read out and print the contents of the calibration registers at any time.

Also write to them, of course, but it is not possible to turn off the automatic (re)calibration process.

Maybe I wasn't understood, I wanted ... using the EulerAngleDemo example, after I move the module and it calibrates, to have a confirmation in the console.
Anyway, thank you for your time

Read out the calibration flag register, and print it to the console. Tutorial here: Device Calibration | Adafruit BNO055 Absolute Orientation Sensor | Adafruit Learning System

Thank you again...
All the respect.

Hello.
I come back with a question, how can I change the BNO map, from 0-360 degrees to -180 - 0 +180 degrees.
0 = North.
I tried this line...
if (Compass >= 0.0) Compass = Compass-180.0;
the result is 0 to 180 and -180 to 0.
180 = North
Thank you.

If North is to remain 0

if (Compass >= 180.0) Compass = 360.0 - Compass;

Edit: should be (see reply below):

if (Compass >= 180.0) Compass = Compass - 360.0;

1 Like

I was also inspired by a post of yours.
Thank you for the quick reply.
I think that maybe I need 0 to - 180 and 0 to + 180, for steering control.

For steering control, most people use the intended direction (the bearing) as zero, rather than North.

For PID steering, the error term is heading - bearing, or the other way around, if you like.

1 Like

I changed it like this...
if (Compass >= 180.0) Compass = Compass - 360; and I got what I wanted, it remains to try both options.
And I use "0" which means magnetic north.
I have read many of your answers on this topic and I take them into account.
Thank you.

That is correct, I wasn't thinking clearly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.