SparkFun 9DoF Razor IMU M0

The SparkFun 9DoF Razor IMU M0 combines a SAMD21 microprocessor with an MPU-9250 9DoF (9 Degrees of Freedom) sensor to create a tiny, reprogrammable, multipurpose IMU (Inertial Measurement Unit). It can be programmed to monitor and log motion, transmit Euler angles over a serial port or even act as a step-counting pedometer.

The 9DoF Razor’s MPU-9250 features three 3-axis sensors—an accelerometer, gyroscope and magnetometer—that give it the ability to sense linear acceleration, angular rotation velocity and magnetic field vectors. The onboard microprocessor, Atmel’s SAMD21, is an Arduino-compatible, 32-bit ARM Cortex-M0+ microcontroller also featured on the Arduino Zero and SAMD21 Mini Breakout boards.

In addition to a pair of ICs, the 9DoF Razor IMU includes a µSD card socket, LiPo battery charger, power-control switch, and a host of I/O breakouts for project expansion. It comes preprogrammed with example firmware and an Arduino-compatible bootloader, so you can customize the firmware and flash new code over a USB connection.

Get Started with the 9DoF Razor IMU M0 Guide

  • Integrated MPU-9250 IMU and SAMD21 microprocessor
  • LiPo battery charger
  • µSD card socket
  • Preprogrammed example firmware that streams and/or logs:
    • Accelerometer, gyroscope and magnetometer data…
    • …and/or quaternions, and Euler angles
  • Arduino-programmable via USB
  • New MPU-9250 Arduino library with support for the chip’s digital motion processing capabilities
  • Extra SAMD21 pins broken out
  • System on/off switch

SparkFun 9DoF Razor IMU M0 Product Help and Resources

9DoF Razor IMU M0 Hookup Guide

December 1, 2016

How to use and re-program the 9DoF Razor IMU M0, a combination of ATSAMD21 ARM Cortex-M0 microprocessor and MPU-9250 9DoF-in-a-chip.

To use hardware serial.

For the hardware serial issues, see this forum post:

You need to: * Edit out some code we use for testing in production. See the line beginning with ‘For production testing only’. * Change the baud rate on the ‘Serial1.begin’ line * Change config.h from ‘#define LOG_PORT SERIAL_PORT_USBVIRTUAL’ to ‘#define LOG_PORT SERIAL_PORT_HARDWARE’

Once that is done, upload the revised code and output will be on the RX/TX pins on the edge of the board.

The blue will pulse letting you know you’re in bootloader mode. (double check your COM port, it will change when this happens)

Common question. since it is looking for a “$” for testing. By changing a few lines and printing the string to one of the hardware UARTs, other serial UARTs can read the serial data. Additionally, the serial object is defined here => for the Arduino serial monitor or the hardware serial UART port 1 on pins 0 and 1.



Autonomous robot project combining Arduino Mega and Raspberry Pi. Uses Behavior tree for decision making.

