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.
A low-cost marine compass (Part 2 – Software)
A low-cost marine compass (Part 3 - Calibration)