# Working with GY-85 9DOF IMU Sensor Module raw data and applications

Hello,

I've been doing some simple Arduino programming. But I wanted to be a little away of the prewritten libraries for sometime until I get to know the basic programming principles of C/C++.

So working with GY-85 9DOF IMU Sensor Module, I'm trying to get the raw data of each chip on the board.

I've worked with HMC5883L chip and got the raw data, it took me time to read libraries for what to do with the raw data.

I learned that I can use x,y to get the compass calculations from 0 - 360 degrees. And then I can divide this range into 4 divisions to get N, S, E and W directions.

Now I understand how to work this function for specific applications; like, getting the directions for a moving object e.g. quadcopter.

Quadcopter is my next major project so this function should be very helpful in that project.

But .. what does z value do actually? This is my first question.

=======================================================

My second question is of course about the other two chips on this board.

I should start the second question with the accelerometer and its applications.

The question is how can this chip be helpful for my quadcopter?

Thanks,

Good overview on sensors and basic orientation in 3D here:

http://www.chrobotics.com/library

What’s the correct way to read the raw data?

I’ve used two ways:

``````x = data << 8 | data;
z = data << 8 | data;
y = data << 8 | data;
``````

This way I get values in the range of 0 to 255 and 0 to -255.

or

``````x = data << 8 | data;
z = data << 8 | data;
y = data << 8 | data;
``````

This way I get values in the range of signed 16-bits.

The device datasheet explains how the data are stored.

Whichever is the high byte should be shifted ( <<8 ).

jremington:
The device datasheet explains how the data are stored.

Whichever is the high byte should be shifted ( <<8 ).

“with DATAx0 as the least significant byte and DATAx1 as the most significant byte”

Now, I’m using this arrangement:

``````void ADXL345_print_Serial(void){
int16_t x,z,y;
uint8_t data;

x = data << 8 | data;
z = data << 8 | data;
y = data << 8 | data;

Serial.print(x);Serial.print("\t");
Serial.print(y);Serial.print("\t");
Serial.println(z);
_delay_ms(100);
}
``````

Now, according to the following picture:

1. When device is on this position, I get average readings for x - y - z:
-14 253 -5

2. When it’s flipped over I get:
-6 -245 21

3. On the long side:
258 2 -4

4. Opposite of long side:
-262 -1 5

5. On the short side:
-1 -22 252

6. Opposite of short side:
1 -3 -260

So, how interpret these numbers?

The acceleration due to gravity is between 245 and 260, as measured by your sensor.

For accurate acceleration measurements, it needs to be calibrated, as described in this blog article.

jremington:
The acceleration due to gravity is between 245 and 260, as measured by your sensor.

For accurate acceleration measurements, it needs to be calibrated, as described in this blog article.
Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers

Thanks for the link, I took an overview on the site, but it's complicated to me right now.

I just need an basic understanding for each sensor, what it does? When I read the data, how to convert the raw data to a useful information? Maybe I just have to map them then observe the results.
How each one is different from the other? What are the proper applications for each sensor?