# valentintintin/arduino-tracker-aprs-dra818 architecture

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

- Interactive diagram: https://gitdiagram.com/valentintintin/arduino-tracker-aprs-dra818
- Repository: https://github.com/valentintintin/arduino-tracker-aprs-dra818

## Overview

##### Project Type & Purpose
- This is an embedded firmware project for an Arduino Nano.
- Its sole purpose is to read GPS coordinates and send them as APRS frames over VHF using a DRA818V (or alternative TX path).

##### Top-Level Components
a. Hardware Blocks
- Arduino Nano (ATmega328P)
- GPS Module (NEO-6M)
- VHF TX Module (DRA818V)
- Optional external TX (Baofeng header or 3.5 mm jack)
- User button (EasyButton)
- Power supply & LPF (external low-pass filter)

b. Software Blocks (in src/)
- main.cpp – system initialization & loop, mode selection
- GPS.cpp/h – reads NMEA sentences via serial, provides fix & speed
- DRA.cpp/h – driver for DRA818V configuration & audio I/O
- APRS.cpp/h – QAPRS-based AFSK encoding of position packets
- Utils.cpp/h – timing, affine functions for TX interval by speed
- Third-party libs (TinyGPS+, QAPRS fork, DRA818 lib, EasyButton)

c. External Services
- APRS network (over RF)
- APRS.fi (internet visualization)
- M5Stack logger (UART debug)

##### Relationships & Data Flows
1. Hardware power → Arduino + modules
2. GPS → Arduino serial → GPS driver → location & time data
3. main.cpp logic → checks DRA module presence via DRA driver
4. On each TX event:
– APRS module encodes lat/long into AFSK audio signal
– audio out → resistor network or PWM (per build flag)
– audio → DRA818V audio input (or Baofeng/jack)
– DRA818V → VHF RF → APRS network
5. Button press → EasyButton ISR → main triggers manual transmit
6. (Optional) UART → M5Stack logger for debug output

##### Architectural Patterns & Design Principles
- Layered firmware structure (drivers → protocol → application)
- Build-time configuration via PlatformIO environments (`nanoprod`, `nanotest`)
- Hardware abstraction for TX path (R2R vs PWM resistor network)
- Finite-state detection of DRA module presence on startup

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Components"
        direction TB
        Power["Power Supply & LPF"]:::hardware
        Arduino["Arduino Nano (ATmega328P)"]:::hardware
        GPS["GPS Module (NEO-6M)"]:::hardware
        Button["User Button (EasyButton)"]:::hardware
        DRA["VHF TX Module (DRA818V)"]:::hardware
        OptionalTX["Optional TX (Baofeng Header / 3.5mm Jack)"]:::hardware
    end

    %% Firmware Layer
    subgraph "Firmware Layers"
        direction TB

        subgraph "Application Layer"
            direction TB
            main["main.cpp\n(system init & loop)"]:::software
            Decision{"DRA818V Detected?"}:::decision
            main -->|checks module| Decision
        end

        subgraph "Protocol Layer"
            direction TB
            APRSencoder["APRS.cpp/h\n(AFSK Encoder)"]:::software
        end

        subgraph "Driver Layer"
            direction TB
            GPSdriver["GPS.cpp/h\n(NMEA via Serial)"]:::software
            DRAdriver["DRA.cpp/h\n(config & Audio I/O)"]:::software
            Utils["Utils.cpp/h\n(timing & TX interval)"]:::software
        end

        subgraph "3rd-Party Libraries"
            direction TB
            ThirdParty["TinyGPS+, QAPRS fork,\nDRA818 lib, EasyButton"]:::software
        end
    end

    %% External Services
    subgraph "External Systems"
        direction TB
        APRSnet["APRS Network (RF)"]:::external
        APRSfi["APRS.fi (Internet)"]:::external
        Logger["M5Stack Logger (UART)"]:::external
    end

    %% Documentation & Config
    subgraph "Project Resources"
        direction TB
        BuildConfigs["platformio.ini"]:::external
        Docs["README.md & DRA818V.pdf"]:::external
        Wiring["trackerAPRS.fzz"]:::external
        CMake["CMakeLists.txt"]:::external
    end

    %% Connections
    Power --> Arduino
    GPS -->|Serial RX/TX| GPSdriver
    Button -->|GPIO ISR| main
    Utils -->|affine interval| main
    GPSdriver -->|location data| main
    main -->|trigger TX| APRSencoder
    APRSencoder -->|Audio Signal| DRAdriver
    DRAdriver -->|Audio In/Out| DRA
    Decision -->|Yes| APRSencoder
    Decision -->|No| OptionalTX
    OptionalTX -->|Audio In| DRA
    DRA -->|VHF RF| APRSnet
    APRSnet --> APRSfi
    Arduino -->|UART Debug| Logger

    %% Click Events
    click main "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/src/main.cpp"
    click GPSdriver "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/src/GPS.cpp"
    click DRAdriver "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/src/DRA.cpp"
    click APRSencoder "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/src/APRS.cpp"
    click Utils "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/src/Utils.cpp"
    click ThirdParty "https://github.com/valentintintin/arduino-tracker-aprs-dra818/tree/master/lib/"
    click BuildConfigs "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/platformio.ini"
    click Docs "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/README.md"
    click Wiring "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/trackerAPRS.fzz"
    click CMake "https://github.com/valentintintin/arduino-tracker-aprs-dra818/blob/master/CMakeLists.txt"

    %% Styles
    classDef hardware fill:#A9CCE3,stroke:#1B4F72,color:#1B2631
    classDef software fill:#ABEBC6,stroke:#196F3D,color:#0B5345
    classDef external fill:#F9E79F,stroke:#B9770E,color:#784212
    classDef decision fill:#F5B7B1,stroke:#943126,color:#641E16
```
