# dipto9999/self_balancing_robot architecture

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

- Interactive diagram: https://gitdiagram.com/dipto9999/self_balancing_robot
- Repository: https://github.com/dipto9999/self_balancing_robot

## Overview

##### Project type and purpose
- This is an IoT-style robotics system (“WALL-E”) combining embedded firmware, a Linux single-board computer, and user-facing software.

##### File structure
Top-level directories and their roles:
- Arduino_Firmware – balancing control, BLE communications, closed-loop PID, PWM motor drive
- Driver_App – Flask/HTML/CSS/JS web app (ngrok-exposed) for remote BLE control
- Dashboard_App – Python/Tkinter camera viewer, AWS S3 upload, AWS-interaction scripts
- Simulation – MATLAB/Simulink model of the control loop

Configuration and support files:
- requirements.txt files for Python dependencies
- .ino and .cpp/.h for MCU code
- KiCad files for PCB
- LaTeX source and PDF for final report

##### README for additional insights
- It lists hardware components (Arduino Nano 33 BLE, STM32L051, Raspberry Pi Zero 2 W), sensors, actuators, and software stacks (Flask/ngrok, Python/Tkinter, AWS S3).

##### Detail is key
- Sensors/modules as individual sub-components in the “Embedded Tier”.
- Intermediate data paths (e.g., IMU → complementary filter → PID → PWM).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Embedded Tier
    subgraph "Embedded Tier"
        direction TB
        SN1["IMU Sensor"]:::sensor
        SN2["Distance Sensor"]:::sensor
        SN3["Color Sensor"]:::sensor
        SN4["RFID Reader"]:::sensor
        Arduino["Arduino Nano 33 BLE Sense"]:::firmware
        STM32["STM32L051 MCU"]:::firmware
        DRV["DRV8833 Motor Driver"]:::hardware
        Motors["DC Motors"]:::hardware
    end

    %% User Software Tier
    subgraph "User Software Tier"
        direction TB
        DriverApp["Driver_App<br/>(Flask UI)"]:::app
        DashboardApp["Dashboard_App<br/>(Tkinter UI)"]:::app
    end

    %% Cloud Tier
    subgraph "Cloud Tier"
        direction TB
        AWS_S3["AWS S3 Bucket"]:::storage
    end

    %% Connections - Embedded
    SN1 -->|"I2C/SPI"| Arduino
    SN2 -->|"I2C/SPI"| STM32
    SN3 -->|"I2C/SPI"| STM32
    SN4 -->|"SPI"| STM32
    STM32 -->|"GPIO"| Arduino
    Arduino -->|"PWM"| DRV
    DRV -->|"Power"| Motors

    %% Connections - Embedded to User Apps
    Arduino -->|"BLE"| DriverApp
    DriverApp -->|"BLE"| Arduino

    %% Connections - Pi/Camera to Dashboard
    Pi["Raspberry Pi Zero 2 W"]:::firmware
    Pi -->|"Camera Feed"| DashboardApp

    %% Connections - Dashboard to Cloud
    DashboardApp -->|"HTTPS/S3"| AWS_S3
    AWS_S3 -->|"Data Fetch"| DashboardApp

    %% Click Events
    click Arduino "https://github.com/dipto9999/self_balancing_robot/tree/main/Arduino_Firmware/main"
    click STM32 "https://github.com/dipto9999/self_balancing_robot/tree/main/STM32_Firmware/ExtraFeatures/Core/Inc"
    click SN3 "https://github.com/dipto9999/self_balancing_robot/tree/main/ColorSensor_PCB/VEML3328"
    click DriverApp "https://github.com/dipto9999/self_balancing_robot/blob/main/Driver_App/webApp.py"
    click DashboardApp "https://github.com/dipto9999/self_balancing_robot/blob/main/Dashboard_App/main.py"
    click Pi "https://github.com/dipto9999/self_balancing_robot/blob/main/Dashboard_App/app.py"
    click Simulation "https://github.com/dipto9999/self_balancing_robot/blob/main/Simulation/tfBot.m"

    %% Styles
    classDef sensor fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef firmware fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef hardware fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef app fill:#EDE7F6,stroke:#5E35B1,color:#5E35B1;
    classDef storage fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A;
```
