# makersfunduck/humidity-temperature-sensor-th05f architecture

> Architecture diagram of the GitHub repository makersfunduck/humidity-temperature-sensor-th05f, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/makersfunduck/humidity-temperature-sensor-th05f
- Repository: https://github.com/makersfunduck/humidity-temperature-sensor-th05f

## Overview

##### Main System Components

a. Hardware Layer:
- Sensor interfaces (CHT8215, CHT8310, CHT8305, AHT20..30)
- I/O components (LCD display, buttons, RX/TX pins)
- Battery management system

b. Firmware Layers:
- Boot Layer (0x03000 - 52KB)
- Application Layer (0x10000 - 128KB)
- History Storage (0x30000 - 304KB)
- Settings Storage (0x7C000 - 16KB)

c. Communication Interfaces:
- BLE Stack (show advertising and connection paths)
- UART/Debug interface
- I2C for sensors

##### Key Architectural Elements

- Boot Mode (minimal functionality + OTA)
- Application Mode (full functionality)
- OTA Update Mode

b. Data flows:
- Sensor readings → Processing → BLE Advertisement
- Button Input → Mode Control
- Battery Monitoring → Status Updates
- External Trigger Input → Event Processing

##### Integration Points

a. External Systems:
- Home Assistant integration
- BTHome protocol interface
- OTA update mechanism
- USB-COM programming interface

##### Specific Features

- BTHome v2 advertisement handling
- Trigger system for temperature/humidity control
- History recording mechanism
- Battery monitoring system
- Counter/event handling system

##### Technical Details

- Memory map overlay
- BLE advertisement intervals
- Sensor polling intervals
- Battery measurement timing
- History recording intervals

##### Interface Layer (BTHome Protocol, External Communications)

This system architecture should emphasize the project's focus on low power consumption, reliable OTA updates, and seamless integration with home automation systems while maintaining clarity about the different operational modes and data flows.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef hardware fill:#f9f,stroke:#333,stroke-width:2px
    classDef firmware fill:#bbf,stroke:#333,stroke-width:2px
    classDef communication fill:#bfb,stroke:#333,stroke-width:2px
    classDef storage fill:#ffb,stroke:#333,stroke-width:2px
    classDef service fill:#fbb,stroke:#333,stroke-width:2px
    classDef display fill:#bff,stroke:#333,stroke-width:2px
    classDef system fill:#ddd,stroke:#333,stroke-width:2px

    %% Hardware Layer
    subgraph Hardware
        MCU["PHY622x2 MCU"]:::hardware
        I2C["I2C Interface"]:::hardware
        GPIO["GPIO Interface"]:::hardware
        ADC["ADC/Battery"]:::hardware
    end

    %% Firmware Layers
    subgraph Firmware
        Boot["Boot Layer<br>(0x03000)"]:::firmware
        App["Application Layer<br>(0x10000)"]:::firmware
        Storage["Flash Storage"]:::storage
    end

    %% Communication Layer
    subgraph Communication
        BLE["BLE Stack"]:::communication
        UART["UART Debug"]:::communication
        BTHome["BTHome Protocol"]:::communication
    end

    %% Core Features
    subgraph Core
        BattMgmt["Battery Management"]:::system
        SensorHandler["Sensor Handling"]:::system
        Config["Configuration"]:::system
        OTA["OTA Updates"]:::system
        CmdInterface["Command Interface"]:::system
    end

    %% Device Services
    subgraph Services
        BattService["Battery Service"]:::service
        DevInfo["Device Info Service"]:::service
        THService["Temp/Humidity Service"]:::service
    end

    %% Display Support
    subgraph Display
        LCD["LCD Interface"]:::display
        LCD_TH05["TH05 Driver"]:::display
        LCD_TH05D["TH05D Driver"]:::display
        LCD_TH05F["TH05F Driver"]:::display
        LCD_THB1["THB1 Driver"]:::display
    end

    %% System Management
    subgraph SystemMgmt
        Power["Power Management"]:::system
        Timer["Timer Management"]:::system
        WDog["Watchdog"]:::system
    end

    %% Relationships
    MCU --> I2C & GPIO & ADC
    Boot --> App
    App --> Storage
    App --> BLE
    BLE --> BTHome
    SensorHandler --> I2C
    BattMgmt --> ADC
    LCD --> LCD_TH05 & LCD_TH05D & LCD_TH05F & LCD_THB1

    %% Click events
    click MCU "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/inc/mcu_phy_bumbee.h"
    click I2C "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/i2c/i2c.h"
    click GPIO "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/gpio/gpio.h"
    click ADC "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/adc/adc.h"
    click Boot "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/ota_boot/source/main.c"
    click App "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/main.c"
    click Storage "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/flash_eep.c"
    click BLE "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/tree/main/SDK/components/ble/include/"
    click UART "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/uart/uart.h"
    click BTHome "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/bthome_beacon.c"
    click BattMgmt "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/battery.c"
    click SensorHandler "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/sensors.c"
    click Config "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/config.c"
    click OTA "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/ble_ota.c"
    click CmdInterface "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/cmd_parser.c"
    click BattService "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/battservice.c"
    click DevInfo "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/devinfoservice.c"
    click THService "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/thservice.c"
    click LCD "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/lcd.h"
    click LCD_TH05 "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/lcd_th05.c"
    click LCD_TH05D "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/lcd_th05d.c"
    click LCD_TH05F "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/lcd_th05f.c"
    click LCD_THB1 "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/bthome_phy6222/source/lcd_thb1.c"
    click Power "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/pwrmgr/pwrmgr.h"
    click Timer "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/timer/timer.h"
    click WDog "https://github.com/MakersFunDuck/humidity-temperature-sensor-TH05F/blob/main/SDK/components/driver/watchdog/watchdog.h"
```
