HAL Library 36- AHRS and IMU algorithms for calculating roll, pitch and yaw axes

With this library, it is possible to calculate roll, pitch and yaw axes from 2 or 3 sensors.

By using 2 sensors (Gyro and Accelerometer) you can use IMU or by adding Magnetic sensor, you can use AHRS algorithm to additionally stabilize outputs.

Library is written in ANSI C and works on any device you want. It is not specifically set to be used by STM32 devices.

Algorithms are developed by Sebastian Madgwick. For more info about these algorithms, you should check his website.


Read more about HAL libraries


  • Supports multiple independant calculations for multiple sensors if required
  • Calculates roll, pitch and yaw values from motion sensors
  • It uses 2 or 3 sensors each with 3 axes


  • Platform inpendent library written in ANSI C

Functions and enumerations

Functions and its enumerations can be found on AHRS IMU library API.


Conceptual use is available on my Github account.


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...