ArduIMU_V3 DCM Code with Calibration

Seeing that many are having issues with getting this IMU board up and running, I am uploading code that hopefully will help further progress on your own projects.  This code only addresses the task of getting consistent roll, pitch and yaw angles.  This means, no drift, especially in the yaw component.  To this end, this code contains calibration procedures for the accelerometers, gyros and the magnetometer. 

Since this board can accommodate GPS, the code also supports various units but I have only tested with the MTK16.  The code is liberally commented and modular such that you can cut & paste routines into your own project.  As it stands, you can use this as is for a AHRS system or head tracker.  By sending the serial data to another Arduino, you can create autopilot or an Orientation/GPS data logger. 

Compile options will let you output comma delimited values which my Processing sketch will display a rotating cube OR output data compatible with the HappyKillmore Test app.

This code relies on libraries found on the ArduIMU project site which you must put into your own Arduino IDE environment under Libraries. Specifically : AP_Common, AP_GPS, AP_Math and FastSerial.

File  "ArduIMU_V3_Layout.txt"  is general information about this board as far I could determine.  It may not be completely correct but provides some good reference source.

File  ""  is the main code.  Download, unzip and open file ArduimuV3_v1.ino.  Included with the code are detailed steps on how to perform the calibration.

After you have successfully calibrated and have comma delimited data display. You can download ""  which is a Processing sketch to display a rotating cube with roll, pitch & yaw data as well as GPS data if available.

If you comment out the OUTPUT_DELIMITED #define, you can output data that is compatible with the ArduIMU v1.1.19 Test application by HappyKillmore.  On my computer the response was very sluggish but YMMV.

Good Luck!








You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Hello  Andy here

    I am trying your ArduinuV3_v1 code above but i keep getting loads of install errors.

    I am using Ardunio 1.0.5

    The first error i get is 'AP_GPS_MTK' does not name a type

    I do not have a GPS attached

    What am i doing wrong



    • Andrew, very near the top of ArduImuV3_v1.ino file is a link to the DIY drones code respository.  Since this app is using libraries there you will have to download the 1.9.6 zip file to get all the required libraries into your system.  I am using Arduino 1.0.1 but I think it should still work on 1.0.5

  • Does your code fuse the GPS heading data into the calculations?

    • Nope, just uses gyro, accel and mag data.  Does gyro/accel cals and stores in eprom.  Likewise with mag data.  After calibration, all you can just read cals and come up running.  No cals at each turn on. Have managed to get good yaw data - no drift.

      I am reading GPS and Baro data but just displaying them.

  • Standing ovation! This is great. Al, nice work, seriously. Uploading to my board now...

  • Here is a link to the Processing sketch demo:

This reply was deleted.


Chris Anderson liked Zara Mae Pickering's profile
May 21
Azjeg liked Azjeg's profile
Apr 27
Benewake LiDAR liked Benewake LiDAR's profile
Apr 12
Gremsy liked Gremsy's profile
Mar 12