Maybe you are interested in my Arduino sketch specifically written for the MPU-6000 on the ArduIMU+ V3 board from 3DRobotics Inc. It is attached to this post (v053_MPU6000_DMP6_SPI.ino). Please read the header carefully because it contains a lot of useful information.My sketch is based on Jeff Rowberg's MPU6050_DMP6_I2C sketch which makes use of the Digital Motion Processor to obtain the quaternion values from the MPU, and from there derives roll, pitch and yaw without almost any drift. My sketch is a translation of Jeff's sketch and also uses the DMP, but makes use of the SPI protocol i.s.o. the I2C protocol for transferring data (on ArduIMU+ V3 "MPU-6000 uses SPI for max performance"). My sketch works perfectly with the Teapot demo also from Jeff, I only corrected the axis ((Teapot_ArduIMU_V3.pde - attached). Please let me know if you like it. It took me a little over 100 hours to write and test it.



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

Join diydrones


  • Just an FYI -

    Tom said:

    For the APM with the ATMEGA2560 also be sure the change it to use INT6 in the attach interrupt. It seems to compile just fine that way with the stock Arduino IDE.

    // attachInterrupt(interrupt, function, mode) specifies a function to call when an external interrupt occurs
    // ArduIMU+ V3 has ATMEGA328 INT0 / D2 pin 32 (input) connected to MPU-6000 INT pin 12 (output) - Different for the ATMEGA2560
        attachInterrupt(6, dmpDataReady, RISING); // the 6 points correctly to INT6 / PE3
    // -> if there is an interrupt from MPU-6000 to ATMEGA328, boolean mpuInterrupt will be made true

    New I2Cdev lib that runs on SPI. Contribute to tsimon57/I2CdevSPI development by creating an account on GitHub.
  • So what's the verdict?

    Is everyone finally convinced that the DMP is a scam?

    • I wouldn't dare to say... Why do you think it is a scam?

  • see my comment below on how to make this work on the APM Mini with an ATMEGA2560

  • Thanks Martin

     I finally got it working what happened is that my voltage regulator for my APM 2.6 had blown and as such The MPU6000 was receiving 5V instead of the 3.3V required operating voltage. I remedied this problem temporarily by using a AT Mega 2560 board and connecting the the compass with the 3.3V and ground on the board therefore the AT Mega 2560 was supplying the 3.3 volts needed for the Mpu6000 in the long run I have ordered voltage regulators

    This was also the reason for the bad gyro health message I keep observing in mission planner. Once again thank you for your help much appreciated.  helps to understand how to fix voltage regulators

    • Hi Psam,

      Nice to read that you have it all working now!

      Lucky you: MPU-6000 Absolute Maximum Ratings, Supply Voltage VDD: -0.5V to +6V, so the MPU should be undamaged by the 5V supply it accidently got. I'm not sure about the other components - but obviously now you have it working they seem to have all survived.

      Good luck repairing the board with a new 3.3 V regulator. Advise: buy +3.00 dioptry reading glasses (those cheap ones from a drugstore will do fine), this helps tremendously for this kind of miniature soldering, because compared to a normal magnifying glass you still see depth, and are not hampered by holding the magnifying glass or the need to keep the board fixed underneath it.

  • Hey Martin,

    I'm a student trying to get an MPU-6000 working with an M0 processor over SPI. I'm not familiar with arduino or "sketches", but most of this code looks like C, do you have any idea how to port it? I'd be willing to pay for the inconvenience.

    • Hello Tanner,

      Thanks for your interest in my code.

      Unfortunately, I have no coding experience with the ARM Cortex-M0 (or any ARM processor). The Arduino code is indeed C-like, so if you already have experience coding in C or C++, and combined with the comments in my code, you should be able to understand what my code is doing. However, translating it for the M0, I suspect this will be quite a job. I did the translation for Arduino from I2C to SPI (so only the bus interface protocol changed, not the Arduino coding environment), and that took over 100 hours.

      But don't let that stop you from trying!

      Most importantly you should start writing code (or find open source code) which creates the SPI protocol on the M0. I have glanced at the M0 documentation, it provides some kind of serial wire interface, and since SPI is a really simple protocol, it should not be to hard to get a SPI bus working.

      Next step will be a really good understanding of my code, and then translate it piece by piece.Test every small step (so, run the code on the M0 / MPU-6000 board), to see if it works (use a lot of debug statements), and continue building. Give every improved coding file a new number (I always start with _001), to be able to revert to a previously working one if things foul up.

      Given the amount of time that will probably be involved in this, I will not be able to do this port for you, I'm sorry.

      Do you have a specific reason why you want to use the M0 processor over an Arduino? Since for Arduino, all is readily available...

      Best regards, Martin

  • This is what I see in  the serial monitor

    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    Writing DMP configuration... done.
    Verifying DMP configuration... FAILED!
    Writing DMP update 1/7 ..... done.
    Verifying DMP update 1/7 ..... success!
    Writing DMP update 2/7 ..... done.
    Verifying DMP update 2/7 ..... FAILED!

    ############# MPU-6000 Data Acquisition #############
    Initializing SPI Protocol...
    ...SPI Protocol initializing done.
    Initializing Digital Motion Processor (DMP)...
    Writing DMP memory.......... done.
    Verifying DMP memory.......... $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte verification error
    $$$ dmpMemory: byte veri

    • I had the above problem as well when using the Mini APM 2.6.First be sure to change the select pin to 53 for the ATMEGA2560.

      I found a post with the solution. The barometer uses port 40 as its CS. You have to set it to output and write it high to prevent the barometer from taking control of the SPI.

      Add this right before you initialize the SPI.:

      pinMode(40, OUTPUT);
      digitalWrite(40, HIGH); 

      I also made some other changes to do a cleaner reset as per the data shoot for the MPU6000. So my test vehicle had the following for the MPU init:


      byte dmpInitialize()
      // Trigger a full device reset.
      // A small delay of ~50ms may be desirable after triggering a reset.
      DEBUG_PRINTLN(F("Resetting MPU6000..."));
      SPIwrite(0x6B, 0x80, ChipSelPin1); // DEVICE_RESET
      DEBUG_PRINTLN(F("Disabling sleep mode..."));

      SPIwrite(0x68, 0x7, ChipSelPin1); // reset sensors
      delay(100); //
      SPIwrite(0x6A, 0x10 ,ChipSelPin1); // disable I2C
      // Setting the SLEEP bit in the register puts the device into very low power
      // sleep mode. In this mode, only the serial interface and internal registers
      // remain active, allowing for a very low standby current. Clearing this bit
      // puts the device back into normal mode. To save power, the individual standby
      // selections for each of the gyros should be used if any gyro axis is not used
      // by the application.
      // disable sleep mode
      SPIwrite(0x6B, 0x00, ChipSelPin1); // wake up from SLEEP

      // get MPU hardware revision

      <original code resumes here>


      This took a long time to figure out, as I had checked everything in the code twice. Now I just need a I2Cdev lib that has SPI under the hood.....


This reply was deleted.


DIY Drones via Twitter
RT @chr1sa: My talk on PX4 and FAA certification is coming up at 1:45 PST today on the PX4 Dev Summit livestream. Includes some cool new st…
DIY Drones via Twitter
RT @seesharp: I'm tuned into the PX4 / Dronecode free live conference. Great stuff. Microsoft AirSim talk in 10 minutes.…
DIY Robocars via Twitter
RT @masato_ka: 距離センサを3つとESP32を付けたラジコンカーをDonkeyCarライクにNNで自動走行。3層FC極小モデルをTensorFlow Lite for microcontrollerで動かしてる。機体は借り物でRumiCarって言います。Tenso…
DIY Robocars via Twitter
RT @SmallpixelCar: My car was able to go all the way autonomously until the crosswalk. It was only 100 yards from the target. What should b…
Jul 4
Liam left a comment on Agricultural UAVs
I'm Liam from T-MOTOR. I would like to reach out to see if there is any possibility for us to work together.
We are a propulsion system manufacturer who offers motors, propellers and ESCs for all kinds of drone applications which vary from secur…"
Jun 30
DIY Robocars via Twitter
RT @SmallpixelCar: Smart move. The car used the shadow to guide it through the bridge. This was never in the training samples. But it learn…
Jun 30
DIY Robocars via Twitter
RT @SmallpixelCar: Getting closer to the target. Single camera. Untrained road.
Jun 29
Richard Cox left a comment on Australia
"Anyone in the DIYDRONES Australian subgroup based in Alice Springs, NT?
I am experimenting with Ardupilot (standard Arduplane), Pixhawk 4 FC in a 4-ch
RC "AXN Floater Jet" foamy plane..."
Jun 29
Omar Sykes left a comment on Australia
"Hi everyone, I am looking for someone who is good at drone building, repair and software in Adelaide. Please give me a call on 0477 319 219."
Jun 29
DIY Robocars via Twitter
RT @RoboticMasters: #donkeycar
Jun 29
DIY Robocars via Twitter
Jun 29
DIY Robocars via Twitter
RT @RoboticMasters: Donkey car, car car car car car car; Donkey car, car car car car car car; Donkey Car. Anyone like our tiny tiny donkey…
Jun 29
DIY Robocars via Twitter
RT @SmallpixelCar: After improving DBSCAN speed, I can get 11 frame per second on @NVIDIAEmbedded Jerson Xavier MAXN mode and the autonomou…
Jun 26
DIY Robocars via Twitter
RT @Heavy02011: Join us at next Virtual Race League: ⁦@diyrobocars⁩ Race #4 - Parking Lot Nerds, August 1st
Jun 25
DIY Robocars via Twitter
RT @SmallpixelCar: #CUDA implementation should be easy, because most of the time is on distance calculations berween two points and if the…
Jun 25
DIY Robocars via Twitter
RT @SmallpixelCar: This is the view from the car. Even my lanenet inference is fast on @NVIDIAEmbedded Jerson Xavier, DBSCAN clustering tak…
Jun 25