# danieltone/cubesat-simulator-using-esp32s architecture

> Architecture diagram of the GitHub repository danieltone/cubesat-simulator-using-esp32s, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danieltone/cubesat-simulator-using-esp32s
- Repository: https://github.com/danieltone/cubesat-simulator-using-esp32s

## Overview

1. **What this repo is**
   - This is a CubeSat telemetry simulation and ground-segment prototype, not a full mission stack.
   - It produces realistic-looking bus telemetry, moves it over either **USB serial** or **ESP-NOW**, and turns it into **CSV/SQLite**, **reports**, and **HTML dashboards**.

2. **Onboard / “spacecraft” simulator**
   - `cubesat_simulator.ino` is the main flight-side telemetry generator.
   - It emits a full telemetry JSON line every 15 seconds over Serial and can also send a compact heartbeat over ESP-NOW.
   - The simulated fields cover orbit, EPS, thermal, ADCS, comms health, and general fault/watchdog state.
   - This is the primary data source for the rest of the system.

3. **Optional over-the-air relay path**
   - `ground_station_receiver.ino` is the dedicated receiver firmware for a second ESP32 board.
   - In the tested architecture, the XIAO ESP32-C3 transmits via ESP-NOW to this receiver, and the receiver forwards data to the host over USB serial.
   - The receiver MAC address is a key boundary value: the transmitter must be configured with the receiver’s MAC before the link works.

4. **Host ingestion and decoding**
   - `ground_station_logger.py` is the ground-side ingestion service.
   - It reads telemetry from either a serial port or stdin, parses JSON lines, and writes records to persistent storage.
   - It is the boundary between raw transport and mission data products.

5. **Persistence layer**
   - The logger writes both `data/telemetry.csv` and `data/telemetry.db`.
   - SQLite is the primary structured store for downstream analytics and dashboards; CSV is a simple export/archive path.
   - The repo also includes demo SQLite databases under `demo/db/` for presentation and offline use.

6. **Analytics and reporting**
   - `telemetry_report.py` reads the SQLite database and computes summary statistics, anomaly counts, and latest-state reporting.
   - This is the “ops reporting” layer: it consumes stored telemetry rather than live transport.
   - Thresholds are configurable, which makes anomaly detection a post-ingest analysis step rather than part of the simulator.

7. **Offline dashboard generation**
   - `telemetry_dashboard.py` turns SQLite telemetry into a static HTML dashboard with charts and anomaly tables.
   - The dashboard is generated from stored data, so the visualization layer is decoupled from the logger and can be rebuilt from history.
   - `generate_demo_dashboards.py` produces the prebuilt demo HTML pages in `demo/dashboards/`.

8. **Live dashboard serving**
   - `live_dashboard_server.py` adds a thin local web-serving layer that regenerates the dashboard on a timer and serves it on localhost.
   - This creates a near-real-time operator view without changing the ingestion pipeline.
   - The live server depends on the SQLite database produced by the logger.

9. **Demo mode vs live mode**
   - The repo is split into two operating modes:
     - **Live mode:** hardware telemetry path from simulator/receiver to logger to dashboard.
     - **Demo mode:** pre-generated databases and HTML dashboards under `demo/` for offline presentation.
   - `run_live_demo.sh` ties the live workflow together, while the `demo/` directory provides ready-made sample outputs.

10. **Firmware build and hardware packaging**
   - `pio_upload/` and `pio_receiver_upload/` are PlatformIO projects for the simulator and receiver firmware variants.
   - `cubesat_3d_printfiles/` contains STL parts for a physical CubeSat mock enclosure, which is adjacent to but separate from the telemetry pipeline.
   - The repo therefore spans both software and physical mockup artifacts.

11. **Operational/documentation boundary**
   - The root markdown files describe setup, wiring, telemetry flow, serial connections, and operator usage.
   - `PIPELINE_FLOWCHART.md` and `TELEMETRY_PIPELINE.md` are especially relevant for diagramming because they document the intended end-to-end data path and system boundaries.

12. **Key architecture diagram takeaway**
   - The central flow is: **telemetry generation on ESP32 firmware → transport over Serial or ESP-NOW → PC logger/decoder → SQLite/CSV storage → report/dashboard generation → optional local web serving**.
   - The biggest boundary is between the embedded telemetry source and the host-side ground software; a second important boundary is between live ingestion and offline/demo visualization.

