finds.dev

leech001/MPU6050

STM32 HAL library for GY-521 (MPU6050) with Kalman filter

View on GitHub

★ 526CGPL-3.0updated Sep 2023

// the take

A small STM32 HAL wrapper around the MPU6050/GY-521 IMU that reads raw accel/gyro values over I2C and layers a Kalman filter on top to spit out filtered pitch/roll angles. It's aimed at hobbyists doing CubeMX-generated STM32 projects who want tilt angles without writing their own filter math.

The Kalman filter implementation (borrowed from TKJElectronics' well-known Arduino port) is a real addition over the dozens of bare register-read MPU6050 libraries out there — you get MPU6050.KalmanAngleX/Y directly instead of doing sensor fusion yourself. It ships a full working example project (STM32F401CCU6, .ioc file and all) rather than just a snippet, so you can see the exact CubeMX I2C config that's expected. Single .c/.h pair with no external dependencies beyond the HAL makes it trivial to drop into an existing project.

Everything is blocking: MPU6050_Read_All uses polled HAL_I2C calls and the init pattern (while (MPU6050_Init(&hi2c1) == 1);) will spin forever with no timeout if the sensor is miswired or the bus locks up — there's no error path at all. No calibration/offset handling for accel or gyro bias, so out of the box the angles will have a static error that varies per unit. README is purely a CubeMX click-through guide (in English and Russian) with zero documentation of the MPU6050_t struct fields, filter tuning constants, or how to change the I2C address for AD0-high boards. No tests, no CI, and no commits since September 2023, so if STM32CubeIDE/HAL conventions shift under it, nobody's watching.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
526
Forks
84
Language
C
License
GPL-3.0
Last commit
17 Sep 2023

// nearby

If MPU6050 isn't quite it.

All repos →