# patrickhaetti/measurementdatastreamer architecture

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

- Interactive diagram: https://gitdiagram.com/patrickhaetti/measurementdatastreamer
- Repository: https://github.com/patrickhaetti/measurementdatastreamer

## Overview

##### Main Components

a. Hardware Layer:
- RaspberryPi (Primary controller)
- Arduino (Secondary controller)
- Sensors:
- DHT22 (Temperature/Humidity sensor)
- CCS811 (CO2 sensor)

b. Data Collection Layer:
- Python Scripts:
- DHT22 reader (dht22_to_grafana.py)
- Combined sensor reader (dht22_ccs811_to_grafana.py)
- Arduino communication scripts (arduino_to_influxdb.py)

c. Data Storage & Processing Stack:
- InfluxDB (Time-series database)
- Telegraf (Data collection agent)
- Grafana (Visualization platform)

**[Hardware Layer]**
- ↓
**[Data Collection Layer]**
- ↓
**[Data Processing Layer]**
- ↓
**[Visualization Layer]**

##### Data Flow Representation

- Sensor data flow from DHT22 and CCS811 to their respective Python scripts
- Data flow from Arduino to RaspberryPi (via Serial communication)
- Data ingestion into InfluxDB (both direct and through Telegraf)
- Data query flow from Grafana to InfluxDB

##### Port and Protocol Information
- Port numbers (e.g., Grafana:3000, InfluxDB:8086)
- Communication protocols (HTTP, Serial, etc.)

##### Additional Details

a. Configuration Notes:
- InfluxDB database name: "newmeasurementdatabase"
- Telegraf configuration pointing to InfluxDB
- Grafana data source configuration

b. Data Structure:
**measurement: "environment"**
**fields:**
- temperature_c
- temperature_f
- humidity

##### Notes Section
A notes section mentioning:
- Authentication details (admin credentials)
- Port requirements
- Network connectivity requirements

Remember to include version information for major components and any specific configuration requirements that are critical to the system's operation.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hardware Layer
    subgraph Hardware
        RPI[RaspberryPi]:::hardware
        ARD[Arduino]:::hardware
        DHT[DHT22 Sensor]:::hardware
        CCS[CCS811 Sensor]:::hardware
    end

    %% Data Collection Layer
    subgraph Collection
        DHT_SCRIPT["DHT22 Reader Script"]:::script
        COMB_SCRIPT["Combined Sensor Reader"]:::script
        ARD_SCRIPT["Arduino Communication Script"]:::script
        CCS_LIB["CCS811 Library"]:::script
    end

    %% Data Processing Layer
    subgraph Processing
        TELEGRAF[("Telegraf")]:::service
        INFLUX[(InfluxDB<br/>Port: 8086)]:::storage
    end

    %% Visualization Layer
    subgraph Visualization
        GRAFANA[("Grafana<br/>Port: 3000")]:::visualization
    end

    %% Connections
    DHT --> DHT_SCRIPT
    CCS --> COMB_SCRIPT
    ARD --> ARD_SCRIPT
    CCS_LIB --> COMB_SCRIPT
    
    DHT_SCRIPT --> INFLUX
    COMB_SCRIPT --> INFLUX
    ARD_SCRIPT --> INFLUX
    
    TELEGRAF --> INFLUX
    INFLUX --> GRAFANA

    %% Data Structure Note
    subgraph DataStructure
        MEAS["Measurement: environment<br/>Fields:<br/>- temperature_c<br/>- temperature_f<br/>- humidity"]:::note
    end

    %% Legend
    subgraph Legend
        L1[Hardware Component]:::hardware
        L2[Script Component]:::script
        L3[("Service Component")]:::service
        L4[("Storage Component")]:::storage
        L5[("Visualization Component")]:::visualization
    end

    %% Styles
    classDef hardware fill:#90EE90,stroke:#333,stroke-width:2px
    classDef script fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef service fill:#FFD700,stroke:#333,stroke-width:2px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:2px
    classDef visualization fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef note fill:#f9f,stroke:#333,stroke-width:1px

    %% Click Events
    click CCS_LIB "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/CCS811V1-Python/ccs811.py"
    click DHT_SCRIPT "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/dht22/dht22_to_grafana.py"
    click ARD "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/arduino_files/temperature_co2_json/temperature_co2_json.ino"
    click COMB_SCRIPT "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/stream_data/dht22_ccs811_to_grafana.py"
    click ARD_SCRIPT "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/stream_data/arduino_to_influxdb.py"
    click INFLUX "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/info_files/setup_influxDB_V1.md"
    click TELEGRAF "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/info_files/setup_telegraf.md"
    click GRAFANA "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/info_files/setup_grafana.md"
    click RPI "https://github.com/patrickhaetti/MeasurementDataStreamer/blob/main/info_files/readme_Arduino_RaspberryPi.md"
```
