Advanced compass/accelerometer library for Arduino

We don’t have much personal experience with DOF hardware, but this Arduino library which reads and compensates for three-axis magnetometer and accelerometer data looks very impressive. It should work for existing hardware, but there’s also a demo design using a Honeywell HMC5883L compass and a Freescale MMA8453Q accelerometer which you can build yourself. Unfortunately these come in QFN packages (like most cheap accelerometers these days) so you may need to be creative when soldering.

What’s so special about this library? Watch the video after the break (use 720p in fullscreen to get the full effect) and you’ll see three different scatter plots of the output data. The image above is a capture of the third example, which is using the hard iron offset and accelerometer compensation. That is to say, metal on and around the board is accounted for, as well as the physical orientation of the device. Even if you have no prior experience with this type of hardware it’s easy to see the usefulness of this kind of software compensation.

[youtube=http://www.youtube.com/watch?v=NF1ezexJuHk&w=470]

Comments

  1. Scott says:

    A nice write up … but after reading the linked Freescale app note, it doesn’t seem like there was much originality here. Simply ported an excellently written app note from C# to an arduino library (which they did well…. just want to makee sure credit is given where due…)

  2. MrW says:

    “DOF Hardware” is non nonsensical. DOF stands for Degrees of Freedom. 6DOF means that the hardware can provide measurements in 6 degrees (x,y,z acceleration and roll, pitch, yaw) The term you’re looking for is Inertial Measurement (although magnetometers aren’t truly inertial measurement devices, they are often included in Inertial Measurement Units for drift compensation)

  3. Soo-Hyun says:

    This is an awesome visualization of magnetometer offset!

    That said, all that is needed to calibrate a magnetometer is to find the minimum and maximum readings of each of the three axes. The zero point is (max+min)/2, and the gain can be determined from the value of (max-min).

    • Michael says:

      This is true, however it isn’t so easy to get the max and min directly on axis and in the presence of noise. The auto solver included with the library will pick out the on axis limits with off axis data while rejecting noise.

      Michael

  4. jpa says:

    Would be a great fit with LSM303, which contains both magnetometer and accelerometer in a single device. It’s LGA14, but it’s not that difficult to solder with a normal iron if you make the pads long enough.

Speak Your Mind

*

Related Hacks in arduino hacks

  • Garden sensors measure soil moisture and greenhouse temperature
  • More pins and more power with a DIY Sanguino
  • A much easier take on an Android garage door opener
  • UnoJoy makes your Arduino play well with Xbox 360 or PS3
  • RC car controller and receiver replacement