Posts: 6
Joined: Thu Feb 01, 2018 7:10 am

Normalising angled Earth magnetic field from Sense HAT magnetometer

Tue Jan 22, 2019 8:13 pm

We want to investigate the connection between the magnetic intensity measurements from Sense HAT magnetometer and predictions from the World Magnetic Model (WMM). We want to research the accuracy of the magnetometer on Sense HAT.

The program will get raw magnetometer data (X, Y and Z) in microteslas from Sense HAT and calculate values H and F as described in British geological survey's article ( (section 2.1). It will then save them to CSV file, along with timestamp and location calculated with ephem.

We will then compare values Z, H and F from ISS with WMM data and create maps with our data and differences (like figures 6, 8 and 10). We will then research, how accurate are Sense HAT magnetometer data.

We want to compare our data with data from WMM to see how accurate is Sense HAT magnetometer, but we have a problem that the orientation of magnetometer will always be different. Because of that, our data will always be (very) different from WMM so we won't be able to compare them correctly.

We talked with Astro Pi support team and they suggested to "normalise the angled measurements so it looks like they were taken by a device aligned North/South".

Unfortunately, we (and they) don't know how to do this, so they suggested to ask this question on Stack Exchange. I asked it on ... etic-field and ... etic-field, but unfortunately, it didn't receive any answers, so I am also asking this here.

How can we do this? We have data for the timestamp, ISS location (latitude, longitude, elevation), magnetic data (X, Y and Z) and also the direction from the North.

We want to normalise our data so we will be able to correctly compare them with data from WMM.

Here is part of our program that calculates magnetometer values (which gets not normalised data):

Code: Select all

compass = sense.get_compass_raw()

    # Get raw data (values are swapped because Sense HAT on ISS is in different position)
    # x: northerly intensity
    # y: easterly intensity
    #  z: vertical intensity
    x = float(compass['z'])
    y = float(compass['y'])
    z = float(compass['x'])

except (ValueError, KeyError) as err:
    # Write error to log (excluded from this snippet)

    # h: horizontal intensity
    # f: total intensity
    # d: declination
    # i: inclination
    h = sqrt(x ** 2 + y ** 2)
    f = sqrt(h ** 2 + z ** 2)
    d = degrees(atan(y / x))
    i = degrees(atan(z / h))

except (TypeError, ValueError, ZeroDivisionError) as err:
    # Write error to log (excluded from this snippet)

User avatar
Posts: 4292
Joined: Wed Aug 28, 2013 3:31 am

Re: Normalising angled Earth magnetic field from Sense HAT magnetometer

Fri Feb 22, 2019 1:36 am

It is not clear but don't you need the accelerometer data to correct for any tilt?
Rotating the compass is also a common method of calibration.

Aircraft and ships have procedures for magnetic compass calibration.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Astro Pi”