Customer Comments

  • Anyone has a AHRS compatible firmware for it? I looked over here: but they only have support for older Razor boards.

    Any help is welcome!


    • A bit late, but I tried my best to update the firmware to make it compatible with the M0 : see

  • Driver installation on Windows 8.1 Pro doesn’t work. Driver is found but INF file doesn’t contain informations of numerique signature. Could you help me ? Edit: On Windows 10 Family, driver installation is not requiered ! Just plug and play. But I need to work with on my W8.1Pro. Windows says that you are the solution…

  • With the example firmware, the Euler angle Yaw drifts by roughly 1 degree a second when subject to no motion. Is this experienced by others? I’ve seen it on 2/2 boards I have tested. Thanks!

    • What you’re seeing is a very common problem in orientation sensing. As I understand it, the built-in DMP is fusing only the gyro and accelerometer. The magnetometer must be used for stable orientation on all 3 axes, which is the art of 9-DOF sensor fusion. This and many other relevant issues are well described in this wiki.

      As strider points out, there was support for 9DOF fusion in the previous razor board’s library (which was in fact a fork from the repo by the author of that wiki), though it’s mysteriously absent from this new version… it would be great to see this added!

    • I just observed yaw angle after leaving the new razor imu on my table; what you say happens in my Razor as well. I think the angles we observe are estimated only from gyroscope and accelerometer data; if magnetometers are calibrated and included in the estimation, the heading values can be much better. It was better in the previous version of the Razor IMU, in the code written by Peter Bartz. In that code, Peter provided soft and hard iron calibration of magnetometers; the complementary filter used there was taking the magnetometer data into account in heading estimation.

  • Is it possible for this module to spit out the raw IMU data on the I2C bus to another microcontroller and still allow the SAMD21 to control the IMU? Also is it possible to have 2 of these boards on the same I2C bus? I see that the AD0 pin should be set to VCC and will require changing the IMU address on the SAMD21 for each module.

  • For charging, the Razor IMU supplies a 450mA Charge Current. What might happen if I used the Razor IMU to charge a 400mAh battery? eg

    Might this battery explode, or would it just be bad for the health of this battery?

  • Does the µSD card socket happen to support SDHC or SDXC? What is the max SD card capacity supported?

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

  • Is the Atmel’s SAMD21 low-level ARM Cortex libraries compatible with Arduino Due’s AT91SAM3X8E micro-controller?

    I want to know if I can use this 9Dof IMU at full capabilities with the Arduino Due instead of Zero.

  • If I am using the DMP example I get a drift of one degree about every 3.5 minutes. I thought it odd because the old 9DOF Razor’s magnetometer compensated for the drifting. With a quick test I noticed that the magnetometer is not being used (putting a magnet nearby shows no change in the yaw).

    Is this by design? Looking at dmp.begin() arguments it appears there is no argument flag for using the magnetometer.

  • Does anyone understood what are the Euler angle axes and the sequence which is used (to decompose quaternions into eulers)? It is supposed to send (pitch, roll, yaw) but I do not get which are the axes of these rotations? Are the Euler axes the ones of the Accelero/Gyrometer? If yes, then it means that the angles which are send should be rotation around the Yaccelero (“Pitch”) , rotation around Xaccelero (“Roll”) and then rotation around Zaccelero (“Yaw”). And therefore the final posture of the board should be easily reconstructed by applying successively -in the correct order YXZ, these three rotations. Does anyone have any clues about this?

  • Hi, I’m trying to get this to send data over the pins marked TX and RX on the 8 pin header on this module. Any idea which Serial port it corresponds to. Nothing seems to be working other than the SerialUSB at the moment.

    • Try specifying Serial1 as the port. I’m doing this to data to a bluetooth LE module over the rx/tx pins.

  • Sorry if this an amateur question, but is it possible to make this a wireless unit with a lipo and a Bluetooth or other such device? If so, what are the connections? Wanting to make a wireless head tracker for PC games like flying and driving.

    • You should definitely be able to do that. The connections will depend on what type of wireless you want to do and how. The easiest is probably a bluetooth/wifi module that you can connect over the hardware serial ports on the board. The other (and much trickier) option is to use the OTG feature on the board and connect a USB boothtooth/wifi dongle. In this case you will probably end up writing ‘drivers’ for it, but it is also possible someone has already done it. Look into the Simblee board, the ESP8266, nRF boards, and the Bluetooth Mate as a few cheaper wireless options. If you have any other questions feel free to email our techsupport department.

      • So using a Bluetooth Mate, its just as simple as

        Razor IMU Mo —-> Bluetooth Mate Silver GND —> GND 3v3 —> VCC TX —> RX RX —> TX

        What does the RTS 0 and CTS I get wired to? Are they needed? Would this then be wireless to a computer paired by Bluetooth using a USB mini module?



  • When I followed the hookup guide, and finished “Install Arduino SAMD Boards” section, first I tried to verify firmware code “_9DoF_Razor_M0_Firmware.ino” but Arduino displayed fatal error: sam.h: No such file or directory. Then I tried to verify and upload “MPU9250_Basic.ino” located at the SF MPU-9250 library. I obtained the same fatal error.. Did anybody face this problem when verifying and uploading code to Razor IMU?

    • Arduino’s latest versions of the SAMD board definition’s (1.6.9+) tripped a few things up with the 9DoF Razor’s board definitions. We just pushed a compatible update to the board manager.

      Update the “SparkFun SAMD Boards” core to 1.3.2 by following the same steps in the Installing the SparkFun Board Definition section of the tutorial, but instead of clicking “Install” click “Update”. That should fix it.

  • Any idea of the fastest sampling rate to the uSD card?

  • Congratulations on the new MPU-9250 library. :D

  • Wouldn’t have been better to have the sensor at the center point of the board? If this board is spun (about the mid-point of the mounting holes), the accelerometer and gyroscope sensors will show periodic variations, rather than a simpler 0 acceleration and pure rotational changes.

  • I’m curious, how does this compare to the Razor board it replaced? Obviously, it uses an ARM processor instead of the Atmel one but how about the sensor itself? It’s an all-in-one unit now but I’m curious if the old one may have any advantage over this one in any way or if this is better all around.

    • This board has a much better IMU sensor. The old one used 3 separate chips for accel, gyro, and mag, while this board uses the all in one MPU-9250 IMU. That alone makes it better, no issues with small misalignments, but also, the newer sensor is generally better; less noise and more sensitive.

Customer Reviews

3 out of 5

Based on 2 ratings:

Currently viewing all customer reviews.

4 of 4 found this helpful:

Euler values are not usable

When configured to output the Euler values, the values drift considerably when the IMU is sitting still on a desk and are erratic to the point to appearing random if the IMU is not perfectly still.

The pitch values oscillate slowly around 0, from 339 degrees to 20 degrees. The roll values also oscillate in a similar fashion between 350 degrees to 10 degrees The yaw values just drift, making a complete 360 in 42 seconds or so.

If you slowly pitch or roll the IMU 30 to 45 degrees the values become erratic.

Update: I sent an email to technical support per Kansukee’s suggestion. It is a week later and I haven’t received any response other than the “Thank you for contacting SparkFun Technical Support” auto-reply.

Sorry to hear about the issues with the Razor IMU.

Have you contacted our technical support team at - they’re usually pretty good at helping to get products working properly, they may have some strategies to help get rid of the erratic drift on the sensor.

So tiny, but so powerful!

I used this to make a quadcopter flight controller. It’s really nice having everything in such a compact package. It makes testing so much easier with everything being on one board. The SAMD21 is a great chip too!