Hi, does anyone recommend a good library for mpu6050? I've used it a bit but without success, finding some errors, I think, in terms of scale (I always find a range of 400 degrees).
or any advice on how to fix them? for example in a code I have this:
#define SCALE_FACTOR 32.8 // The resolution factor of the gyro with full scale (1000dps)
...........
yawAng_speed = ((double)read_mpu() - avg_gyro_error) / SCALE_FACTOR; // Speed measured
yawAngle += (yawAng_speed * (time_now - time_prev)/1000); // Yaw angle from yaw angular speed
in these codes the only doubts are the scale factor and the division of the yaw by 1000. any advice on how to change them? (I have checked the rest is correct, even the calibration, the sensor is precise but scales the degrees poorly)
Most libraries calculate the pitch, roll and yaw. If you need only the yaw, then use the yaw.
There are no "standard" libraries for the MPU-6050.
If you bought your MPU-6050 on Ebay/Amazon/AliExpress/TEMU then it is a counterfeit.
To serious use an accelerometer or gyro, you have to calibrate it.
When you make a turn, the software has to keep up with the motion. Make slow movements.
It depends on your project what the best option is:
Is this for fun and for learning ? Then try that code by jremington. If it works a little, then try to calibrate the sensor.
Is this a serious project ? Then you need a real sensor.
Is this for something with high speed motions (such as a drone), then you need a good and fast sensor with SPI interface. The I2C bus is slow.