# yanbe/bme280-esp-idf-i2c architecture

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

- Interactive diagram: https://gitdiagram.com/yanbe/bme280-esp-idf-i2c
- Repository: https://github.com/yanbe/bme280-esp-idf-i2c

## Overview

1. The main application code (located in the “main” directory, with main.c) which initializes and controls the reading process.
2. The sensor component (located in “components/bme280”) that encapsulates the low-level driver logic and communication with the sensor hardware via I2C.

##### Main Components
- ESP32 Hardware: Represent the ESP32 microcontroller, which is running the firmware.
- Main Application Module: The primary application logic (main/main.c) that orchestrates the sensor reading. It’s built using the components defined in the project.
- BME280 Sensor Component: The dedicated driver which communicates with the BME280 sensor. This is stored under “components/bme280” and contains its own build information (component.mk) and driver files.
- I2C Master Driver (ESP-IDF): Although not explicitly within this project’s files, it is an integral part of the stack provided by ESP-IDF that the main application and sensor component call into.
- BME280 Sensor (Hardware): The physical sensor hardware, which is connected via the I2C bus.

##### Relationships and Interactions
- The Main Application Module invokes functions provided by the BME280 Sensor Component.
- The BME280 Sensor Component uses the ESP-IDF I2C master driver (which is part of the ESP-IDF framework) to communicate with the BME280 sensor hardware.
- The physical wiring details (GPIO pins for I2C_SDA and I2C_SCL, along with proper sensor power mapping) should be annotated since the README provides specific guidance regarding GPIO pins and sensor addresses.

##### Architectural Design Patterns and Technical Choices
- Modular Component Design: The project is separated into a “main” module and a “sensor” component, following a modular design typical in ESP-IDF projects.
- Clear Separation Between High-level Application Logic and Hardware Abstraction: The division between the main application and the sensor driver component indicates a separation of concerns.
- Utilization of ESP-IDF’s Build System: Notice the use of component.mk and sdkconfig, which are indicative of how the project is structured and built.
- Hardware-Software Integration: The sensor’s wiring instructions (GPIO 15 for SDA, GPIO 2 for SCL, and sensor Vio mapping) are critical for understanding the real-world integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Configuration Tools
    subgraph "Build & Configuration Tools"
        Makefile("Makefile"):::config
        Sdkconfig("sdkconfig"):::config
    end

    %% Firmware Components
    Main("Main Application (main/main.c)"):::software
    SensorDriver("BME280 Sensor Driver (components/bme280)"):::software
    I2C("I2C Master Driver (ESP-IDF)"):::framework

    %% Target Hardware
    subgraph "Target Hardware"
        ESP32("ESP32 Microcontroller"):::hardware
        SensorHW("BME280 Sensor (Hardware)"):::hardware
    end

    %% Relationships from Build Tools to Firmware
    Makefile -->|"builds"| Main
    Sdkconfig -->|"configures"| Main

    %% Firmware Interactions
    Main -->|"invokes"| SensorDriver
    SensorDriver -->|"calls"| I2C

    %% Firmware Running on ESP32
    Main -->|"runs_on"| ESP32
    SensorDriver -->|"runs_on"| ESP32
    I2C -->|"runs_on"| ESP32

    %% I2C Communication with Sensor Hardware
    I2C -->|"communicates"| SensorHW

    %% Click Events
    click Main "https://github.com/yanbe/bme280-esp-idf-i2c/blob/master/main/main.c"
    click SensorDriver "https://github.com/yanbe/bme280-esp-idf-i2c/tree/master/components/bme280"
    click Makefile "https://github.com/yanbe/bme280-esp-idf-i2c/tree/master/Makefile"
    click Sdkconfig "https://github.com/yanbe/bme280-esp-idf-i2c/tree/master/sdkconfig"

    %% Styles
    classDef software fill:#cce5ff,stroke:#00509d,stroke-width:2px,color:#00509d;
    classDef hardware fill:#f4c2c2,stroke:#8b0000,stroke-width:2px,color:#8b0000;
    classDef config fill:#d1e7dd,stroke:#0f5132,stroke-width:2px,color:#0f5132;
    classDef framework fill:#fff3cd,stroke:#856404,stroke-width:2px,color:#856404;
```
