# How to Fuse Motion Sensor Data into AHRS Orientation (Euler/Quaternions)

## Overview

https://www.youtube.com/watch?v=Z0IpAMcecHE

[AHRS](http://en.wikipedia.org/wiki/Attitude_and_heading_reference_system) is an acronym for _ **Attitude and Heading Reference System** _, a system generally used for aircraft of any sort to determine _heading, pitch, roll_, _altitude_ etc.  
  
A basic IMU (Intertial Measurement Unit) generally provides raw sensor data, whereas an AHRS takes this data one step further, converting it into heading or direction in degrees.  
  
To help you get started designing your own AHRS system, or just to help convert raw sensor data into useful numbers that you can relate to the real world, we've created an Arduino library that lets you 'fuse' a range of common accelerometer/gyroscope/magnetometer sensor sets using a few different algorithms such as **Mahony** , **Madgwick** and **NXP Sensor Fusion**.

We recommend a Cortex M0 or faster/greater chipset - there's a lot of math and memory required so 4KB+ or RAM and 32 MHz+ speed helps for the fancier algorithms. That said, you _can_ do some basic fusion with an ATmega328p (Arduino UNO compatible). The data is output on the serial port for easy integration.

1. We'll start by verifying you can store calibrations on your chipset, and then calibrating your sensors.
2. Then we'll compile the AHRS library for your desired sensors and algorithm/
3. Finally we'll visualize the motion using a Web Serial API 3D model.

![](https://cdn-learn.adafruit.com/assets/assets/000/088/497/medium800thumb/sensors_Rabbit10DOF.jpg?1581966922)

- [Next Page](https://learn.adafruit.com/how-to-fuse-motion-sensor-data-into-ahrs-orientation-euler-quaternions/storing-calibrations.md)

## Featured Products

### Adafruit LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel / Gyro / Mag

[Adafruit LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel / Gyro / Mag](https://www.adafruit.com/product/4485)
_This item is discontinued - **you can grab** [Adafruit LSM6DS3 + LIS3MDL - Precision 9 DoF IMU](https://adafruit.com/products/5543) **instead!&nbsp;** _

Add motion,&nbsp;direction and orientation&nbsp;sensing to your Arduino project with this all-in-one 9 Degree...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4485)
[Related Guides to the Product](https://learn.adafruit.com/products/4485/guides)
### Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU

[Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://www.adafruit.com/product/5543)
Add high-quality motion,&nbsp;direction, and orientation&nbsp;sensing to your Arduino project with this all-in-one 9 Degree of Freedom (9-DoF) sensor with sensors from ST. This little breakout contains two chips that sit side-by-side to provide 9 degrees of full-motion data.

The board...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5543)
[Related Guides to the Product](https://learn.adafruit.com/products/5543/guides)
### Adafruit LSM6DSOX + LIS3MDL - Precision 9 DoF IMU

[Adafruit LSM6DSOX + LIS3MDL - Precision 9 DoF IMU](https://www.adafruit.com/product/4517)
Add high-quality motion,&nbsp;direction, and orientation&nbsp;sensing to your Arduino project with this all-in-one 9 Degree of Freedom (9-DoF) sensor with sensors from ST. This little breakout contains two chips that sit side-by-side to provide 9 degrees of full-motion data.

The board...

In Stock
[Buy Now](https://www.adafruit.com/product/4517)
[Related Guides to the Product](https://learn.adafruit.com/products/4517/guides)
### Adafruit Feather nRF52840 Sense

[Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
The **Adafruit Feather Bluefruit Sense** takes our popular [Feather nRF52840 Express](https://www.adafruit.com/product/4062) and adds a smorgasbord of sensors to make a great wireless sensor platform. This Feather microcontroller comes with Bluetooth® Low Energy and...

In Stock
[Buy Now](https://www.adafruit.com/product/4516)
[Related Guides to the Product](https://learn.adafruit.com/products/4516/guides)
### Adafruit CLUE - nRF52840 Express with Bluetooth® LE

[Adafruit CLUE - nRF52840 Express with Bluetooth® LE](https://www.adafruit.com/product/4500)
Do you feel like you just don't have a CLUE? Well, we can help with that - get a CLUE here at Adafruit by picking up this sensor-packed development board. We wanted to build some projects that have a small screen and a lot of sensors. To make it compatible with existing projects, we made...

In Stock
[Buy Now](https://www.adafruit.com/product/4500)
[Related Guides to the Product](https://learn.adafruit.com/products/4500/guides)
### Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1

[Adafruit 9-DOF Accel/Mag/Gyro+Temp Breakout Board - LSM9DS1](https://www.adafruit.com/product/3387)
Add motion, direction and orientation sensing to your Arduino project with this all-in-one 9-DOF sensor. Inside the chip are three sensors, one is a classic 3-axis accelerometer, which can tell you which direction is down towards the Earth (by measuring gravity) or how fast the board is...

In Stock
[Buy Now](https://www.adafruit.com/product/3387)
[Related Guides to the Product](https://learn.adafruit.com/products/3387/guides)
### Adafruit Precision NXP 9-DOF Breakout Board

[Adafruit Precision NXP 9-DOF Breakout Board](https://www.adafruit.com/product/3463)
The NXP Precision 9DoF breakout combines two of the best motion sensors we've tested here at Adafruit: The **FXOS8700** 3-Axis accelerometer and magnetometer, and the **FXAS21002** 3-axis gyroscope.

These two sensors combine to make a nice 9-DoF kit, that...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/3463)
[Related Guides to the Product](https://learn.adafruit.com/products/3463/guides)
### Adafruit LSM6DSOX 6 DoF Accelerometer and Gyroscope

[Adafruit LSM6DSOX 6 DoF Accelerometer and Gyroscope](https://www.adafruit.com/product/4438)
Behold, the ST LSM6DSOX: The latest in a long line of quality Accelerometer+Gyroscope 6-DOF IMUs from ST.

This IMU sensor has 6 degrees of freedom - 3 degrees each of linear acceleration and angular velocity at varying rates within a respectable range. For the accelerometer:...

In Stock
[Buy Now](https://www.adafruit.com/product/4438)
[Related Guides to the Product](https://learn.adafruit.com/products/4438/guides)

## Related Guides

- [LSM6DSOX, ISM330DHC, & LSM6DSO32 6 DoF IMUs](https://learn.adafruit.com/lsm6dsox-and-ism330dhc-6-dof-imu.md)
- [LIS3MDL Triple-axis Magnetometer](https://learn.adafruit.com/lis3mdl-triple-axis-magnetometer.md)
- [Introducing Adafruit CLUE](https://learn.adafruit.com/adafruit-clue.md)
- [Adafruit Feather nRF52840 Sense](https://learn.adafruit.com/adafruit-feather-sense.md)
- [ST 9-DoF Combo Breakouts and Wings](https://learn.adafruit.com/st-9-dof-combo.md)
- [Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://learn.adafruit.com/adafruit-lsm6ds3tr-c-lis3mdl-precision-9-dof-imu.md)
- [Qualia S3 Compass](https://learn.adafruit.com/qualia-s3-compass.md)
- [Adafruit LSM6DS33 6-DoF IMU Breakout](https://learn.adafruit.com/lsm6ds33-6-dof-imu-accelerometer-gyro.md)
- [Pyloton: CircuitPython Cycling Computer](https://learn.adafruit.com/pyloton.md)
- [Using the Bluefruit Dashboard with Web Bluetooth in Chrome](https://learn.adafruit.com/bluefruit-dashboard-web-bluetooth-chrome.md)
- [Programmable Wireless BLE Gesture Mouse](https://learn.adafruit.com/ble-wireless-gesture-mouse.md)
- [Mini LED Matrix Audio Visualizer](https://learn.adafruit.com/mini-led-matrix-audio-visualizer.md)
- [CircuitPython BLE Libraries on Any Computer](https://learn.adafruit.com/circuitpython-ble-libraries-on-any-computer.md)
- [PyLeap CLUE Sensor Plotter](https://learn.adafruit.com/pyleap-clue-sensor-plotter.md)
- [Digital Egg Drop Experiment with CLUE](https://learn.adafruit.com/egg-drop-clue.md)
- [Light-Up Reactive Ukulele](https://learn.adafruit.com/light-up-reactive-ukulele.md)
- [Wearable Continuous Temperature Monitor with Adafruit IO](https://learn.adafruit.com/wearable-temperature-monitor.md)
- [CLUE BLE MIDI Glove](https://learn.adafruit.com/clue-midi-glove.md)
