# pluscrafter/i2cdevlib architecture

> Architecture diagram of the GitHub repository pluscrafter/i2cdevlib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pluscrafter/i2cdevlib
- Repository: https://github.com/pluscrafter/i2cdevlib

## Overview

##### Project type and purpose
- This is an open-source, cross-platform I²C device driver library (“i2cdevlib”).
- Purpose: provide a uniform C/C++ interface (I2Cdev) and per-device classes (e.g., MPU6050, ADXL345) that abstract away platform-specific I²C/TWI details, plus example code and Doxygen-style documentation.

##### File structure
Top level:
- .gitignore, README
- Platform directories: Arduino, EFM32, ESP32_ESP-IDF, Jennic, MSP430, PIC18, RaspberryPi_bcm2835, STM32, STM32_HAL, dsPIC30F, nRF51
Inside each platform:
- A generic I2Cdev implementation (I2Cdev.cpp/h or .c/.h)
- Device-specific folders or components (e.g., MPU6050/, ADXL345/) containing .cpp/.c and .h files and “examples” subfolders with sample sketches/programs
- Some have platform build configs (Makefile, component.mk, nbproject files)
Shared:
- The generic device classes in Arduino/ and in each platform—they all depend on I2Cdev.
- Examples scattered under each device directory demonstrate usage.

##### README for additional insights
- Core abstraction class: I2Cdev
- Device classes derive from it to implement register-level operations described in device datasheets
- The I2Cdev class is static (one instance across all devices)
- Users include only the headers they need and link platform sources accordingly
- Documentation is generated via Doxygen from code comments

##### Elements
- Clear labels for each layer/component (e.g., “Device Classes”, “I2Cdev Core”, “Platform I2C HAL”, “Hardware”)
Examples → Device Classes → I2Cdev Core → Platform I2C HAL → Hardware
Source → Doxygen → HTML Docs
- Blue rectangles for code modules (Device, Core, PAL)
- Yellow parallelograms for examples/apps

