3 Axis Compass Sensor

O Watch Sensor Kit includes the Honeywell HMC5883 chip which is a 3 axis digital compass chip that can be used to make a digital compass. This chip uses magnetoresistance sensors.
Here is an example to demo this sensor. This is based on the compass example from TinyCircuits.

You can copy paste this code to the Arduino IDE and load to the O Watch to see it work.

After uploading the code, you need to calibrate it by rotating the O Watch 3 times each on x, y, and z axis as shown in the TinyCircuits example. Calibration us required every time you power on or upload the compass program.

Few things to note.

  • The compass sensor is pointing to the right i.e. towards the buttons on the right if you’re wearing the O Watch on your left wrist. Therefore the heading values are shifted down by 90 to show the results pointing ahead.
  • The compass sensor sits upside down in the O Watch. Therefore you need to swap the results of East and West to display the heading correctly.

Adafruit also has a HMC5883 Library if you’d like to give that a try.

<< Back: Humidity Sensor