# aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data architecture

> Architecture diagram of the GitHub repository aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data
- Repository: https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data

## Overview

##### Project Type and Purpose
– This is a full-stack IoT + Machine Learning application with four main parts:
- A Linux kernel driver for the BMP180 temperature/pressure sensor on a Raspberry Pi
- A Python-based data-processing and ML pipeline (data ingestion, feature extraction, model inference)
- A Flask-based web server for visualizing live sensor readings and weather predictions
- A cross-platform Flutter app (Android, iOS, macOS, Windows, Linux) that mirrors the web UI on mobile/desktop

##### File-Structure Analysis
– Top-level “App/BMP180-Driver” holds:
- Kernel code: bmp180_driver.c, eeprom.c, process.c plus Makefile, Module.symvers
- Python AI folder: ai/ (data.py, model.py, run.py, plus pre-trained .pkl files)
- Web UI: web.py, templates/, static/
- Flutter app under Android/android (multi-platform runner projects for Android, iOS, macOS, Linux, Windows)
- Test app: test_bmp.c
- Env/requirements.txt
– Readme explains: I2C hardware binding, ioctl interface, Python ML steps, web hosting, ngrok tunnel, Flutter build & deploy for Android

##### Key Architecture Insights from README
– Sensor ↔ Driver via I2C and character device (`/dev/bmp180`, ioctl commands)
– Python scripts fetch raw data (process.c or direct char-device), run ML models, produce predictions & CSV outputs
– Flask server (web.py) serves templates, static chart.js/CSS, communicates with Python ML modules
– External weather API for scaler or enrichment (`worldweatheronline.com`)
– ngrok for remote access, Flutter mobile app consumes the same HTTP endpoints

##### Main Components and Interactions
A. Hardware Layer
- BMP180 sensor on I2C bus
- Raspberry Pi 3B+ board
B. Kernel Layer
- `bmp180_driver` module registers as a char-device
- Exposes ioctl for READ_TEMP, READ_PRESS
C. User-Space Data Layer
- `eeprom` utility reads calibration constants
- `process.c` (optional CLI) or Python `run.py` reads raw data via `/dev/bmp180`
D. ML/Analytics Layer
- Python packages: numpy, pandas, scikit-learn, joblib
- Pre-trained models (.pkl) loaded by `model.py`
E. Web/API Layer
- Flask (`web.py`)
- Jinja2 templates under templates/
- Static assets (chart.js, CSS) under static/
- Exposes HTTP endpoints for real-time sensor and prediction data
- Optionally secured by simple user/pass
- ngrok tunneling for external access
F. Mobile/Desktop Presentation Layer
- Flutter app in Android/android folder
- Native runners for Android (APK), iOS, MacOS, Linux, Windows
- Fetches JSON via HTTP from Flask server, renders UI similarly to web

##### Architectural Patterns & Design Principles
– Layered architecture: hardware → kernel → data/ML → web/API → client UI
– Separation of concerns: C code for driver, Python for ML, Flask for HTTP, Flutter for UI
– Plug-in points: ML models can be swapped under ai/model; new sensor drivers can follow same ioctl pattern
– Device-tree binding for kernel module configuration
– Cross-platform UI via Flutter

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hardware Layer
    subgraph "Hardware Layer"
        direction TB
        BMP["BMP180 Sensor"]:::hardware
        RP["Raspberry Pi 3B+"]:::hardware
    end

    %% Kernel Layer
    subgraph "Kernel Driver Layer"
        direction TB
        KD["Kernel Driver Module\n(bmp180_driver)"]:::kernel
        EQ["EEPROM Calibration Utility\n(eeprom)"]:::kernel
        CLI_C["CLI Data Processor\n(process.c)"]:::kernel
    end

    %% Data & ML Layer
    subgraph "Data & ML Layer"
        direction TB
        DP["Data Ingestion & Feature Extraction\n(data.py)"]:::ml
        MD["Model Definition & Loading\n(model.py)"]:::ml
        OF["Feature Selection Utility\n(opti.py)"]:::ml
        RN["Inference Runner\n(run.py)"]:::ml
        VZ["Visualization Scripts\n(visualize.py, visudata.py)"]:::ml
        PM["Pre-trained Models & Scaler\n(.pkl)"]:::ml
        ENV["Python Env Spec\n(requirements.txt)"]:::ml
    end

    %% Web/API Layer
    subgraph "Web/API Layer"
        direction TB
        FL["Flask API & Views\n(web.py)"]:::api
        TMP["Jinja2 Templates"]:::api
        STA["Static Assets"]:::api
        WAPI["External Weather API"]:::external
        NG["ngrok Tunnel"]:::external
    end

    %% Client UI Layer
    subgraph "Client UI Layer"
        direction TB
        WB["Web Browser UI"]:::ui
        FC["Flutter Client"]:::ui
    end

    %% Connections
    BMP -->|I2C| KD
    RP -->|runs module| KD
    KD -->|ioctl/raw| CLI_C
    KD -->|ioctl/raw| DP
    CLI_C -->|CSV| DP
    DP -->|features| OF
    OF -->|processed data| MD
    MD -->|model| RN
    RN -->|predictions| VZ
    VZ -->|charts/CSV| FL
    FL -->|REST/JSON| DP
    FL -->|serves pages| WB
    FL -->|serves| FC
    FL -->|HTTP/HTTPS| WAPI
    FL -->|tunneled| NG

    %% Click Events
    click KD "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/bmp180_driver.c"
    click EQ "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/eeprom/eeprom.c"
    click CLI_C "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/process/process.c"
    click DP "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/data.py"
    click MD "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/model.py"
    click RN "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/run.py"
    click OF "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/opti.py"
    click VZ "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/visualize.py"
    click PM "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/ai/model/Decision_Tree.pkl"
    click FL "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/web.py"
    click TMP "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/templates/index.html"
    click STA "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/static/chart.js"
    click FC "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/tree/main/App/BMP180-Driver/Android/android"
    click ENV "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/requirements.txt"
    click CLI_C "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/test_bmp/test_bmp.c"
    click ENV "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/requirements.txt"
    click KD "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/tree/main/App/BMP180-Driver/Makefile"
    click KD "https://github.com/aysinemu/weather-prediction-using-machine-learning-based-on-bmp180-sensor-data/blob/main/App/BMP180-Driver/Module.symvers"

    %% Styles
    classDef hardware fill:#fddc5c,stroke:#e69a00,color:#000
    classDef kernel fill:#a6cee3,stroke:#1f78b4,color:#000
    classDef ml fill:#b2df8a,stroke:#33a02c,color:#000
    classDef api fill:#cab2d6,stroke:#6a3d9a,color:#000
    classDef ui fill:#80b1d3,stroke:#1f78b4,color:#000
    classDef external fill:#dddddd,stroke:#888888,color:#000
```