Main entry points: [`cubesat_simulator.ino`](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/cubesat_simulator.ino) (Simulator), [`ground_station_logger.py`](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_logger.py) (Logger), [`ground_station_receiver.ino`](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_receiver.ino) (Receiver), [`TELEMETRY_PIPELINE.md`](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/TELEMETRY_PIPELINE.md) (Pipeline docs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_embedded["Embedded side"]
  node_cubesat_simulator["Simulator<br/>ESP32 firmware"]
  node_ground_station_receiver["Receiver<br/>ESP32 firmware"]
end

subgraph group_host["Ground segment"]
  node_ground_station_logger["Logger<br/>ingest service"]
  node_telemetry_store[("Telemetry DB<br/>SQLite+CSV")]
  node_telemetry_report["Report<br/>analytics"]
  node_telemetry_dashboard["Dashboard<br/>static HTML generator"]
  node_live_dashboard_server(("Live server<br/>local web server"))
  node_run_live_demo["Live demo<br/>shell workflow<br/>[run_live_demo.sh]"]
end

subgraph group_demo["Demo assets"]
  node_generate_demo_dashboards["Demo builder<br/>batch generator"]
  node_demo_databases[("Demo DBs<br/>sample SQLite")]
  node_demo_dashboards["Demo HTML<br/>static pages"]
end

subgraph group_docs["Docs"]
  node_pipeline_docs["Pipeline docs"]
  node_ops_docs["Operator guides<br/>docs<br/>[README.md]"]
end

subgraph group_packaging["Hardware packaging"]
  node_pio_upload["Flight build<br/>PlatformIO project<br/>[main.ino]"]
  node_pio_receiver_upload["Receiver build<br/>PlatformIO project<br/>[main.cpp]"]
  node_cubesat_parts{{"CubeSat parts<br/>STL enclosure"}}
end

node_cubesat_simulator -->|"USB serial"| node_ground_station_logger
node_cubesat_simulator -->|"ESP-NOW"| node_ground_station_receiver
node_ground_station_receiver -->|"USB serial"| node_ground_station_logger
node_ground_station_logger -->|"write"| node_telemetry_store
node_telemetry_store -->|"read"| node_telemetry_report
node_telemetry_store -->|"read"| node_telemetry_dashboard
node_telemetry_dashboard -->|"serve"| node_live_dashboard_server
node_demo_databases -->|"input"| node_generate_demo_dashboards
node_generate_demo_dashboards -->|"output"| node_demo_dashboards
node_ground_station_logger -.->|"orchestrate"| node_run_live_demo
node_telemetry_store -.->|"depends on"| node_run_live_demo
node_pipeline_docs -.->|"documents"| node_cubesat_simulator
node_pipeline_docs -.->|"documents"| node_ground_station_logger
node_ops_docs -.->|"documents"| node_ground_station_receiver
node_pio_upload -.->|"builds"| node_cubesat_simulator
node_pio_receiver_upload -.->|"builds"| node_ground_station_receiver
node_cubesat_parts -.->|"physical mockup"| node_cubesat_simulator

click node_cubesat_simulator "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/cubesat_simulator.ino"
click node_ground_station_receiver "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_receiver.ino"
click node_ground_station_logger "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_logger.py"
click node_telemetry_report "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/telemetry_report.py"
click node_telemetry_dashboard "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/telemetry_dashboard.py"
click node_live_dashboard_server "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/live_dashboard_server.py"
click node_generate_demo_dashboards "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/generate_demo_dashboards.py"
click node_demo_databases "https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/demo/db"
click node_demo_dashboards "https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/demo/dashboards"
click node_pipeline_docs "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/TELEMETRY_PIPELINE.md"
click node_ops_docs "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/README.md"
click node_pio_upload "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/pio_upload/src/main.ino"
click node_pio_receiver_upload "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/pio_receiver_upload/src/main.cpp"
click node_cubesat_parts "https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/cubesat_3d_printfiles"
click node_run_live_demo "https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/run_live_demo.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cubesat_simulator,node_ground_station_receiver toneBlue
class node_ground_station_logger,node_telemetry_store,node_telemetry_report,node_telemetry_dashboard,node_live_dashboard_server,node_run_live_demo toneAmber
class node_generate_demo_dashboards,node_demo_databases,node_demo_dashboards toneMint
class node_pipeline_docs,node_ops_docs toneRose
class node_pio_upload,node_pio_receiver_upload,node_cubesat_parts toneIndigo
```

## Components

### Embedded side

Flight-side telemetry generation and optional ESP-NOW relay

- [Simulator](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/cubesat_simulator.ino): ESP32 firmware · Main CubeSat telemetry generator; emits full JSON telemetry and optional heartbeat · `cubesat_simulator.ino`
- [Receiver](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_receiver.ino): ESP32 firmware · ESP-NOW receiver that forwards telemetry to host over USB serial · `ground_station_receiver.ino`

### Ground segment

Host-side ingestion, storage, reporting, and serving

- [Logger](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/ground_station_logger.py): ingest service · Reads serial or stdin, parses JSON telemetry, and writes persistent records · `ground_station_logger.py`
- **Telemetry DB**: SQLite+CSV · Persistent telemetry storage used by downstream analytics and dashboards
- [Report](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/telemetry_report.py): analytics · Computes summaries, anomaly counts, and latest-state operational reporting · `telemetry_report.py`
- [Dashboard](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/telemetry_dashboard.py): static HTML generator · Builds charted HTML dashboards and anomaly tables from SQLite telemetry · `telemetry_dashboard.py`
- [Live server](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/live_dashboard_server.py): local web server · Regenerates dashboards on a timer and serves them on localhost · `live_dashboard_server.py`
- [Live demo](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/run_live_demo.sh): shell workflow · Convenience script tying together the live telemetry workflow · `run_live_demo.sh`

### Demo assets

Prebuilt sample data and static dashboard outputs

- [Demo builder](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/generate_demo_dashboards.py): batch generator · Creates the prebuilt demo dashboards from sample databases · `generate_demo_dashboards.py`
- [Demo DBs](https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/demo/db): sample SQLite · Prebuilt telemetry databases used for offline demos and presentation · `demo/db`
- [Demo HTML](https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/demo/dashboards): static pages · Pre-rendered dashboard examples for nominal and anomaly scenarios · `demo/dashboards`

### Docs

Operator and pipeline documentation

- [Pipeline docs](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/TELEMETRY_PIPELINE.md): docs · Architecture and operator documentation for the telemetry flow and setup · `TELEMETRY_PIPELINE.md`
- [Operator guides](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/README.md): docs · Setup, wiring, serial connection, and operator cheat-sheet material · `README.md`

### Hardware packaging

Firmware build projects and physical mockup parts

- [Flight build](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/pio_upload/src/main.ino): PlatformIO project · Build/upload project for the simulator firmware variant · `pio_upload/src/main.ino`
- [Receiver build](https://github.com/danieltone/cubesat-simulator-using-esp32s/blob/main/pio_receiver_upload/src/main.cpp): PlatformIO project · Build/upload project for the ESP-NOW receiver firmware variant · `pio_receiver_upload/src/main.cpp`
- [CubeSat parts](https://github.com/danieltone/cubesat-simulator-using-esp32s/tree/main/cubesat_3d_printfiles): STL enclosure · 3D-printable mockup enclosure and frame components · `cubesat_3d_printfiles`

## Connections

- Simulator → Logger: USB serial · Direct host ingestion path when simulator is connected by serial
- Simulator → Receiver: ESP-NOW · Wireless telemetry/heartbeat path to the receiver board
- Receiver → Logger: USB serial · Forwarded telemetry stream into the host logger
- Logger → Telemetry DB: write · Persists telemetry to CSV and SQLite
- Telemetry DB → Report: read · Report layer consumes stored telemetry for summaries and anomalies
- Telemetry DB → Dashboard: read · Dashboard generator renders charts from database history
- Dashboard → Live server: serve · Live server serves regenerated dashboard content locally
- Demo DBs → Demo builder: input · Sample databases used to build demo pages
- Demo builder → Demo HTML: output · Produces prebuilt static dashboard examples
- Logger → Live demo: orchestrate · Live workflow wrapper invokes ingestion and display steps
- Telemetry DB → Live demo: depends on · Live demo assumes the logger has populated the database
- Pipeline docs → Simulator: documents · Documents end-to-end telemetry flow and boundaries
- Pipeline docs → Logger: documents · Describes the host ingestion and storage boundary
- Operator guides → Receiver: documents · Covers serial wiring and receiver setup
- Flight build → Simulator: builds · PlatformIO packaging for simulator firmware
- Receiver build → Receiver: builds · PlatformIO packaging for receiver firmware
- CubeSat parts → Simulator: physical mockup · Mechanical parts adjacent to the telemetry prototype
