Strange compass comportment


I am having issues with the compass, again.

I imported this library following Karan’s advice, and at first it was working fine.

But now, after a few days not touching it, even the example problem does not work properly. I launch the program, enter any commands above 45° and the robot doesn’t stop spinning.

The heading degree I read are quite strange, as it never does a full 360. Reading the heading degree when the robot does a full 360 gives me heading from 80 to 100, and not 0 to 360.

I tried to understand what the library does, but for starters, I don’t understand why there is 5 set of the same information in the data variable.

Is there something I am missing on how the compass works?

The compass gives out raw x,y and z values and using it it calculates 2 more values which are heading(direction which the compass is pointing) in degrees and radians.

We have seen that this compass is affected by the emf from the GPG board if it is kept too close to it and can also give wrong values if the board is tilted.

Let us know if this helps.



I tested the compass in two different rooms, one that might have a lot of em interferences, and another that should not have, the results were the same.

As for the GPG emf, I tested the compass as far away from the GPG as the cable allowed me to, and no difference again in the reading.

Same for the tilt, I tried rotating the compass with different tilts, but I still can’t make it work properly.
The heading is different for each tilt, but the comportment is the same: during a 360 of the compass, the angles only ranges on something like 40° and sometimes ranges on 180° maximum.

I can’t find a reason why it is behaving this way, except of course that it might be broken.

Do you have an arduino or something else to test the compass or you should just ask Seeed or where you brought it from to replace it if you think it is broken.