Mpu6050 scale factor and library

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)

Did you try this one? It uses Kalman filtering.

I tried reading the library but there is no yaw calculation. I would only need to scale the data I provided in the initial code

This library uses the Mahony filter for pitch, roll and yaw: https://github.com/jremington/MPU-6050-Fusion

Can you explain why you think that you need to scale something ?

I only have to measure the YAW. if I use standard libraries and make a 360° turn, it actually measures 400°

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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.