Go Down

Topic: Run GY-955 (BNO055) in Arduino IDE through I2C connection (Read 1 time) previous topic - next topic

Peyman_Amiri

Aug 10, 2018, 08:08 pm Last Edit: Feb 14, 2019, 11:08 am by Peyman_Amiri
Hello Everyone.
Gy-955 and BNO055 have the same German IC but different modules. When we connect GND,S1 and SR pins together for Gy-955 module, we can communicate with BNO055 directly, through I2C connection. Here I will represent my Code  to run Gy-955 (BNO055) by Arduino IDE, 3 times FASTER than BNO055.h library:

// Connect GND, S1 and SR pins together.

#include <Wire.h>
float Yaw , Roll , Pitch,magx,magy,magz,accx, accy,accz, gyrox,gyroy,gyroz,q0,q1,q2,q3,Roll2,Pitch2,Yaw2;
const int GY_955=0x29;
void setup()
{
  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);
  Wire.beginTransmission(GY_955);
  Wire.write(0x3E); // Power Mode
  Wire.write(0x00); // Normal:0X00 (or B00), Low Power: 0X01 (or B01) , Suspend Mode: 0X02 (orB10)
  Wire.endTransmission();
  delay(100);
  Wire.beginTransmission(GY_955);
  Wire.write(0x3D); // Operation Mode
  Wire.write(0x0C); //NDOF:0X0C (or B1100) , IMU:0x08 (or B1000) , NDOF_FMC_OFF: 0x0B (or B1011)
  Wire.endTransmission();
  delay(100);
  Serial.begin(115200);  //Setting the baudrate
  delay(100);
}
void loop()
{
  Wire.beginTransmission(GY_955);
  Wire.write(0x08); 
  Wire.endTransmission(false);
  Wire.requestFrom(GY_955,32,true);
  // Accelerometer
  accx=(Wire.read()|Wire.read()<<8 )/100.00; // m/s^2
  accy=(Wire.read()|Wire.read()<<8 )/100.00; // m/s^2
  accz=(Wire.read()|Wire.read()<<8 )/100.00; // m/s^2
  // Magnetometer
  magx=(Wire.read()|Wire.read()<<8 )/16.00; // mT
  magy=(Wire.read()|Wire.read()<<8 )/16.00; // mT
  magz=(Wire.read()|Wire.read()<<8 )/16.00; // mT
  // Gyroscope
  gyrox=(Wire.read()|Wire.read()<<8 )/16.00; // Dps
  gyroy=(Wire.read()|Wire.read()<<8 )/16.00; // Dps
  gyroz=(Wire.read()|Wire.read()<<8 )/16.00; // Dps
  // Euler Angles
  Yaw=(Wire.read()|Wire.read()<<8 )/16.00;  //in Degrees unit
  Roll=(Wire.read()|Wire.read()<<8 )/16.00;  //in Degrees unit
  Pitch=(Wire.read()|Wire.read()<<8 )/16.00;  //in Degrees unit
  // Quaternions
  q0=(Wire.read()|Wire.read()<<8 )/(pow(2,14)); //unit less
  q1=(Wire.read()|Wire.read()<<8 )/(pow(2,14)); //unit less
  q2=(Wire.read()|Wire.read()<<8 )/(pow(2,14)); //unit less
  q3=(Wire.read()|Wire.read()<<8 )/(pow(2,14)); //unit less
  //Convert Quaternions to Euler Angles
  Yaw2=(atan2(2*(q0*q3+q1*q2),1-2*(pow(q2,2)+pow(q3,2))))*180/PI;
  Roll2=(asin(2*(q0*q2-q3*q1)))*180/PI;
  Pitch2=(atan2(2*(q0*q1+q2*q3),1-2*(pow(q1,2)+pow(q2,2))))*180/PI;


  // Print data
  Serial.print("Yaw=");
  Serial.print(Yaw);
  Serial.print(" Roll=");
  Serial.print(Roll);
  Serial.print(" Pitch=");
  Serial.println(Pitch);
}

NOTE: Yaw, Roll and Pitch are more reliable than Yaw2, Roll2 and Pitch2.
Enjoy it!!! it is very stable and exact (0.01 degree exactness).
 
Also you can Run GY-955 through Serial connection:
https://forum.arduino.cc/index.php?topic=588569.0

I used GY-955 through Serial connection for my quadcopter, but the final result of GY-955 with I2C connection was very better in comparison to GY-955 Serial connection.

Also I used GY-25 for my quadcopter, but the final result of GY-955 through I2C connection was very better in comparison to GY-25. Here is the code to get Euler angles from 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 by 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.

jremington

#1
Aug 10, 2018, 09:46 pm Last Edit: Aug 10, 2018, 09:49 pm by jremington
Quote
6. Enjoy it!!! it is very stable and exact (0.01 degree exactness).
Extremely unlikely. Many people have given up on the BNO055, because the firmware performs so poorly. The calibration routines are very primitive, and hardly work at all. At best yaw angles are repeatable to about +/- 5 degrees.

See this page and this long discussion. The BNO080 is reported to work a bit better, but still has a long way to go.

I recommend RTImulib with Pololu's Altimu10 or Altimu9 instead.

Peyman_Amiri

#2
Aug 10, 2018, 09:55 pm Last Edit: Feb 13, 2019, 04:30 pm by Peyman_Amiri
I used this sensor with this code. It reports roll, pitch and yaw exactly good and without noise. Also it works very good on my big quadcopter.

jremington

#3
Aug 10, 2018, 10:00 pm Last Edit: Aug 10, 2018, 10:01 pm by jremington
Please prove the "exactness", after reading the articles I linked.

Many other people would be interested if you can demonstrate accurate results. But I will bet that you can't.

Peyman_Amiri

Yes, I can show it. Do I send a clip about its exactness?

jremington

No clips, just post the results, and all the important details about how you calibrated the sensor and determined the accuracy of the angles.

For your report, you could follow this outline, for example.

Peyman_Amiri

Yes, I will do that. But with respect I mention that BNO055 Adafruit libraries and GY_955 Libraries, and calibration are different. So maybe the library codes of GY-955 caused more accuracy. Also maybe module of GY_955 caused more stability by filtering current noises and instabilities.

f3ir3n

Thank you my friend. You are the only one on the internet who shares this information clearly.

Peyman_Amiri

You're welcom. I have used this IMU and Arduino Mega for my big quadrotor and it flies very clean. It is a great sensor for degress in range -90 to 90.

Vliegvogeltla

Hi Payman,
I'm using the BNO080 in my artificial horizon project. Used the accelerator readout. The hard & software are working ok, as long the unit is on my hobby table. But in real flight the roll and pitch are not given any readout any  at all.
How did you solve this ?
Regards, Marc

Peyman_Amiri

#10
Jan 05, 2019, 10:15 pm Last Edit: Jan 05, 2019, 10:17 pm by Peyman_Amiri
Hi Payman,
I'm using the BNO080 in my artificial horizon project. Used the accelerator readout. The hard & software are working ok, as long the unit is on my hobby table. But in real flight the roll and pitch are not given any readout any  at all.
How did you solve this ?
Regards, Marc
Hi my friend.
I attached gy-955 VCC to 3.3 Volt pin of Arduino Mega 2560. I also have used Electrolyte capacitors parallel to power source of Arduino to remove noises. if you still have problem you can pm me to get more help.

Go Up