TD-CMP04 Compass v2

Get this page as PDF

TechDesign Electronics


Front view.


TD-CMP04 Compass v2.




  • Small electronic compass.
  • Dimensions: 45x36x15mm.
  • Suited for robotics and other various applications.
  • Low current LED indicator (stays lit when heading North) for power saving.
  • Accuracy 1...2° @ 7Hz measurement..
  • Easy calibration.
  • Serial RS232 readout possible.
  • One multifunction push button for power on and calibration.
  • Low power operation with one small +12V MN21 battery.
  • Power supply input range is +3.0V ... +12V, only 2...5 mA active, 190ľA when sleeping.
  • Auto sleep mode after 30 seconds (LED goes off.)
  • Runs on a PIC18F25K20 at 8 MhZ along with an HMC5883 sensor.






 Module Software Updated on Dec. 27, 2011.

Circuit explanation / Getting started:


PIC18F25k20   The 18F25k20 offers high speed and low power operation. Well suited for a portable application such as this one.
HMC5883   Digital 3-axis compass IC
Push button   Short press to power up the compass (LED starts to flash.)

Long press (5 seconds) to start calibration.

LED   Flashing fastly when the compass is ON.

Stays lit when heading (top of the box as shown above) is close to North (from heading 355° to 5°)

Flashing slowly when requesting calibration (push button for 5 seconds.)

Stays lit for calibration (for 10 seconds.)

Low current red LED for power saving.

  1. Have the compass placed on a leveled (flat) surface.
  2. Long press on the push button (5 seconds) to start calibration.
  3. The LED starts flashing slowly.
  4. Continue to press for 5 seconds.
  5. The LED will stop flashing and now stays on.
  6. Now slowly rotate the compass 2-3 times , whilst keeping it leveled (flat.)
  7. Wait until the LED starts flashing again.
  8. Check whether the North indicator (LED stays on when heading North.)


front view, cover removed


bare PCB - populated backside







Check out our development tools page.

The PIC code was made with the PCWH CCS compiler ($500,-); you can install Microchip's MPLAB IDE (click on the link and you can get it for free) with it to get things running smoothly.

Programming of the PIC was done with a GTP-USB+ hardware programmer along with the WinPic800 software.

Eagle 4.11e was used for the schematic & PCB layout. 

Projects Home