Magnetic Navigation


Since ancient times sailors have used the Earth’s magnetic field for navigation. The compass has its origin in China and was introduced into Western Europe from the Islamic world (Ref.1). My first compass exposure was orienteering on canoe trips in Norther Quebec and then later on a mineral magnetic survey in the Coppermine Area of Northern Canada. I used a Silva Ranger compass. For the mineral survey we used a Scintrex Magnetometer to measure the dip in the Earths’ Magnetic field over a field grid where the suspected mineral deposit was located. Later I used the same compass in South East Asia and discovered that the compass needle only leveled when I angled the base to the vertical. Then I learned that compasses were manufactured for specific regions and were balanced for the vertical component of the Earth’s magnetic field.

Several years ago I purchased a Suunto Global compass that had compensation for use anywhere on Earth. My experience with the hand bearing compasses was that you could get a bearing with an accuracy somewhere between 3 – 5deg. Since the compass needle points to magnetic north, you have to adjust a dial within the compass housing to account for magnetic variation/declination which is the difference between true geographic north and magnetic north. The north magnetic pole has been wandering continuously and now has moved from the Canadian Arctic towards Siberia (Ref.2). Using a Brunton transit compass mounted on an aluminum tripod with bronze mounting bracket, I was able to get bearings on the Sun within 1deg. YouTube Video Fig.12 shows these various hand bearing compasses.

Earth’s Magnetic Field

Figure 1 shows the Earth’s magnetic field. The total field vector is He, the North component is Hx, Hy is the West component and Hz the vertical component. Hhor is the net horizontal component which is the vector sum of Hx and Hy. The magnetic inclination phi is the angle from Hhor to He. Figure 2 gives the Earth Magnetic field values from the World Magnetic Model 2020 Calculator for Toronto, Canada (Ref.3):
Dec = D = -10.308 (West Declination)
Phi = I = 69.382deg (Mag Inclination)
He = F = Total Field Intensity = 53,526nT
Hx = X = 18544nT (North Intensity)
Hy = -Y = 3373nT (West Intensity = -East Intensity)
Hz = -Z = -50097 (Up Intensity = -Down Intensity)
Hhor = H = 18,849nT
Hhor = sqrt(Hx^2 + Hy^2) = 18,848nT
He = sqrt(Hx^2 + Hy^2 + Hz^2) = 53,525nT
Declination = atan((absHy)/Hx) = atan(3373/18544) = 10.31decW = 0.1799radW
Phi = atan((absHz)/Hhor) = 69.38deg
Note: 1Tesla = 10^4Gauss
He = 0.53526Gauss

Fig.1 Earth Magnetic Field Vector Model
Fig.2 Earth Magnetic Field Toronto Ontario

Electronic Compasses

My first electronic compass used a Dinsmore 1490 Digital Hall effect sensor. It was based on an article in the August 1997 issue of Popular Electronics (Ref.4). The unit had 4 transistors in the North, East, South and West positions. If the internal compass was exactly pointing at the North transistor, then it would turn on. If it pointed half way between the North & East transistors, then both would turn on. Thus the compass had 8 points or 45 deg accuracy. The transistor states were sensed by a Parallax BS2 micro controller. The unit is shown in Figure 3 and the schematic in Figure 4. YouTube Video Figure 12 shows the output.

Fig.3 Dinsmore 1490 Hall Effect Sensor Compass
Fig.4 Dinsmore 1490 Compass Schematic StampBS2

HMC5883L 3 Axis Magnetometer Compass

The Honeywell HMC5883L is a 3 axis magnetometer that can be used as an electronic compass. The GY-273 breakout board shown in Figure 5 has the HMC5883L with all the external components required to interface with a micro controller using an I2C interface. Adafruit has a similar breakout board (extra pin for 3.3VDC, different axis orientation) with a comprehensive application note containing datasheet, schematics, pintouts, Arduino code, Library code, and complete explanations (Ref.5). Note the axis orientation shown by arrows on the breakout board. This corresponds to Figure 1.

Fig.5 Honeywell HMC8533L Mounted on GY-273 Breakout Board

HMC5883L Magnetometer Compass with Arduino Uno

Figure 6 shows the connection of the GY-273 breakout board to an Arduino Uno micro controller:
Vin to 5V
Gnd to Gnd
SCL to A5
SDA to A4
DRDY not connected
Following the procedure in Figure 13 YouTube Video Magnetic Navigation_b to load the library code for the HMC5883L and run the example file ‘magsensor’ as described in the Adafruit application note. The Arduino code was written by Ada Lovelace herself, taking time off from coding the Babbage Differential Engine! Figure 7 shows the output on the Arduino 1.8.13 IDE. When you orient the sensor so that x is pointing to Magnetic North, then y = 0 and the heading is 0deg (setting declination to zero for now). If you point x directly to the West, then x = 0 and the heading is 90deg.

Fig.6 HMC5883L on Arduino Uno
Fig.7 HMC5883 on Arduino Compass Output

HMC5883L Magnetometer Compass with Raspberry Pi 3B

Figure 8/9 shows the connection of the HMC5883L on the Raspberry Pi 3B.
Vin to Pin4
Gnd to Pin6
SDA to Pin3
SCL to Pin5
DRDY not connected
In order to interface the magnetometer, go into Raspberry/Preferences/Raspberry Pi Configuration/Interfaces and enable I2C. I am running OpenPlotter as the OS. Next install a programming IDE such as Thonny.
pi@openplotter:~ $sudo apt install thonny
There are many excellent Python programs to interface with the HMC5883L, I used Ref.6. Figure 10 shows the Python interface program running on the Thonny IDE.

Fig.8 HMC5883 on RaspberryPi
Fig.9 RaspberryPi GPIO Header
Fig.10 HMC5883 on RaspberryPi Compass Output

Magnetic Anomaly Navigation

In a recent article in Electronic Design (Ref.7), the concept of using the Earth’s Magnetic anomalies for navigation was discussed. This system could be used as an “alternative” to GPS.

Fig.11 Earth Magnetic Anomaly NASA
Fig.12 Magnetic Navigation_a YouTube Video
Fig.13 Magnetic Navigation_b YouTube Video

Please send your comments, questions and suggestions to:

YouTube Channel
YouTube Channel


#1. – “Compass”, Wikipedia

#2. – “Scientists explain magnetic pole’s wanderings”, BBC News

#3. – “Magnetic Field Calculator”, UK BGS

#4. – “Hall-Effect Electronic Compass”, Popular Electronics Aug 1997

#5. – “Honeywell HMC5833L Triple Axis Magnetometer”, Adafruit

#6. – “Triple Axis Magnetometer HMC5883L Interfacing with Raspberry Pi”,

#7. – “Magnetic-Field Navigation as an “Alternative” GPS?”, Electronic Design

Categorized as Navigation

By Jeremy Clark

Jeremy Clark is a Senior Telecommunications Engineer and Advanced Amateur Radio Operator VE3PKC. He is the author of E-Books on Telecommunications, Navigation & Electronics.