Hello everyone.
CMPS12 is a module with BNO055 sensor. Here is my code to get Eulerian angles from this module.
#include <Wire.h>
int CMPS12=0x60;
float Pitch,Roll,Yaw,Pitch_2;
void setup()
{
Serial.begin(115200);
Wire.begin();
Wire.setClock(400000); // I2C clock rate ,You can delete it but it helps the speed of I2C (default rate is 100000 Hz)
delay(100);
}
void loop()
{
Wire.beginTransmission(CMPS12);
Wire.write(0X02);
Wire.endTransmission(false);
Wire.requestFrom(CMPS12,4);
Yaw=(int16_t)(Wire.read()<<8|Wire.read())/10.00; //Two bytes Yaw in range of (0 to 359 degrees)
Pitch=((int8_t)Wire.read()); // One byte Pitch in range of (-90 to 90 degrees)
Roll=((int8_t)Wire.read()); // One byte Roll in range of (-90 to 90 degrees)
Wire.beginTransmission(CMPS12);
Wire.write(0x1C);
Wire.endTransmission(false);
Wire.requestFrom(CMPS12,2);
Pitch_2=(int16_t)(Wire.read()<<8|Wire.read()); // Two bytes Pitch in range of (-180 to 180 degrees)
//Print Euler Angles
Serial.print("Pitch= ");
Serial.print(Pitch);
Serial.print(" Roll=");
Serial.print(Roll);
Serial.print(" Yaw= ");
Serial.print(Yaw);
Serial.print(" Pitch_2= ");
Serial.println(Pitch_2);
}
NOTE: Powerup this sensor, toward the north from the heading, to prevent Yaw error or drift (As I showed in the attached picture).
Also here is my code to run Gy-955 (BNO055) through I2C connection:
https://forum.arduino.cc/index.php?topic=563091.0
And my code to run Gy-25 through serial connection:
https://forum.arduino.cc/index.php?topic=588136.0
Also I get data from MPU 6050 or GY 521 or MPU 9250 with correct measurement units here:
https://forum.arduino.cc/index.php?topic=596009.0
If you have any question, you can ask me in comments or by a pm.