# jarzebski/arduino-mpu6050 architecture

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

- Interactive diagram: https://gitdiagram.com/jarzebski/arduino-mpu6050
- Repository: https://github.com/jarzebski/arduino-mpu6050

## Overview

1. **Repository purpose**
   - This is an **Arduino C++ library** for the **MPU6050** IMU sensor, which combines a **3-axis accelerometer** and **3-axis gyroscope**.
   - The repo is organized around a reusable sensor driver plus a set of small example sketches that demonstrate different measurement modes.

2. **Core library boundary**
   - `MPU6050.h` and `MPU6050.cpp` form the reusable driver layer.
   - This is the main abstraction boundary: application sketches call into the library, and the library handles sensor communication and data interpretation.

3. **Hardware communication path**
   - The library communicates with the sensor over **I2C**, as stated in the README.
   - That means the architectural flow is: **Arduino sketch → MPU6050 library → I2C bus → MPU6050 hardware sensor**.

4. **Sensor capabilities exposed by the library**
   - The library appears to expose several distinct sensing functions:
     - raw/derived **accelerometer readings**
     - raw/derived **gyroscope readings**
     - **pitch/roll** computation from accelerometer data
     - **pitch/roll/yaw** computation from gyroscope data
     - **temperature**
     - **motion** detection
     - **free-fall** detection
   - These correspond directly to the example folders in the repo.

5. **Example sketches as application layer**
   - Each folder under the root examples is an independent Arduino sketch:
     - `MPU6050_accel_simple`
     - `MPU6050_accel_pitch_roll`
     - `MPU6050_gyro_simple`
     - `MPU6050_gyro_pitch_roll_yaw`
     - `MPU6050_temperature`
     - `MPU6050_motion`
     - `MPU6050_free_fall`
   - These sketches are not separate subsystems; they are thin consumers of the same underlying driver.

6. **Data processing split**
   - There is a clear split between **device acquisition** and **derived computation**.
   - Low-level code likely reads registers and raw sensor values; higher-level examples convert those values into orientation or event-based outputs.
   - For architecture diagrams, it helps to show this as: **sensor data acquisition → filtering/interpretation in library/example → output**.

7. **Output/consumption model**
   - The examples likely publish results through the standard Arduino runtime, typically via serial output or similar simple sketch-level reporting.
   - There is no indication of a larger application server, GUI, or network layer in this repo; the library is meant to be embedded in microcontroller sketches.

8. **Repository structure**
   - The repo is intentionally minimal:
     - one reusable library module
     - one README and changelog/license
     - multiple example entry points
   - This structure suggests the library is designed for reuse across projects rather than as a standalone executable application.

9. **External dependency boundary**
   - The only material external dependency implied by the README is the **MPU6050 hardware device** and the Arduino platform’s I2C support.
   - The code’s operational boundary ends at the sensor bus; there are no signs of cloud services, databases, or host-side frameworks.

10. **What to show in an architecture diagram**
   - Depict the system as:
     - **Arduino sketch examples** on one side
     - **MPU6050 library** in the middle
     - **I2C connection**
     - **MPU6050 sensor hardware** on the other side
   - Optionally show the example sketches as separate consumers of the same shared library module.

11. **Overall architectural characterization**
   - This is a **library-centric embedded sensor project**, not an application platform.
   - The main architecture concern is the separation between reusable sensor-driver logic and multiple small demonstration programs that exercise different sensor features.

Main entry points: [`MPU6050.h`](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050.h) (MPU6050.h), [`MPU6050_accel_simple/MPU6050_accel_simple.ino`](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_simple/MPU6050_accel_simple.ino) (Accel simple), [`MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino`](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino) (Accel P/R), [`MPU6050_gyro_simple/MPU6050_gyro_simple.ino`](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_gyro_simple/MPU6050_gyro_simple.ino) (Gyro simple)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_examples["Examples"]
  node_accel_simple["Accel simple<br/>example sketch"]
  node_accel_pr["Accel P/R<br/>example sketch"]
  node_gyro_simple["Gyro simple<br/>example sketch"]
  node_gyro_pry["Gyro P/R/Y<br/>example sketch"]
  node_temperature["Temperature<br/>example sketch"]
  node_motion["Motion<br/>example sketch<br/>[MPU6050_motion.ino]"]
  node_free_fall["Free fall<br/>example sketch"]
end

subgraph group_core["Core library"]
  node_mpu6050_h["MPU6050.h<br/>public API<br/>[MPU6050.h]"]
  node_mpu6050_cpp["MPU6050.cpp<br/>driver impl<br/>[MPU6050.cpp]"]
end

subgraph group_runtime["Runtime"]
  node_arduino_runtime["Arduino<br/>platform"]
  node_serial_output(("Serial<br/>io"))
end

subgraph group_hardware["Hardware"]
  node_i2c_bus["I2C<br/>bus"]
  node_mpu6050_sensor[("MPU6050<br/>imu sensor")]
end

node_accel_simple -->|"uses"| node_mpu6050_h
node_accel_pr -->|"uses"| node_mpu6050_h
node_gyro_simple -->|"uses"| node_mpu6050_h
node_gyro_pry -->|"uses"| node_mpu6050_h
node_temperature -->|"uses"| node_mpu6050_h
node_motion -->|"uses"| node_mpu6050_h
node_free_fall -->|"uses"| node_mpu6050_h
node_mpu6050_h -->|"implements"| node_mpu6050_cpp
node_mpu6050_cpp -->|"reads/writes"| node_i2c_bus
node_i2c_bus -->|"connects"| node_mpu6050_sensor
node_accel_simple -->|"runs on"| node_arduino_runtime
node_accel_pr -->|"runs on"| node_arduino_runtime
node_gyro_simple -->|"runs on"| node_arduino_runtime
node_gyro_pry -->|"runs on"| node_arduino_runtime
node_temperature -->|"runs on"| node_arduino_runtime
node_motion -->|"runs on"| node_arduino_runtime
node_free_fall -->|"runs on"| node_arduino_runtime
node_accel_simple -->|"reports"| node_serial_output
node_accel_pr -->|"reports"| node_serial_output
node_gyro_simple -->|"reports"| node_serial_output
node_gyro_pry -->|"reports"| node_serial_output
node_temperature -->|"reports"| node_serial_output
node_motion -->|"reports"| node_serial_output
node_free_fall -->|"reports"| node_serial_output

