Arduino and GY-85 9DOF (Accelerometer ADXL345, Gyroscope ITG3200 and Magnetometer HMC5883) + Angle Information Comparison

posted in: Arduino | 22

Download # Arduino Code (*.ino file)

Download # ADXL345 Accelerometer Library (*.rar file)

Download # ITG3200 Gyroscope Library (*.rar file)

Download # HMC5883L Magnetometer Library (*.rar file)

Download # Serial Oscilloscope v1.5 (*.rar file)
or
Upload Arduino code directly to your Microcontroller from website
If you want to integrate Arduino IDE into your website (as above) sign up here: codebender
 

Follow me:

22 Responses

  1. Has this project’s code Kalman Filter?

    • This one – no, and the sensor information is not fused in any way. Actually, I would suggest using quaternion implementation rather than Kalman filter like here http://www.himix.lt/?p=915 (sensor fusion is done here), when you use the array of 3 sensors (accelerometer, gyroscope and magnetometer). The use of Kalman filter would not provide noticeable improvements over quaternions (I’ve did lot’s of experimentation).
      BUT! If you use only one sensor, for instance, accelerometer, I would recommend using Kalman filter.
      I’m planing to make KF tutorial in near future.

  2. David Liddell

    I have been trying to run this code for hours but for some reason the Arduino 1de ver 1.6.5 on windows 10 cannot find HMC5883L.h. I’ve placed copies of the library in the main library, the sketch book library and the hardware library but it continues not to find it. I also used the library manager. help

    • Hi, I have windows 10 x64, I tested it right now and it works perfectly. Make sure that the library directories looks something similar to this:
      C:\Users\EdgarasArt\Documents\Arduino\libraries\HMC5883L_library\HMC5883L_Example

      not to this:
      C:\Users\EdgarasArt\Documents\Arduino\libraries\HMC5883L_library\HMC5883L_library\HMC5883L_Example

      Depending on how you extract the libraries, it might have two same folders one in another (HMC5883L_library\HMC5883L_library\\HMC5883L_Example) so I assume Arduino can’t recognize it.

    • Luc De Clerck

      line 125 gxrate ??_

  3. Hi, I don’t know why but arduino software don´t recognize the ADXL345 library. The program shows it in black instead of orange.
    The folder is in this directory: C:\Users\Leyre\Documents\Arduino\libraries\ADXL345_library with the other libraries (which it recognizes well) and the folder ADXL345_library is not duplied.
    Nevertheless, when compiling the software doesn´t show any error.
    Any idea? I need help please.

    • First you said it does not recognize the library, but then you say that it “doesn’t show any error”. I don’t understand. How do you know that it can’t recognize the library without the errors written?

  4. Thank you for answering.
    The programm shows the library and all the functions related to accelerometer in black instead of orange whereas the rest are in orange. Isn’t that weird?
    Nevertheless it compiles and I can upload the programm to the Arduino UNO Board (although the data adquired is really weird).

    • That’s really weird, it’s hard to suggest something right now, but answer to this question: do you really use GY-85 board? yes or no?
      This is important because I had some weird data readings while using board with only accelerometer alone and I couldn’t find the solution for that.

  5. Maybe colors of the text have no importance. The fact is that I’m pretty new using Arduino, I’m still learning basic things.

    Another question, how can I get angles between -180 and 180 degrees? I have confusing data in the serial monitor

    • Try and search specific library for GY-85 on the internet.

  6. Hi again,
    I have been trying the code the entire day but i don’t understand the outputs.
    I want the angles in degrees. On the one hand i get the rolldeg and pitchdeg between 20 and -20 instead 90 and -90 degrees.
    On the other hand when i show anglegx, anglegy and anglegz i get signals which change even when the Imu is stationary.
    I would like to add to your code a complementary filter but with those output data i can’t.
    I have watched the video and it seems to me that output data shown are correct but i don’t get the same.
    Could you help me please? I’m a little desperate because my project depends on an good measurement of the angles.
    Best regards and sorry about the mess

    • If you would send me some pictures of the sensor wiring to arduino microcontroller and screenshots of error in the program maybe I will be able to help you.

  7. Hi! Thanks in advance for your work! I tested and worked very well.
    I’m looking at the code and I have some stupid question to ask you. I would be glad your feedback. (sorry in advance for the dumb questions.. but I’m not an expert in arduino)
    0.1- the raw output of the acc is what? voltages?(from readAccel)
    0.2-the raw output of the MM is what?
    0.3-the raw output of the gy is what?

    1-line47: reading gyros acc and mm, you have a FOR loop of 201. May I ask you why?
    2-line88: why 255? there is a pre-set offset of 255deg?
    3-line89: why are you dividing by 256 the raw data?
    4-line92->95: I don’t understand what u are doing here.
    5-line113->115: why is divided by 14.375?

    I was looking at you comment in the 15-05-2015. It is interesting: Kalman filter doesnt improve the attitude determination with quaternions. may I disagree? the kalman filter (if well tuned) would improve drastically the representation of the attitude during time, enabling what is so called “smooth” representation.

    Here (http://www.himix.lt/?p=915) are you using just quaternions? no KF? right?
    Have you ever tried to implement it on arduino uno?
    I had rumors that is impossible due to limited memory?

    Thanks in advance for your kind answers,
    I really appreciated your wonderful job! It works nice?

    p.s. do you have an oscilloscope for dumb Macosx users?

    Cheers

    S

    • Hello,

      1. Concerning all first questions – look up some theory on the internet how it works and read sensor datasheets it will answer lots of your questions.
      2. “I was looking at you comment in the 15-05-2015. It is interesting: Kalman filter doesnt improve the attitude determination with quaternions. may I disagree? the kalman filter (if well tuned) would improve drastically the representation of the attitude during time, enabling what is so called “smooth” representation.” – show me some proofs of that “drastical” improvement. Quaternions already have smooth representation.
      3. “Here (http://www.himix.lt/?p=915) are you using just quaternions? no KF? right?” – correct
      4. “Have you ever tried to implement it on arduino uno?” – Yes I have tried it.
      5. “I had rumors that is impossible due to limited memory?” – Wrong, there’s enough memory.
      6. No, I don’t have oscilloscope for Mac.

      Good luck with your work

  8. science

    Hi,
    I run this code with GY-85 BMP085 sensor. ADXL345 library is in black instead of orange in the program. Also, at the serial monitor, the values does not change and they are always “0.00, 0.00, 92.50”. I don’t understand why it is. I need help :(

    • Did you sort the problem? Maybe some wiring problem?

      • Engulf

        I actually know what your problem is. On my code, ADXL345.h is also black, but it runs just fine. I get the same problem if I move the libraries to a wrong location.
        So to explain, When my code works correctly, I have my main folder labeled “Arduino”. Within that, I have a unique folder for each “.ino” file, labeled the same way as the “.ino” file (minus the .ino) and a folder labeled “libraries”. All of the libraries go in the “libraries” folder, then are saved in another folder titled with the name of that library followed by “_library”. For example, it goes:
        Arduino>libraries>ADXL345_library>”all contents of that library”
        I have the problem where my serial monitor values are always “0.00, 0.00, 92.48” if I move the libraries from the “ADXL345_library” folder to the “libraries” folder.
        I don’t know if that actually makes a difference but if it was the same problem so hopefully this helps you fix it!

      • I got the same problem, where constant value coming out from my serial monitor, but later I found that I am using Mega2560 board and the pin assignment is completely different, please take a look at the pin assignment below, hope it helps!

        Uno, Ethernet: A4(SDA), A5(SCL)
        Mega2560: 20(SDA), 21 (SCL)
        Leonardo: 2(SDA), 3(SCL)
        Due: 20(SDA), 21(SCL), SDA1, SCL1

  9. Hello,

    I am interested in a solution that allows to fuse the results from accel and gyro in order to get the angular position.
    Is there any tutorial about the kalman filter (or any other method for mixing) available for GY-85?

    Which operation is the code doing (with the for cycles) in the line 47 and 60?

    Thank you very much for your answers,
    compliment for your work.

    kind regards,

    M

  10. how can ı use with arduino due

    i tried and i changed ‘unsigned long time ‘ to ‘unsigned long tim’ but gives 0.00,0.00,92…’
    can you help me ?

  11. Kiyoshi

    Hi ! first of all thanks for this post. And I’m having some issues, when i opened Serial Monitor it keep printing 0,00.0,00.92,8.92,8 even i rolls it many directions. Did i have to calibre it first ?

Leave a Reply to David Liddell Cancel reply