Grove - 3-Axis Compass V1.0

Introduction

3.3V 5.0V I2C

This 3-axis digital compass features a low field magnetic sensing multi-chip module HMC5883L, which provides up to 1° to 2° heading accuracy. HMC5883L consists of high-resolution HMC118X series magneto-resistive sensors, as well as Honeywell developed ASIC containing amplification, automatic degaussing strap drivers, offset cancellation and 12 bit ADC. With peripheral power management circuit added, this is an easy to use and reliable compass module for low cost compassing and magnetometry.

Specifications

  • Input Voltage: 3.3V, 5V
  • Sleep Mode Current: 2.5uA
  • Measurement Mode Current: 640uA
  • High resolution
  • Easy to control I2C interface
  • Compatible with either 3.3V or 5.0V development platform
  • Max 116Hz output rate
  • High heading accuracy

Tip

More details about Grove modules please refer to Grove System

Platforms Supported

Demonstration

With Arduino

This demo is going to show you how to read raw data, how to calibrate the data with your local magnetic declination angle and how to get heading angle.

First off, before any action you are going to take, you need to prepare a parameter you are going to use in your demo. That’s your local magnetic declination.

You can find it out in degree via the magnetic declination webpage. For example, mine is -2°37’, which is -2.617 degree.

Then transfer it from degree to radians, and there you get the “declinationAngle”. For example, in my case, declinationAngle = -2.617 * π / 180 = -0.0456752665 rad. Three significant figures are enough. So I would shorten it into -0.0456 rad. And this is the parameter you are going to replace the value of “declinationAngle” in the demo code with.

Now let’s start to run your compass.

  1. Plug the 3-axis compass into the I2C port of Grove - Base Shield.

  2. Download the library file: Digital Compass Library. Unzip it into the libraries file of Arduino IDE by the path: ..\arduino-1.0.1\libraries.

  3. Open the demo by the path:File ->Example ->Digital Compass ->HMC5883L_Example.

  4. Replace the value of variable “declinitionAngle” with the one you’ve figured out already.

  5. Upload the Code.

  6. Check the output result by opening the serial monitor.

With Raspberry Pi

1.You should have got a raspberry pi and a grovepi or grovepi+.

2.You should have completed configuring the development enviroment, otherwise follow here.

3.Connection

  • Plug the sensor to grovepi socket i2c-x(1~3) by using a grove cable.

4.Navigate to the demos’ directory:

   cd yourpath/GrovePi/Software/Python/
  • To see the code
    nano grove_compass_lib.py       
    nano grove_compass_example.py    
    import grove_compass_lib
    c=grove_compass_lib.compass()
    while True:
            print "X:",c.x,"Y:",c.y,"X:",c.z,"Heading:",c.headingDegrees
            c.update()
            time.sleep(.1)

5.Run the demo.

    sudo python grove_compass_example.py

Resources


ArduinoWioBeagleBoneRaspberry PiLinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:

  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.

An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.

Happy hacking