I am measuring the angle of a link with the Gy-25 sensor using Arduino mega2560 with the UART protocol. I need to have the pitch angle, and according to its datasheet, the angle range is approximately from -20 to 85 and then starts to decrease again. Is there any way to have this angle in 360? I don't know if it's possible to convert this Euler angle to a quaternion? And how? The sensor and its datasheet attached bellow.
https://bsfrance.fr/modules-rc-drones/606-GY25-capteur-de-position-angulaire-MPU6050-MCU-tilt-angle-module-UART-GY-25.html
float Roll,Pitch,Yaw;
unsigned char Re_buf[8],counter=0;
void setup()
{
Serial.begin(115200);
Serial3.begin(115200);// SoftwareSerial can only support 9600 baud rate for GY 25 but Serial3 can support 115200 and 9600 both
delay(4000);
Serial3.write(0XA5);
Serial3.write(0X54);//correction mode
delay(4000);
Serial3.write(0XA5);
Serial3.write(0X51);//0X51:query mode, return directly to the angle value, to be sent each read, 0X52:Automatic mode,send a direct return angle, only initialization
}
void loop() {
serialEvent();
Serial.print("roll= ");
Serial.print(Roll);
Serial.print(" pitch= ");
Serial.print(Pitch);
Serial.print(" yaw= ");
Serial.print(Yaw);
}
void serialEvent() {
Serial3.write(0XA5);
Serial3.write(0X51);//send it for each read
while (Serial3.available()) {
Re_buf[counter]=(unsigned char)Serial3.read();
if(counter==0&&Re_buf[0]!=0xAA) return;
counter++;
if(counter==8)
{
counter=0;
if(Re_buf[0]==0xAA && Re_buf[7]==0x55) // data package is correct
{
Yaw=(int16_t)(Re_buf[1]<<8|Re_buf[2])/100.00;
Pitch=(int16_t)(Re_buf[3]<<8|Re_buf[4])/100.00;
Roll=(int16_t)(Re_buf[5]<<8|Re_buf[6])/100.00;
}
}
}
}