# kriswiner/mpu9250 architecture

> Architecture diagram of the GitHub repository kriswiner/mpu9250, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kriswiner/mpu9250
- Repository: https://github.com/kriswiner/mpu9250

## Overview

This repository is a collection of embedded MPU-9250/AK8963 sensor-fusion examples, not a single application. The principal workflow initializes and reads motion sensors, calibrates/scales measurements, applies Madgwick or Mahony quaternion fusion, and presents results. Documented branches cover dual sensors, AK8963-as-slave operation, STM32F401, and pressure-sensor/flash add-on examples. Some sketch implementations were not sampled, so their internal call relationships are not asserted.

Main entry points: [`MPU9250_MS5637_AHRS_t3.ino`](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5637_AHRS_t3.ino) (Teensy AHRS sketch), [`STM32F401/main.cpp`](https://github.com/kriswiner/mpu9250/blob/master/STM32F401/main.cpp) (STM32F401 application), [`MPU9250_BME280_SPIFlash_Ladybug/MPU9250_BME280_SPIFlash_Ladybug.ino`](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/MPU9250_BME280_SPIFlash_Ladybug.ino) (BME280 flash sketch), [`MPU9250BasicAHRS.ino`](https://github.com/kriswiner/mpu9250/blob/master/MPU9250BasicAHRS.ino) (Basic AHRS sketches)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Sensor Capture"]
  node_sensor_driver["MPU9250 driver<br/>[MPU9250.cpp]"]
  node_ak_driver["AK8963 slave driver<br/>[MPU9250.cpp]"]
  node_dual_driver["Dual sensor driver<br/>[MPU9250.cpp]"]
  node_stm_driver["STM32 sensor driver<br/>[MPU9250.h]"]
end

subgraph group_fusion["Fusion and Output"]
  node_main_sketch["Teensy AHRS sketch"]
  node_filters["Quaternion filters"]
  node_basic_sketches["Basic AHRS sketches"]
  node_display["Display or serial output"]
end

subgraph group_variants["Board Variants"]
  node_stm_sketch["STM32F401 application<br/>[main.cpp]"]
  node_dual_sketch["Dual MPU sketch"]
  node_ak_sketch["AK8963 slave sketch"]
end

subgraph group_addons["Add-on Sensors and Storage"]
  node_pressure_sketches["Pressure sensor sketches"]
  node_pressure_variants["Altimeter variants"]
  node_mpl_sketch["MPL3115A2 sketch"]
  node_ms_sketch["MS5611 sketch"]
  node_ms5637_sketch["MS5637 sketch"]
  node_bme_driver["BME280 driver<br/>[BME280.cpp]"]
  node_flash_driver["SPI flash driver<br/>[SPIFlash.cpp]"]
  node_bme_sketch["BME280 flash sketch"]
end

node_user(("Embedded user"))

node_user -->|"runs"| node_main_sketch
node_main_sketch -->|"uses fusion"| node_filters
node_main_sketch -.->|"reads sensors"| node_sensor_driver
node_main_sketch -->|"presents results"| node_display
node_user -->|"runs"| node_basic_sketches
node_basic_sketches -->|"uses fusion"| node_filters
node_user -->|"runs"| node_stm_sketch
node_stm_sketch -->|"reads sensors"| node_stm_driver
node_stm_sketch -->|"presents results"| node_display
node_user -->|"runs"| node_dual_sketch
node_dual_sketch -.->|"uses dual sensors"| node_dual_driver
node_user -->|"runs"| node_ak_sketch
node_ak_sketch -.->|"uses slave sensor"| node_ak_driver
node_user -->|"runs"| node_pressure_sketches
node_user -->|"runs"| node_pressure_variants
node_user -->|"runs"| node_mpl_sketch
node_user -->|"runs"| node_ms_sketch
node_user -->|"runs"| node_ms5637_sketch
node_user -.->|"runs"| node_bme_sketch
node_bme_sketch -.->|"uses sensor"| node_bme_driver
node_bme_sketch -.->|"uses storage"| node_flash_driver

click node_main_sketch "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5637_AHRS_t3.ino"
click node_filters "https://github.com/kriswiner/mpu9250/blob/master/quaternionFilters.ino"
click node_basic_sketches "https://github.com/kriswiner/mpu9250/blob/master/MPU9250BasicAHRS.ino"
click node_sensor_driver "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/MPU9250.cpp"
click node_ak_driver "https://github.com/kriswiner/mpu9250/blob/master/AK8963_as_slave/MPU9250.cpp"
click node_dual_driver "https://github.com/kriswiner/mpu9250/blob/master/Dual_MPU9250/MPU9250.cpp"
click node_stm_driver "https://github.com/kriswiner/mpu9250/blob/master/STM32F401/MPU9250.h"
click node_stm_sketch "https://github.com/kriswiner/mpu9250/blob/master/STM32F401/main.cpp"
click node_dual_sketch "https://github.com/kriswiner/mpu9250/blob/master/Dual_MPU9250/Dual_MPU9250_dual_Ladybug.ino"
click node_ak_sketch "https://github.com/kriswiner/mpu9250/blob/master/AK8963_as_slave/AK8963Slave0_MPU9250_Ladybug.ino"
click node_pressure_sketches "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BMP280_BasicAHRS_t3.ino"
click node_pressure_variants "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_LPS25H_BasicAHRS_t3.ino"
click node_mpl_sketch "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MPL3115A2_BasicAHRS_t3.ino"
click node_ms_sketch "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5611_BasicAHRS_t3.ino"
click node_ms5637_sketch "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5637_AHRS_t3.ino"
click node_bme_driver "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/BME280.cpp"
click node_flash_driver "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/SPIFlash.cpp"
click node_bme_sketch "https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/MPU9250_BME280_SPIFlash_Ladybug.ino"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sensor_driver,node_ak_driver,node_dual_driver,node_stm_driver,node_user toneBlue
class node_main_sketch,node_filters,node_basic_sketches,node_display toneAmber
class node_stm_sketch,node_dual_sketch,node_ak_sketch toneMint
class node_pressure_sketches,node_pressure_variants,node_mpl_sketch,node_ms_sketch,node_ms5637_sketch,node_bme_driver,node_flash_driver,node_bme_sketch toneRose
```

## Components

### Sensor Capture

- [MPU9250 driver](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/MPU9250.cpp): `MPU9250_BME280_SPIFlash_Ladybug/MPU9250.cpp`
- [AK8963 slave driver](https://github.com/kriswiner/mpu9250/blob/master/AK8963_as_slave/MPU9250.cpp): `AK8963_as_slave/MPU9250.cpp`
- [Dual sensor driver](https://github.com/kriswiner/mpu9250/blob/master/Dual_MPU9250/MPU9250.cpp): `Dual_MPU9250/MPU9250.cpp`
- [STM32 sensor driver](https://github.com/kriswiner/mpu9250/blob/master/STM32F401/MPU9250.h): `STM32F401/MPU9250.h`

### Fusion and Output

- [Teensy AHRS sketch](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5637_AHRS_t3.ino): `MPU9250_MS5637_AHRS_t3.ino`
- [Quaternion filters](https://github.com/kriswiner/mpu9250/blob/master/quaternionFilters.ino): `quaternionFilters.ino`
- [Basic AHRS sketches](https://github.com/kriswiner/mpu9250/blob/master/MPU9250BasicAHRS.ino): `MPU9250BasicAHRS.ino`
- **Display or serial output**

### Board Variants

- [STM32F401 application](https://github.com/kriswiner/mpu9250/blob/master/STM32F401/main.cpp): `STM32F401/main.cpp`
- [Dual MPU sketch](https://github.com/kriswiner/mpu9250/blob/master/Dual_MPU9250/Dual_MPU9250_dual_Ladybug.ino): `Dual_MPU9250/Dual_MPU9250_dual_Ladybug.ino`
- [AK8963 slave sketch](https://github.com/kriswiner/mpu9250/blob/master/AK8963_as_slave/AK8963Slave0_MPU9250_Ladybug.ino): `AK8963_as_slave/AK8963Slave0_MPU9250_Ladybug.ino`

### Add-on Sensors and Storage

- [Pressure sensor sketches](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BMP280_BasicAHRS_t3.ino): `MPU9250_BMP280_BasicAHRS_t3.ino`
- [Altimeter variants](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_LPS25H_BasicAHRS_t3.ino): `MPU9250_LPS25H_BasicAHRS_t3.ino`
- [MPL3115A2 sketch](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MPL3115A2_BasicAHRS_t3.ino): `MPU9250_MPL3115A2_BasicAHRS_t3.ino`
- [MS5611 sketch](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5611_BasicAHRS_t3.ino): `MPU9250_MS5611_BasicAHRS_t3.ino`
- [MS5637 sketch](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_MS5637_AHRS_t3.ino): `MPU9250_MS5637_AHRS_t3.ino`
- [BME280 driver](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/BME280.cpp): `MPU9250_BME280_SPIFlash_Ladybug/BME280.cpp`
- [SPI flash driver](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/SPIFlash.cpp): `MPU9250_BME280_SPIFlash_Ladybug/SPIFlash.cpp`
- [BME280 flash sketch](https://github.com/kriswiner/mpu9250/blob/master/MPU9250_BME280_SPIFlash_Ladybug/MPU9250_BME280_SPIFlash_Ladybug.ino): `MPU9250_BME280_SPIFlash_Ladybug/MPU9250_BME280_SPIFlash_Ladybug.ino`

### Other components

- **Embedded user**

## Connections

- Embedded user → Teensy AHRS sketch: runs (evidence: `README.md`)
- Teensy AHRS sketch → Quaternion filters: uses fusion (evidence: `README.md`)
- Teensy AHRS sketch → MPU9250 driver: reads sensors
- Teensy AHRS sketch → Display or serial output: presents results (evidence: `README.md`)
- Embedded user → Basic AHRS sketches: runs (evidence: `README.md`)
- Basic AHRS sketches → Quaternion filters: uses fusion (evidence: `README.md`)
- Embedded user → STM32F401 application: runs (evidence: `README.md`)
- STM32F401 application → STM32 sensor driver: reads sensors (evidence: `STM32F401/main.cpp`)
- STM32F401 application → Display or serial output: presents results (evidence: `STM32F401/main.cpp`)
- Embedded user → Dual MPU sketch: runs (evidence: `README.md`)
- Dual MPU sketch → Dual sensor driver: uses dual sensors
- Embedded user → AK8963 slave sketch: runs (evidence: `README.md`)
- AK8963 slave sketch → AK8963 slave driver: uses slave sensor
- Embedded user → Pressure sensor sketches: runs (evidence: `README.md`)
- Embedded user → Altimeter variants: runs (evidence: `README.md`)
- Embedded user → MPL3115A2 sketch: runs (evidence: `README.md`)
- Embedded user → MS5611 sketch: runs (evidence: `README.md`)
- Embedded user → MS5637 sketch: runs (evidence: `README.md`)
- Embedded user → BME280 flash sketch: runs
- BME280 flash sketch → BME280 driver: uses sensor
- BME280 flash sketch → SPI flash driver: uses storage
