Tune a Complementary Filter

Tune a Complementary Filter

animation
sensors

Tune a Complementary Filter

A complementary filter blends short-term gyro motion with a tilt estimate from gravity. Change its weight and test both noise and drift before choosing a setting.

Note

Goal: Using the complementary filter from the production worked example, experiment with different alpha values on an MPU6050 IMU connected to an ESP32.

Challenge tasks:

Start by set alpha = 0.80 and shake the board. How much vibration noise do you see? Then set alpha = 0.995. Hold still for 5 minutes. How much drift accumulates? Next find the alpha that gives the best balance for your application. Finally plot accelerometer-only, gyro-only, and fused angles on the serial plotter to visualize the improvement.

Back to the chapter