calculate G-FORCE using an accelerometer GY-521 (MPU-6050) & ARDUINO DUE

hi everyone,

in my project i need to measure G-FORCE in a car accident. i'm finding it very hard to build a code for this process. i'm using ARDUINO DUE & GY-521.

someone help please.. :roll_eyes:


You use the x,y,z values of the accelerometer and calculate the resulting vector. vector = sqrt ( x*x + y*y +z*z ); However, the MPU-6050 can not be used to measure impact G-forces. You need a specific accelerometer for 100 G or 200 G.

hi peter, first of all thanks for your answer. but i just need to measure about 2-3G. this sensor can measure it. see here:

i'm still struggling to find a code at the global network, or even something similar..


Only 2G or 3G, that is very low, I would not even call that an impact or accident. Most code is developed for the Arduino Uno and other Arduino boards with the ATmel microcontroller. I don't know if everything works with the Arduino Due. You should have at least the newest BETA Arduino IDE.

This is simple code to test the sensor :

This is a complete library : You need two libraries, the i2cdevlib and the mpu6050 library. This is the i2cdevlib forum about the MPU-6050 with the Arduino Due:

hi peter,

3G is enough for my experiment. I have already tested the sensor with this code ( and it seems fine. I downloaded the libraries you named.. also took the code from and it did nothing.

maybe you have another direction for getting any help?...

The sketch in the playground shows the x,y,z for acceleration. Those values represent a certain g-force, but I forgot how to calculate it, it is somewhere in the datasheet. If the z-axis is pointing up, you meausure earth gravity, which is 1G. You can calculate the resulting 3D vector with x,y,z. At least that way you have a start, and you can do some real tests.

Is some filtering needed ? If you accidently hit the sensor, the g-forces go way up, although for a very short time. Or perhaps you want only the peak value ?

You could ask on the i2cdevlib forum to make the library Due compatible.