Electronic – arduino – How to read a gyro/accelerometer

accelerometerarduinogyro

I recently purchased this MPU6050 GY-521 breakout board. I tried it with my Arduino Mega using this Arduino sketch provided by official arduino.cc.
(MPU-6050 Datasheet, InvenSence (producer) Page)

Man, it gives this weird output!!!

InvenSense MPU-6050
June 2012
WHO_AM_I : 68, error = 0
PWR_MGMT_2 : 0, error = 0

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1944, 368, 15608
temperature: 30.576 degrees Celsius
gyro x,y,z : -34, -204, -247, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1952, 364, 15304
temperature: 30.435 degrees Celsius
gyro x,y,z : -38, -216, -274, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1864, 388, 15356
temperature: 30.482 degrees Celsius
gyro x,y,z : -34, -233, -278, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1888, 324, 15260
temperature: 30.576 degrees Celsius
gyro x,y,z : -14, -220, -261, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1904, 392, 15316
temperature: 30.624 degrees Celsius
gyro x,y,z : -34, -241, -238, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1856, 308, 15604
temperature: 30.435 degrees Celsius
gyro x,y,z : -33, -252, -235, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1892, 444, 15528
temperature: 30.624 degrees Celsius
gyro x,y,z : 20, -236, -251, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1924, 356, 15520
temperature: 30.576 degrees Celsius
gyro x,y,z : -19, -224, -251, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1844, 280, 15732
temperature: 30.529 degrees Celsius
gyro x,y,z : -1, -240, -249, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 2004, 372, 15396
temperature: 30.671 degrees Celsius
gyro x,y,z : -20, -252, -255, 

(This is only a part of it, it gives this king of output continuously). I know for sure, only the temperature reading is meaningful. But what are those values given for acceleration and gyro readings??

OK, It says those are raw values. If it is so, then how can I convert them into meaningful values. Hoping it can be helpful (as many suggested), I also like to know how to use so called Jeff Rowberg library.

Hope there will be someone experienced with MPU-6050 module. Just give me a point to start. I have no clue on how to use the module… 🙁

Any help is greatly appreciated. Thanks !

Best Answer

The accelerometer's reading seem to make sense. The datasheet, page 13 indicates 4 different sensitivities:

2 g  
4 g  
8 g  
16 g  

with resp. sensitivity scale factors:

16 384 counts/g  
8 192 counts/g  
4 096 counts/g  
2 048 counts/g  

From the Z-reading I assume you have the 2 g scale selected, then 15 608 is 0.95 g, which is what you can expect from a Z-axis reading when you hold the sensor more or less horizontal. The X- and Y-reading are probably also due to gravitation when you're not holding the part perfectly horizontal. And you'll have an error in the reading too.



Similar for the gyro. At 131 counts per degree/s you may have this kind of reading if you're holding the part in your hands.