I have that MPU9255: https://himalayansolution.com/product/mpu-92-65-gyroscope-and-accelerometer-module-3-axis
I want to angle of yaw movement and here is my code:
#include <SoftwareWire.h>
SoftwareWire wire(2,3);
const int SENSOR_ADDRESS = 0x68;
void setup() {
// put your setup code here, to run once:
wire.begin();
Serial.begin(115200);
wire.beginTransmission(SENSOR_ADDRESS);
wire.write(0x6B);
wire.write(0x00);
wire.endTransmission(true);
delay(50);
wire.beginTransmission(SENSOR_ADDRESS);
wire.write(0x1C);
wire.write(0x00);
wire.endTransmission(true);
}
void loop() {
// put your main code here, to run repeatedly:
wire.beginTransmission(SENSOR_ADDRESS);
wire.write(0x3B);
wire.endTransmission(false);
wire.requestFrom(SENSOR_ADDRESS, 6, true);
int16_t xAxisFull = (wire.read() << 8 | wire.read());
int16_t yAxisFull = (wire.read() << 8 | wire.read());
int16_t zAxisFull = (wire.read() << 8 | wire.read());
float xAxisFinal = (float)xAxisFull / 16384.0;
float yAxisFinal = (float)yAxisFull / 16384.0;
float zAxisFinal = (float)zAxisFull / 16384.0;
Serial.print("x Axis = ");
Serial.println(xAxisFinal);
Serial.print("Y Axis = ");
Serial.println(yAxisFinal);
Serial.print("Z Axis = ");
Serial.println(zAxisFinal);
Serial.println("-------------");
delay(500);
}
and here is my output:
x Axis = 0.00
Y Axis = 0.02
Z Axis = 0.93
There is no problem to get roll and pitch angles but when sensor make yaw movement there is no change in z axis value.
And that is the output when sensor make roll movement:
x Axis = 1.00
Y Axis = 0.02
Z Axis = -0.13
z axis value is decreasing same amount as increase amount of x axis value. And this is the pitch movement output:
x Axis = 0.05
Y Axis = 0.99
Z Axis = -0.14
Same as roll movement.
How can I get angle of yaw movement.