Source: https://mokxi.com/learn/path/sensor-fusion-and-kalman
Updated: 2026-11-20

All paths

# Sensor fusion and the Kalman filter

The math behind fusing sensors, honest about its limits: noise as variance, the EMA, the complementary filter derived, the Kalman filter from one state to two, GPS fused with a compass, and an attitude display that learns its gyro biases.

Arduino Uno R3 Free 7 lessons 7 h 4 chapters 3,920 XP Robotics · Expert +400 XP

0 of 7 done

Start the course free Noise, measured Lesson plan for teachers

What you will build

## 3 projects, built step by step

7 lessons in 4 chapters, about 7 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Moving average and EMA

Two smoothing filters on the same noise: a moving average of 8 and an exponential moving average. Predict how much noise each removes and how long each lags, measure both with a step test, and trade one for the other.
Open it in the simulator

Chapter 2 project

### The 1D Kalman filter

One state, four lines: predict, gain, update, shrink. Work the first steps by hand, watch the gain settle to the steady state Q and R set, catch a move with the innovation test, and see what a wrong R does.
Open it in the simulator

Chapter 3 project

### GPS plus IMU

A NEO-6M GPS and an MPU-9250 compass fused into one position: dead reckoning from speed and heading between fixes, a gain that weighs each fix, the error measured against the truth, a GPS outage, and a compass that is 10 degrees wrong.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Noise, measured

Variance, the square-root law, and the noise and lag of the two everyday smoothing filters.

Open 380 XP

### Noise, measured

Every filter starts from a number for the noise. Measure a noisy pitch in windows of 200: mean, standard deviation, variance and the 68-95 rule, then see averaging cut the noise by the square root of the count.

0 of 6 steps

Start What is in it

Project Locked 760 XP

### Moving average and EMA

Two smoothing filters on the same noise: a moving average of 8 and an exponential moving average. Predict how much noise each removes and how long each lags, measure both with a step test, and trade one for the other.

0 of 6 steps

5 questions, graded as you go.

Chapter 2

## From fusion to Kalman

The complementary filter derived, then the scalar Kalman filter worked to its steady state.

Locked 380 XP

### The complementary filter, derived

The filter you tuned by hand, done properly: alpha from tau and dt, the crossover frequency where gyro hands over to gravity, the steady error a bias leaves (bias x tau), and the accelerometer noise that gets through, each predicted and then measured.

0 of 6 steps

Project Locked 760 XP

### The 1D Kalman filter

One state, four lines: predict, gain, update, shrink. Work the first steps by hand, watch the gain settle to the steady state Q and R set, catch a move with the innovation test, and see what a wrong R does.

0 of 6 steps

5 questions, graded as you go.

Chapter 3

## Kalman for real

Angle and bias in a two-state filter, and a GPS fused with a compass, wrong compass included.

Locked 380 XP

### Kalman for tilt

The gallery’s Kalman filter tilt angle: an MPU6050 through TKJ Electronics’ two-state filter, angle and gyro bias, plotted beside the accelerometer, the gyro alone and a complementary filter. Read the 2 x 2 matrices, follow a tilt, and tighten the level.

0 of 6 steps

Project Locked 860 XP

### GPS plus IMU

A NEO-6M GPS and an MPU-9250 compass fused into one position: dead reckoning from speed and heading between fixes, a gain that weighs each fix, the error measured against the truth, a GPS outage, and a compass that is 10 degrees wrong.

0 of 7 steps

5 questions, graded as you go.

Chapter 4

## Boss build

An artificial horizon that learns its gyro biases and holds steady through a shake.

Locked 400 XP

### Boss: a steady attitude display

An artificial horizon on an SSD1306 OLED, driven by two two-state Kalman filters written out in the sketch: they learn each gyro’s bias while they run, follow a tilt, and hold steady through a shake by trusting the gyro while the accelerometer lies.

0 of 7 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Noise, measured

- Noise, measured Every filter starts from a number for the noise. Measure a noisy pitch in windows of 200: mean, standard deviation, variance and the 68-95 rule, then see averaging cut the noise by the square root of the count.
- Moving average and EMA Two smoothing filters on the same noise: a moving average of 8 and an exponential moving average. Predict how much noise each removes and how long each lags, measure both with a step test, and trade one for the other.

Chapter 2

### From fusion to Kalman

- The complementary filter, derived The filter you tuned by hand, done properly: alpha from tau and dt, the crossover frequency where gyro hands over to gravity, the steady error a bias leaves (bias x tau), and the accelerometer noise that gets through, each predicted and then measured.
- The 1D Kalman filter One state, four lines: predict, gain, update, shrink. Work the first steps by hand, watch the gain settle to the steady state Q and R set, catch a move with the innovation test, and see what a wrong R does.

Chapter 3

### Kalman for real

- Kalman for tilt The gallery’s Kalman filter tilt angle: an MPU6050 through TKJ Electronics’ two-state filter, angle and gyro bias, plotted beside the accelerometer, the gyro alone and a complementary filter. Read the 2 x 2 matrices, follow a tilt, and tighten the level.
- GPS plus IMU A NEO-6M GPS and an MPU-9250 compass fused into one position: dead reckoning from speed and heading between fixes, a gain that weighs each fix, the error measured against the truth, a GPS outage, and a compass that is 10 degrees wrong.

Chapter 4

### Boss build

- Boss: a steady attitude display An artificial horizon on an SSD1306 OLED, driven by two two-state Kalman filters written out in the sketch: they learn each gyro’s bias while they run, follow a tilt, and hold steady through a shake by trusting the gyro while the accelerometer lies.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Sensor fusion and the Kalman filter

Is Sensor fusion and the Kalman filter free?

Yes. All 7 lessons of Sensor fusion and the Kalman filter are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Sensor fusion and the Kalman filter take?

About 7 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Moving average and EMA, The 1D Kalman filter and GPS plus IMU.

Where do I start?

With "Noise, measured", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
