# Compass problems

#1

Hi All,

I seem to have problems with the compass. I have an angle property that i can read but the numbers dont seem to be right are more people experiencing problems ?

Regards,

#2

@ WimEling - What system and firmware version are you using?

#3

Hello, devices like the compass, accelerometer, gyro, barometer etc, normally do require calibration. There are multiple methods to calibrate the device.

I don’t have a gadgeteer compass but I’ve worked a lot with other digital compasses.

The way I calibrate the compass is by turning it in all directions and sampling maximum and minimum values for each axis. then average those values to get the thresholds for the calculation. For instance, if you get 5 maximum values for the X axis then perform the following calculation:

XMaxAver = (X0 + X1 + X2 + X3 + X4) / 5;

Do the same on minimums on each axis.

Here is the summarized procedure:

• Get the maximum and minimum values for all the axes (X, Y, Z)
• Average maximums and minimums for each axis (don’t mix them!!)
• Save calibration data to perform measurement.

Since materials normally utilized inside of these electronic compasses are Anysotropic Materials, they are very sensitive to the direction of magnetic fields and probably to the magnetic component of strong electromagnetic waves, so make sure you perform calibration away of loud speakers, your computer and other noisy electromagnetic sources.

To perform measurement, just get samples and when those go to the maximum side use the maximum reference as follow:

XMaxAng = PI * (XSample / XMaxAverage);

To the minimum side:

XMinAng = PI * (XSample / XMinAverage);

Some extra adjustments could be required on the calculation (for instance, magnetic declination at your location) but I’m sure once you get used to you’ll find a workaround.

#4

Both thnx for the reply

I am using an Cobra 2 wifi board with the latest firmware and the compass you sell in the catalog. Also i use the standard Compass object that comes with gadgeteer for the seeed compass. The Calibration technique is done via a self build compass driver ?

Regards,

Wim

#5

Is there any documentation on how to calibrate the compass module ? It is very irritating that the module is not working as it is supposed to.

#6

Is support always this bad when having issues ? Or am I asking a stupid question here ?

#7

Well, normally the support is not bad here, quick answers, which are often useful, and in general a very friendly environment (compared to other forms I use).

I looked at the driver code, and it looks like that all it does is reading the x, y and z raw values from the sensor and calculating an angle.

This means all kind of calibration is on your side. This is why no one can give you support out of the box.

But have you read this:
https://www.ghielectronics.com/docs/64/compass-module
which also points to that:
https://www.ghielectronics.com/community/forum/topic?id=11880

#8

Byron’s post on this module is the best reference ever !

#9

Ok thnx for the information, I saw the post of Byron but because i had an angle property in the default seeed driver i thought this was the correct compass angle wil look further into the post.

#10

@ WimEling : I had the exact same problem, I did some code to calibrate the compass, and now it works well.

I’m integrating formulas (that I found on the web) to manage the tilt compensation. I know a extension of the Seeed driver has already been published with that functionality, but I have to check if the formula I found is better or not.

Once my tilt compensation is tested I’ll publish the code (probably 3-4 days).