Did you mount the compass in the manner, that is showed in my video? It’s very important how you hold the compass.
To run the compass was very diffcult.
When I first tried to run the compass nothing worked! Then I got it, that something was wrong with the I2C interface in the header-file. When I switched off the buzzer, my compass was recognized, but it showed senseless data.
I calibrated it by pressing the button, turning 360 ° and so on, but there were still the senseless data.
Then I found, that the MeCompass is the same as the HMC5883L. In the internet I found a library and a sketch by Jeff Rowberg. I added the library for my orion board (arduino) for I2Cdev and HMC5883L and added the sketch by Rowberg to calculate the angle in degrees.
Suddenly it worked perfectly!
Did you get the current heading of compass by the following function by Jeff Rowberg It’s important to mount the compass as in the video! (myserial.print is for my LCD-screen, you have to change it to Serial.print for your monitor, if you don’t have a LCD-screen :
float getCurrentHeading() //return headingDegrees
head_X = Compass.getHeadingX();
head_Y = Compass.getHeadingY();
head_Z = Compass.getHeadingZ();
// Calculate heading
float heading = atan2(head_Y, head_X);
// comments by Jeff Rowberg:
// Set declination angle on your location and fix heading
// You can find your declination on: http://magnetic-declination.com/
// (+) Positive or (-) for negative
// For Kiel / Germany declination angle is 2’14E (positive)
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
float declinationAngle = (2.0 + (14.0 / 60.0)) / (180 / M_PI);
heading += declinationAngle;
// Correct for heading < 0deg and heading > 360deg
if (heading < 0)
heading += 2 * PI;
if (heading > 2 * PI)
heading -= 2 * PI;
// Convert to degrees
float headingDegrees = round (heading * 180 / M_PI);
I hope you get the compass running.
If I can help, let me know.