# henrynguyen1204/esp32_gps_mqtt architecture

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

- Interactive diagram: https://gitdiagram.com/henrynguyen1204/esp32_gps_mqtt
- Repository: https://github.com/henrynguyen1204/esp32_gps_mqtt

## Overview

##### Project Type and Purpose
- This is an embedded systems project built with ESP-IDF for the ESP32, and it integrates several hardware components:
- A GPS Module for reading NMEA data via UART.
- A SIM Module, also communicating via UART, used to publish GPS information over MQTT.
- An SSD1306 OLED display connected over I2C, which shows real-time GPS data.
- The overall purpose is to collect location data from the GPS, display it locally on the OLED, and publish it to an MQTT broker, demonstrating real-time communication.

##### File Structure Insights
- The project's file tree shows a top-level CMakeLists.txt with a dedicated "main" directory containing the application source.
- Source files (gps.c, sim_uart.c, ssd1306.c, main.c) and corresponding header files indicate distinct modules handling specific hardware functionality.
- The presence of an idf_component.yml implies the project is structured as an ESP-IDF component, which typically enforces modular separation.

##### System Components and Their Relationships
a. Main Processing Unit (ESP32):
- Acts as the central controller.
- Executes main.c and coordinates among the different modules.
b. GPS Module:
- Interfaces via UART to the ESP32.
- Responsible for capturing and parsing NMEA data.
c. SIM Module:
- Also uses UART, and handles MQTT connectivity.
- Transmits the GPS data over MQTT to a specified broker.
d. SSD1306 OLED Display:
- Connected over I2C.
- Displays live GPS information.
e. MQTT Broker (External Service):
- Receives data pushed from the SIM module via an established topic.

##### Architectural Patterns & Technologies
- Modular design: Each hardware element (GPS, SIM, Display) is implemented as a separate module integrated within the main app.
- Communication Pattern:
- UART communications are used for both the GPS module and SIM module.
- I2C is used for the OLED display.
- MQTT is used for sending data to the external broker.
- ESP-IDF Framework: Leverages ESP32-S3 hardware capabilities, and the component-based architecture provided by ESP-IDF.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    G["GPS Module (UART interface)"]:::module
    S["SIM Module (UART & MQTT interface)"]:::module
    O["SSD1306 OLED Display (I2C interface)"]:::module
    E["ESP32 (Main Processing Unit)"]:::core
    M["MQTT Broker (External Service)"]:::external
    C["ESP-IDF Component Configuration"]:::config

    %% Connections
    G -->|"UART"| E
    E -->|"I2C"| O
    E -->|"UART"| S
    S -->|"MQTT_publish"| M
    C ---|"configures"| E

    %% Click Events
    click E "https://github.com/henrynguyen1204/esp32_gps_mqtt/blob/main/main/main.c"
    click G "https://github.com/henrynguyen1204/esp32_gps_mqtt/blob/main/main/gps.c"
    click S "https://github.com/henrynguyen1204/esp32_gps_mqtt/blob/main/main/sim_uart.c"
    click O "https://github.com/henrynguyen1204/esp32_gps_mqtt/blob/main/main/ssd1306.c"
    click C "https://github.com/henrynguyen1204/esp32_gps_mqtt/blob/main/main/idf_component.yml"

    %% Styles
    classDef core fill:#e3f2fd,stroke:#2196f3,stroke-width:2px;
    classDef module fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
    classDef external fill:#c8e6c9,stroke:#4caf50,stroke-width:2px;
    classDef config fill:#ffcdd2,stroke:#f44336,stroke-width:2px;
```
