Tuesday, August 19, 2014

A low-cost marine compass (Part 1 – Hardware)

For an electronic compass, the accuracy depends more on the quality of the calibration that on the price of the components. Here is the design of a low-cost compass developed around this idea.

The compass is based on the LSM303D chip which combines a 3-axis accelerometer and a 3-axis magnetometer. I used the Pololu carrier board featuring this chip (9.95 US$).

The other component of the compass is an Arduino Pro Mini 328 – 3.3V/8Mhz from Sparkfun (9.95 US$). The Pro Mini communicates with the LSM303D through the SPI bus, using drivers adapted from the PX4 Development Team. The 2 components are hardwired together to keep a compact form.

The following picture illustrates the small compass besides my Hi-Resolution custom compass previously described on this blog.

Here is the wiring diagram for SPI communication. The FTDI breakout is used to program the Pro Mini and to read the LSM303D raw data during the calibration step.

The long ribbon cable is required during calibration so that the compass can be moved around at a safe distance from the breakout and the laptop to avoid magnetic interference. After calibration, the ribbon cable is used to power the compass (3.3V) and to transmit the tilt-compensated heading and the heel angle through the serial link to whatever instrument that needs it.

A low-cost marine compass (Part 2 – Software) 
A low-cost marine compass (Part 3 - Calibration)


  1. How does the accuracy of this low-cost compass compare to your high-resolution version from earlier?

    1. A very good question, that I will try to answer next summer by installing them together in the boat. Even if the small compass has not the technical level of the other, I expect that after calibration, the results may be quite comparable and should not make a practical difference.