Comments: 9DoF Razor IMU M0 Hookup Guide


Comments 21 comments

  • There’s an important drift on euler angles. Does the fusion algorithm is embedded in the DMP? is there’s a EKF algorithm perfomed? How to enhance accuracy? the gyr calibration seems not to have any effect on accuracy… may anyone confirm this?

    • The drift also occurs in quaternions. I am working on an important project and the gyro drift is killing me. I wish I could adjust the fusion algorithm so that the gyroscope had little or no effect, but I can’t control that. I also tried the gyro calibration and saw no difference in the data. I would love if there was code for a fusion algorithm that was customizable. Any help would be appreciated.

      • I have found the drift is a significant problem, too. Besides, the roll angle measurement is not correct (the value seems to be doubled, i.e., if it rolls 45 degrees, it would show the roll angle is 90 deg). But anyway, have you found a solution to get accurate Euler angles or quaternions? I used to use another 9dof razor imu (SEN-10736), which is retired but gave very good orientation measures.

  • I find that the pitch and roll angles don’t seem to be independent. I’m using the firmware from the hookup guide that lets you turn the Euler angles on and off with the ‘e’ command and while the yaw seems right, the others are confounded. If you rotate the board about the x axis, the y axis changes significantly as well and vice versa. But rotating about z (laying board on table and twisting) only affects the z axis. Any idea why this is? It’s not very useful if you can’t separate the axes…

  • bboyho / last year * / 2

    ——————– Tech Support Tips/Troubleshooting/Common Issues ——————–

    Serial Output through Hardware UART pins

    The default test code does not output serial data automatically to the hardware Tx and Rx pins. It is currently waiting for a “$” under our QC test procedures [ ]. Depending on what imu value you want printed from the string, you would need to write additional code to print serial data with the correct function [ Serial1.print() or Serial1.println() - ] somewhere around this function => [ ]. Additionally, the serial object is defined here => ] for the Arduino serial monitor or the hardware serial UART port 1 on pins 0 and 1. Be sure to change the baud rate when you initialize the serial port to match the receiving serial device. By changing a few lines and printing the string to one of the hardware UARTs, other serial UARTs can read the serial data.

    If you have not used a serial UART before, try looking at this tutorial for more information about serial communication and UARTs [ ] .

    Problems Uploading

    If you are having problems uploading to the SAMD21, you can try to set the board into bootloader mode. With any AVR device that has a built in CDC (i.e. the Atmega32U4 bootloaded with Arduino on the Pro Micro, FioV3, LilyPad Arduino USB, etc), there should be an option to place the board into bootloader mode if you brick the board. Try following the “ Troubleshooting ” note listed in the tutorial:

    If your 9DoF Razor IMU won’t enter the bootloader, or take new code, you can force it into the bootloader by holding the SCL pin LOW on start up. Flip the IMU’s switch off, use a jumper wire to connect SCL to GND, and turn the switch back on. While in the bootloader, the blue pin 13 LED should remain illuminated.

    You can also ground the tiny plated through hole on the SWD programming pins. Just look at the 9DOF Razor IMU M0 Eagle files to determine the “RESET” pin using the eyeball tool. You can place the SAMD21 in bootloader mode by grounding the RESET pin 2x.

    Arduino Compile Error

    If you are having problems uploading to the 9DOF Razor and you receive this error:

    Arduino: 1.8.2 (Windows 8.1), Board: "SparkFun 9DoF Razor IMU M0"
    In file included from sketch_feb14b.ino:33:0:
    C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\samd\1.3.0\cores\arduino/Arduino.h:48:17: fatal error: sam.h: No such file or directory
    #include "sam.h"
    compilation terminated.
    exit status 1
    Error compiling for board SparkFun 9DoF Razor IMU M0.

    Make sure that you have also installed the SAMD21 Arduino board definitions as stated in the tutorial => . It’s also possible that there is something incompatible with the Arduino IDE that you are using. The error above used’s IDE v1.8.2 and the SAMD21 board definitions and It was resolved by ensuring that the board versions were up to date.

    If there are other compile issues, try checking out the SAMD21 compile errors listed for the other development boards here => .

    • “Serial Output through Hardware UART pins

      The default test code does not output serial data automatically to the hardware Tx and Rx pins. …."

      All I’m after is the identical data I get from the USB serial interface to be sent via the TX RX- so I can tap this from Bluetooth serial using a Bluetooth Mate Gold. Has anybody made a mode of the default test code for this? or can you suggest what I need to add? I’m not a proficient Arduino programmer- just hoping to get the raw sensor data into Max/MSP via serial (bluetooth). I can do all the max bit if I can get the IMU M0 to output the sensor data via the Tx and Rx pins…

      Any help most appreciated!



      • Can I just change the log port below?: (from config.h) //////////////////////// // Serial Port Config // ////////////////////////

        define ENABLE_UART_LOGGING true

        // Select the Serial port to log to. Either SERIAL_PORT_USBVIRTUAL // or LOG_PORT SERIAL_PORT_HARDWARE (SerialUSB or Serial1)


        define SERIAL_BAUD_RATE 115200 // Serial port baud

        EDIT: Ive tried LOG_PORT SERIAL_PORT_HARDWARE and LOG_PORT Serial1 - but still nothing from tx/rx via bluetooth (although this did stop the data coming in over direct serial comms, so on the right track?). Cheers

  • I have the same problem as everyone. the euler angle are not independent. Is someone make the MPU-9250 working correctly with the SAMD21 ? It is a shame to buy something that don’t works correctly… Thanks you

  • Does ‘raw accelerometer data’ imply that it is not calibrated ?

  • I’m struggling getting this device to communicate with my Arduino Due through I2C. Monitoring the Razor on the serial port, as soon as I connect the Due to SDA/SCL the Razor seems to crash. The Due is not even turned on. Same happens when powered up. Any ideas?

  • Hi Everyone, I was having the same drift errors on the Euler angles. This forum post helped a bunch.

  • I cannot make any sense of the data from the demo code. I can see drift from the gyros, but the heading can rotate a full 360 degrees over time. Investigation makes me suspect the magnetics. As a basic test (running the demo code) I should be able to point each of the X/Y/Z axis in the direction of North and get the other 2 axis at near zero (North is in the direction of Mag north and at an angle equal to the ‘dip’ or inclination - about -60 degrees here in Aus). Should be able to then flip the direction and get -ve the same value. (Much like one can do with the acceleration by putting it in various up/down orientations (Which by the way looks fine)

    Numbers dont behave in the slightest like this.

    Another test is to just output ‘Heading’, which by the code is just “heading = atan2(mx, my);” For any orientation - I am only able to get numbers between about 355 degrees through to 15 degrees ( only a 20 degree range)

    Given the detail of the code I have to conclude that probably the chip is faulty. Wondering if anyone else with problems can check this in the interests of seeing if there is maybe a common faulty batch or similar.

  • Does the dmp use calibrated accelerometer and gyroscope data to calculate the quarternions, is calibrated data required for reliable quarternions ?

  • When flashing the IMU, it never succeeds the first time. It goes into a weird mode where the blue light slowly lights up and then slowly turn off, like a breathing mode. And after 5 minutes of sitting like this, if I try to flash it successfully flashes. Anyone encounter a problem similar to this?

  • Hey guys there is a serious issue with playing around with the sampling rate and Digital Low Pass Filter (DLPF) frequencies: First, read this:

    in the section where the DLPF bandwidth is discussed, you’ll notice that you need to have an update rate 2x higher than the DLPF frequency.

    Second, as long as you’re using the DMP, your maximum accelerometer and gyro sampling frequency is tied to 200Hz since that is the maximum frequency for the DMP. If you try any frequency above that, you will encounter significant drift because the DMP cannot keep up with the sensors, and thus cannot correct any drift.

    Hence, you need to keep your accelerometer and gyro sampling frequency at or below the DMP sampling rate, and the DLPF needs to be less than half of the accelerometer and gyro sampling rate. Hope this helps people around.

  • I’d like to configure pins 10-13 as an SPI interface as mentioned briefly in this guide. As a mechanical engineer, I don’t have the best insight as far as programming. Can anyone offer some insight as to how I can accomplish this? Specifically, I’ve been trying to interface the IMU with a SparkFun Transceiver Breakout - nRF24L01+.

    Any suggestions would be appreciated. Thank you.

  • Thanks for the awesome work on this library! I’m attempting to use this on an Arduino MKR1000 with a SparkFun MPU-9250 Breakout Board, the issue I’m having is that after running for a given amount of time, the sketch stops running for the MPU9250_DMP_quaternion example.I am assuming that it has stoped running based on adding a Serial print within the loop outside of any conditional statements which doesn’t print. The time that it runs correctly, outputting data to the serial port. is inversely related to the DMP FIFO rate, i.e the higher the rate the less time it runs. I was wondering whether this could be an issue relating to porting the library on the Arduino MKR100?

If you've found a bug or have other constructive feedback for our tutorial authors, please send us your feedback!