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

posted in: Arduino | 25

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
 

25 Responses

    • admin

      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.

  1. 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

    • admin

      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.

  2. Leyre

    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.

    • admin

      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?

  3. Leyre

    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).

    • admin

      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.

  4. Leyre

    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

    • admin

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

  5. ley

    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

    • admin

      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.

  6. Stefano

    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

    • admin

      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

  7. 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 🙁

      • 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!

      • Sunny

        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

  8. MAT

    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

  9. yasar

    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 ?

  10. 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 ?

  11. NeedhelpASAP

    Hi admin im really really hopeful that you’d reply me ASAP. The coding for me works just fine and when i open the serial plotter, i get a really stable and responsive values for the red and blue line. the green line however is not very responsive and i keep getting spikes on that value as well and the value stays positive (is it supposed to be that way?). i was just thinking it might be the equations within the coding. this is just a beginner’s guess. Im a beginner at this so pardon the mundane language that i use to describe my situation. i hope you’ll help me resolve this problem, thanks.

  12. Fardz

    Can you please tell me the units in which the ouput is printing?
    I want an ouput that gives acceleration in g’s, rotational velocity in deg/sec and values from compass in degrees?

Leave a Reply

Your email address will not be published. Required fields are marked *