Open fabioetec opened 3 years ago
Do you have a code snippet to simulate it?
Do you have a code snippet to simulate it?
Sure! On line 10 of this file https://github.com/Xinyuan-LilyGO/LilyGo-T-Wristband/blob/master/examples/T-Wristband-MPU9250/sensor.h change:
#define SerialDebugMPU9250 0
with
#define SerialDebugMPU9250 true
then open serial monitor and, with the button on the device, go to the page where you see accelerometer values (green text on black background). On the serial monitor, you will see the output printed by this code (lines 185-192 same sensor.h file, you can also remove comment on line with header "Yaw, Pitch, Roll: ")
if (SerialDebugMPU9250) {
// Serial.println("Yaw, Pitch, Roll: ");
Serial.print(IMU.yaw, 2);
Serial.print(", ");
Serial.print(IMU.pitch, 2);
Serial.print(", ");
Serial.println(IMU.roll, 2);
}
Without moving the device I should get almost the same number for yaw, pitch and roll, instead I get differents values at every loop.
For any other question don't hesitate to ask!
Any news??
Sorry, but i don't have MPU9250 With LSM9DS1 i'm able to get valid pitch and roll values using this snippet of code
update_imu();
x = imu.calcAccel(imu.ax);
y = imu.calcAccel(imu.ay);
z = imu.calcAccel(imu.az);
pitch = atan2(x, sqrt(y * y) + (z * z));
roll = atan2(y, sqrt(x * x) + (z * z));
pitch *= 180.0 / M_PI;
roll *= 180.0 / M_PI;
Hope it can help
I would like to develop a compass.
So I modified MPU9250 example creating a sprite with an arrow which I rotate with the angle returned by IMU.yaw.
If I correctly understand IMU.yaw should give me the angle in degrees from north to the current orientation.
The problem is IMU.yaw return me completly random values, for example without moving the device and setting
#define SerialDebugMPU9250 true
on sensor.h I get:moving from positive to negative values without any sense.