MPU 9150 compass data

Hi guys
I am trying to read the compass data from MPU 9150 with the code given in the playground - Arduino Playground - MPU-9150. However, I am getting almost same value for the three axes no matter how I move the sensor. The acc and gyro data look fine. Please help me out.

Chandra :slight_smile:

Are you getting zero, or some other value ?

I am attaching a copy of the values I get As you can see, the values it is printing for the magnetometer is almost the same for all 3 axes. Please help me out.

T=30.15
an=0.1269
ae=-0.0496
ad=0.0567
phi=-109.4288
theta=-67.4305
psi=0.0013
mx=-19.8000
my=-19.8000
mz=-19.8000
n=0.0000
e=0.0000
d=0.0000
vn=0.0013
ve=-0.0005
vd=0.0006
%%%%%%%%%% End of Time Step%%%%%%%%%%

T=30.01
an=-0.1220
ae=0.0465
ad=-0.0567
phi=-110.1875
theta=-66.5328
psi=0.0004
mx=-19.5000
my=-20.4000
mz=-20.4000
n=0.0000
e=-0.0000
d=0.0000
vn=0.0000
ve=-0.0000
vd=-0.0000
%%%%%%%%%% End of Time Step%%%%%%%%%%

T=30.01
an=0.0281
ae=-0.0112
ad=0.0127
phi=-108.8345
theta=-67.1739
psi=-0.0001
mx=-20.4000
my=-20.4000
mz=-20.4000
n=0.0000
e=-0.0000
d=0.0000
vn=0.0003
ve=-0.0001
vd=0.0001
%%%%%%%%%% End of Time Step%%%%%%%%%%

T=30.11
an=0.2174
ae=-0.0774
ad=0.0912
phi=-111.6418
theta=-68.4352
psi=0.0008
mx=-19.8000
my=-19.8000
mz=-19.8000
n=0.0000
e=-0.0000
d=0.0000
vn=0.0025
ve=-0.0009
vd=0.0010

Chandra