cancel
Showing results for 
Search instead for 
Did you mean: 

MPU6050 gyroscope not working correctly

M7890.1
Associate III

I am using the bluepill board and was trying to compute the angle from gyroscope raw data. However, when I tilt the sensor, the angle measured doesn't change as expected. It's changing between 1.xx and 2.xx regardless of the tilt angle. The sensor is being read every 4ms (I have configured the timer to interrupt at every 4ms). I have attached my code here, can anyone please help to to figure out what is the problem? Thanks!

Update: I try to remove the offset but the reading is still inaccurate. When the row angle is 45 degrees, it shows around 20 degrees; when the row angle is 30, it shows around 13 degrees. Both the angle calculated seems to be around 2.3 times less than the actual angle.

11 REPLIES 11

OK. Will try to change that during free time. Thanks for your help. =)

M7890.1
Associate III

The printing problem is solved but right now the drift in the gyroscope reading is extremely severe. I have already take 100 samples of the gyroscope reading prior to actual measurement and take the average of them. This offset is then subtracted from the raw data during actual measurement. The variable used to store the accumulated offset is a int32_t variable, so it's definitely large enough to store the value. What could be the problem?