click node_mpu6050_h "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050.h"
click node_mpu6050_cpp "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050.cpp"
click node_accel_simple "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_simple/MPU6050_accel_simple.ino"
click node_accel_pr "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino"
click node_gyro_simple "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_gyro_simple/MPU6050_gyro_simple.ino"
click node_gyro_pry "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_gyro_pitch_roll_yaw/MPU6050_gyro_pitch_roll_yaw.ino"
click node_temperature "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_temperature/MPU6050_temperature.ino"
click node_motion "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_motion/MPU6050_motion.ino"
click node_free_fall "https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_free_fall/MPU6050_free_fall.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_accel_simple,node_accel_pr,node_gyro_simple,node_gyro_pry,node_temperature,node_motion,node_free_fall toneBlue
class node_mpu6050_h,node_mpu6050_cpp toneAmber
class node_arduino_runtime,node_serial_output toneMint
class node_i2c_bus,node_mpu6050_sensor toneRose
```

## Components

### Examples

Independent Arduino sketches demonstrating different MPU6050 features.

- [Accel simple](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_simple/MPU6050_accel_simple.ino): example sketch · Basic accelerometer readings. · `MPU6050_accel_simple/MPU6050_accel_simple.ino`
- [Accel P/R](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino): example sketch · Pitch and roll from accelerometer data. · `MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino`
- [Gyro simple](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_gyro_simple/MPU6050_gyro_simple.ino): example sketch · Basic gyroscope readings. · `MPU6050_gyro_simple/MPU6050_gyro_simple.ino`
- [Gyro P/R/Y](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_gyro_pitch_roll_yaw/MPU6050_gyro_pitch_roll_yaw.ino): example sketch · Pitch, roll, and yaw from gyroscope data. · `MPU6050_gyro_pitch_roll_yaw/MPU6050_gyro_pitch_roll_yaw.ino`
- [Temperature](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_temperature/MPU6050_temperature.ino): example sketch · Sensor temperature readings. · `MPU6050_temperature/MPU6050_temperature.ino`
- [Motion](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_motion/MPU6050_motion.ino): example sketch · Motion detection workflow. · `MPU6050_motion/MPU6050_motion.ino`
- [Free fall](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050_free_fall/MPU6050_free_fall.ino): example sketch · Free-fall detection workflow. · `MPU6050_free_fall/MPU6050_free_fall.ino`

### Core library

Reusable MPU6050 driver and public interface.

- [MPU6050.h](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050.h): public API · Library interface used by sketches. · `MPU6050.h`
- [MPU6050.cpp](https://github.com/jarzebski/arduino-mpu6050/blob/dev/MPU6050.cpp): driver impl · Sensor communication and measurement logic. · `MPU6050.cpp`

### Runtime

Arduino platform services used by the sketches and driver.

- **Arduino**: platform · Embedded sketch runtime and core Arduino APIs.
- **Serial**: io · Typical sketch-level reporting channel.

### Hardware

External sensor and bus boundary.

- **I2C**: bus · Communication link between Arduino and the sensor.
- **MPU6050**: imu sensor · External accelerometer/gyroscope device.

## Connections

- Accel simple → MPU6050.h: uses · Sketch calls into the shared library API.
- Accel P/R → MPU6050.h: uses · Sketch calls into the shared library API.
- Gyro simple → MPU6050.h: uses · Sketch calls into the shared library API.
- Gyro P/R/Y → MPU6050.h: uses · Sketch calls into the shared library API.
- Temperature → MPU6050.h: uses · Sketch calls into the shared library API.
- Motion → MPU6050.h: uses · Sketch calls into the shared library API.
- Free fall → MPU6050.h: uses · Sketch calls into the shared library API.
- MPU6050.h → MPU6050.cpp: implements · Header defines the public boundary; cpp provides behavior.
- MPU6050.cpp → I2C: reads/writes · Driver exchanges registers and data over I2C.
- I2C → MPU6050: connects · Physical bus to the IMU device.
- Accel simple → Arduino: runs on · Sketch executes within the Arduino environment.
- Accel P/R → Arduino: runs on · Sketch executes within the Arduino environment.
- Gyro simple → Arduino: runs on · Sketch executes within the Arduino environment.
- Gyro P/R/Y → Arduino: runs on · Sketch executes within the Arduino environment.
- Temperature → Arduino: runs on · Sketch executes within the Arduino environment.
- Motion → Arduino: runs on · Sketch executes within the Arduino environment.
- Free fall → Arduino: runs on · Sketch executes within the Arduino environment.
- Accel simple → Serial: reports · Example output is typically printed from the sketch.
- Accel P/R → Serial: reports · Example output is typically printed from the sketch.
- Gyro simple → Serial: reports · Example output is typically printed from the sketch.
- Gyro P/R/Y → Serial: reports · Example output is typically printed from the sketch.
- Temperature → Serial: reports · Example output is typically printed from the sketch.
- Motion → Serial: reports · Example output is typically printed from the sketch.
- Free fall → Serial: reports · Example output is typically printed from the sketch.