##### Detailed capture of essential elements
- For each platform, show:
[Platform Folder]
└─ I2Cdev implementation
└─ Device classes (common list)
└─ Examples
- In the center, illustrate the generic Device API layer re-used across all platforms
- Side note: annotate that adding a new device only requires a new folder under Device Abstraction, and a new platform only requires a new PAL layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application / Examples
    subgraph "Application / Examples"
        Arduino_Examples["Arduino Examples"]:::examples
        ESP32_Example["ESP32 Example"]:::examples
        PIC18_Example["PIC18 Example"]:::examples
        dsPIC30F_Example["dsPIC30F Example"]:::examples
        RaspberryPi_Example["RaspberryPi Example"]:::examples
    end

    %% Device Abstraction Layer
    subgraph "Device Abstraction Layer"
        Arduino_MPU6050["MPU6050 (Arduino)"]:::code
        Arduino_ADXL345["ADXL345 (Arduino)"]:::code
        ESP32_MPU6050["MPU6050 (ESP32)"]:::code
        Jennic_MPU6050["MPU6050 (Jennic)"]:::code
        MSP430_MPU6050["MPU6050 (MSP430)"]:::code
        PIC18_MPU6050["MPU6050 (PIC18)"]:::code
        dsPIC30F_MPU6050["MPU6050 (dsPIC30F)"]:::code
        STM32_MPU6050["MPU6050 (STM32)"]:::code
        RPi_MPU6050["MPU6050 (RaspberryPi)"]:::code
    end

    %% Core I2C Layer
    subgraph "Core I2C Layer (I2Cdev)"
        Arduino_I2Cdev["I2Cdev (Arduino)"]:::code
        EFM32_I2Cdev["I2Cdev (EFM32)"]:::code
        ESP32_I2Cdev["I2Cdev (ESP32)"]:::code
        Jennic_I2Cdev["I2Cdev (Jennic)"]:::code
        MSP430_I2Cdev["I2Cdev (MSP430)"]:::code
        PIC18_I2Cdev["I2Cdev (PIC18)"]:::code
        dsPIC30F_I2Cdev["I2Cdev (dsPIC30F)"]:::code
        nRF51_I2Cdev["I2Cdev (nRF51)"]:::code
        RPi_I2Cdev["I2Cdev (RPi)"]:::code
        STM32_I2Cdev["I2Cdev (STM32)"]:::code
    end

    %% Platform Abstraction Layer
    subgraph "Platform Abstraction Layer (PAL)"
        Wire["Wire.h (Arduino PAL)"]:::code
        STM32HAL_I2Cdev["I2Cdev (STM32_HAL)"]:::code
        ESP32_MK["component.mk (ESP32 PAL)"]:::code
        PIC18_nbproject["nbproject (PIC18)"]:::code
    end

    %% Hardware / SDK
    subgraph "Platform SDK / Hardware"
        Arduino_Core["Arduino Core"]:::hw
        ESP_IDF["ESP-IDF"]:::hw
        CMSIS_HAL["CMSIS/HAL"]:::hw
        bcm2835["bcm2835"]:::hw
        Toolchains["Vendor Toolchains"]:::hw
    end

    %% Documentation
    subgraph "Documentation Generator"
        Doxygen["Doxygen"]:::docs
        README["README"]:::docs
    end

    %% Connections: Examples to Device
    Arduino_Examples -->|uses| Arduino_MPU6050
    Arduino_Examples -->|uses| Arduino_ADXL345
    ESP32_Example -->|uses| ESP32_MPU6050
    PIC18_Example -->|uses| PIC18_MPU6050
    dsPIC30F_Example -->|uses| dsPIC30F_MPU6050
    RaspberryPi_Example -->|uses| RPi_MPU6050

    %% Connections: Device to Core
    Arduino_MPU6050 -->|calls| Arduino_I2Cdev
    Arduino_ADXL345 -->|calls| Arduino_I2Cdev
    ESP32_MPU6050 -->|calls| ESP32_I2Cdev
    Jennic_MPU6050 -->|calls| Jennic_I2Cdev
    MSP430_MPU6050 -->|calls| MSP430_I2Cdev
    PIC18_MPU6050 -->|calls| PIC18_I2Cdev
    dsPIC30F_MPU6050 -->|calls| dsPIC30F_I2Cdev
    STM32_MPU6050 -->|calls| STM32_I2Cdev
    RPi_MPU6050 -->|calls| RPi_I2Cdev

    %% Connections: Core to PAL
    Arduino_I2Cdev -->|adapts| Wire
    STM32_I2Cdev -->|adapts| STM32HAL_I2Cdev
    ESP32_I2Cdev -->|adapts| ESP32_MK
    PIC18_I2Cdev -->|adapts| PIC18_nbproject

    %% Connections: PAL to Hardware
    Wire -->|driver| Arduino_Core
    STM32HAL_I2Cdev -->|driver| CMSIS_HAL
    ESP32_MK -->|buildcfg| ESP_IDF
    PIC18_nbproject -->|toolchain| Toolchains
    RPi_I2Cdev -->|adapts| bcm2835

    %% Documentation flows
    Arduino_I2Cdev -->|docs| Doxygen
    Arduino_MPU6050 -->|docs| Doxygen
    README -->|instructions| Doxygen

    %% Click Events for Examples
    click Arduino_Examples "https://github.com/pluscrafter/i2cdevlib/tree/master/Arduino/MPU6050/examples"
    click Arduino_Examples "https://github.com/pluscrafter/i2cdevlib/tree/master/Arduino/ADXL345/examples"
    click ESP32_Example "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/main/example.cpp"
    click ESP32_Example "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/main/main.cpp"
    click PIC18_Example "https://github.com/pluscrafter/i2cdevlib/blob/master/PIC18/MPU6050/Examples/MPU6050_raw.X"
    click dsPIC30F_Example "https://github.com/pluscrafter/i2cdevlib/blob/master/dsPIC30F/MPU6050/Examples/MPU6050_example.X"
    click RaspberryPi_Example "https://github.com/pluscrafter/i2cdevlib/tree/master/RaspberryPi_bcm2835/ADXL345/examples"

    %% Click Events for Device Classes
    click Arduino_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.cpp"
    click Arduino_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h"
    click Arduino_ADXL345 "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/ADXL345/ADXL345.cpp"
    click Arduino_ADXL345 "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/ADXL345/ADXL345.h"
    click ESP32_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/components/MPU6050/MPU6050.cpp"
    click ESP32_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/components/MPU6050/MPU6050.h"
    click Jennic_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/Jennic/MPU6050/MPU6050.c"
    click Jennic_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/Jennic/MPU6050/MPU6050.h"
    click MSP430_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/MSP430/MPU6050/MPU6050.cpp"
    click MSP430_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/MSP430/MPU6050/MPU6050.h"
    click PIC18_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/PIC18/MPU6050/MPU6050.c"
    click PIC18_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/PIC18/MPU6050/MPU6050.h"
    click dsPIC30F_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/dsPIC30F/MPU6050/MPU6050.c"
    click dsPIC30F_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/dsPIC30F/MPU6050/MPU6050.h"
    click STM32_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32/MPU6050/MPU6050.c"
    click STM32_MPU6050 "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32/MPU6050/MPU6050.h"
    click RPi_MPU6050 "https://github.com/pluscrafter/i2cdevlib/tree/master/RaspberryPi_bcm2835/MPU6050"

    %% Click Events for Core I2C Layer
    click Arduino_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/I2Cdev/I2Cdev.cpp"
    click Arduino_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/Arduino/I2Cdev/I2Cdev.h"
    click EFM32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/EFM32/I2Cdev/I2Cdev.cpp"
    click EFM32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/EFM32/I2Cdev/I2Cdev.h"
    click ESP32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/components/I2Cdev/I2Cdev.cpp"
    click ESP32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/components/I2Cdev/I2Cdev.h"
    click Jennic_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/Jennic/I2Cdev/I2Cdev.c"
    click Jennic_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/Jennic/I2cdev/I2Cdev.h"
    click MSP430_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/MSP430/I2Cdev/I2Cdev.cpp"
    click MSP430_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/MSP430/I2Cdev/I2Cdev.h"
    click PIC18_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/PIC18/I2Cdev/I2Cdev.c"
    click PIC18_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/PIC18/I2Cdev/I2Cdev.h"
    click dsPIC30F_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/dsPIC30F/I2Cdev/I2Cdev.c"
    click dsPIC30F_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/dsPIC30F/I2Cdev/I2Cdev.h"
    click nRF51_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/nRF51/I2CDev/I2Cdev.cpp"
    click nRF51_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/nRF51/I2CDev/I2Cdev.h"
    click RPi_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/RaspberryPi_bcm2835/I2Cdev/I2Cdev.cpp"
    click RPi_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/RaspberryPi_bcm2835/I2Cdev/I2Cdev.h"
    click STM32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32/I2Cdev.c"
    click STM32_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32/I2Cdev.h"

    %% Click Events for PAL
    click STM32HAL_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32_HAL/Nucleo-144F722ZE/Src/I2Cdev.cpp"
    click STM32HAL_I2Cdev "https://github.com/pluscrafter/i2cdevlib/blob/master/STM32_HAL/Nucleo-144F722ZE/Inc/I2Cdev.h"
    click ESP32_MK "https://github.com/pluscrafter/i2cdevlib/blob/master/ESP32_ESP-IDF/components/I2Cdev/component.mk"

    %% Click Event for Documentation
    click README "https://github.com/pluscrafter/i2cdevlib/tree/master/README"

    %% Styles
    classDef code fill:#D0E8FF,stroke:#036;
    classDef examples fill:#FFF4B8,stroke:#886;
    classDef hw fill:#DFFFD0,stroke:#292;
    classDef docs fill:#FFE0B2,stroke:#B65;
```
