# protocentral/protocentral_openox architecture

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

- Interactive diagram: https://gitdiagram.com/protocentral/protocentral_openox
- Repository: https://github.com/protocentral/protocentral_openox

## Overview

##### Project type and purpose
- This is an embedded IoT hardware + firmware project: a standalone wireless pulse‐oximeter breakout board (based on the AFE4490 sensor IC and ESP32 MCU) with example Arduino sketches for streaming data over USB serial or BLE.
- The README shows its use cases: real‐time SpO₂/PPG/heart‐rate monitoring via a desktop GUI (“OpenView”) over USB, or via a mobile app (“HealthyPi”) over BLE.

##### File structure
- Top‐level:
- hardware/ → Eagle CAD board & schematic files (.brd, .sch, .pdf)
- examples/ → two Arduino sketches (USB streaming, BLE streaming)
- assets/ → images for README and GUI screenshots
- .github/workflows/ → CI pipelines that compile the example sketches
- README.md, LICENSE, .gitignore, etc.
- No backend or frontend web code—this is firmware + hardware + client apps elsewhere.

##### Main components
A. Hardware Layer
1. Nellcor finger‐clip probe → analog photodiodes & LEDs
2. AFE4490 analog front‐end IC → measures light absorption, outputs digital data via I²C
3. ESP32 WROOM32 module → runs Arduino firmware, hosts USB-CDC and BLE stacks
4. Power subsystem (3.3 V regulator, battery/USB supply)
B. Firmware Layer (on ESP32)
1. Sensor driver (AFE4490 Arduino library)
2. Data‐acquisition task (reads SpO₂, PPG, HR)
3. Communication modules:
- USB-CDC Serial (Example1 sketch)
- BLE GATT services & characteristics (Example2 sketch)
C. Host Applications
1. Desktop GUI (“OpenView”)
– Connects over USB serial, parses frames, renders PPG waveform & numeric values
2. Mobile App (“HealthyPi”)
– Connects over BLE, subscribes to GATT notifications, plots data
D. External Services/CI
1. GitHub Actions workflows (compile examples)
2. Documentation site (external link)

##### Relationships and data flow
- Sensor probe → analog signals → AFE4490 → digital I²C → ESP32
- ESP32 firmware → processes data → routes it to either USB-CDC or BLE interface
- Host app ↔ MCU:
- USB: host polls/reads Serial frames
- BLE: host subscribes to notifications
- CI pipelines build and validate the Arduino sketches on each commit

##### Architectural patterns & design principles
- Layered separation: hardware → firmware → host apps
- Modular firmware: distinct driver, acquisition, communication modules
- Standard protocols: I²C for sensor, USB-CDC and BLE GATT for transport
- Open hardware/software: clear license separation, CAD files versioned with source

## Diagram (Mermaid)

```mermaid
flowchart BT
    %% Hardware Layer
    subgraph "Hardware Layer"
        Probe["Nellcor Finger-Clip Probe"]:::hardware
        AFE["AFE4490 AFE IC"]:::hardware
        ESP32["ESP32 WROOM32 Module"]:::hardware
        Power["Power Subsystem (3.3V Regulator)"]:::hardware
        PCB["PCB & Schematics"]:::hardware
    end

    %% Firmware Layer
    subgraph "Firmware Layer"
        Driver["Sensor Driver (AFE4490 Library)"]:::firmware
        Acquire["Data-Acquisition Task"]:::firmware
        USB["Example2-OpenOx-USB-Streaming.ino"]:::comm
        BLE["Example1-OpenOx-BLE-Streaming.ino"]:::comm
    end

    %% Host Apps & External Services
    subgraph "Host Apps & External Services"
        GUI["Desktop GUI (OpenView)"]:::host
        App["Mobile App (HealthyPi)"]:::host
        CI1["Compile Examples Workflow"]:::host
        CI2["Main CI Workflow"]:::host
        Assets["Asset Images"]:::host
        Docs1["README.md"]:::host
        Docs2["LICENSE"]:::host
    end

    %% Connections
    Probe -->|"analog signals"| AFE
    AFE -->|"I²C"| Driver
    Driver --> Acquire
    Acquire --> USB
    Acquire --> BLE
    USB -->|"USB-CDC"| GUI
    BLE -->|"BLE GATT"| App
    CI1 --> USB
    CI1 --> BLE

    %% Click Events
    click PCB "https://github.com/protocentral/protocentral_openox/tree/main/hardware/"
    click USB "https://github.com/protocentral/protocentral_openox/blob/main/examples/Example2-OpenOx-USB-Streaming/Example2-OpenOx-USB-Streaming.ino"
    click BLE "https://github.com/protocentral/protocentral_openox/blob/main/examples/Example1-OpenOx-BLE-Streaming/Example1-OpenOx-BLE-Streaming.ino"
    click Assets "https://github.com/protocentral/protocentral_openox/tree/main/assets/"
    click CI1 "https://github.com/protocentral/protocentral_openox/blob/main/.github/workflows/compile-examples.yml"
    click CI2 "https://github.com/protocentral/protocentral_openox/blob/main/.github/workflows/main.yml"
    click Docs1 "https://github.com/protocentral/protocentral_openox/blob/main/README.md"
    click Docs2 "https://github.com/protocentral/protocentral_openox/tree/main/LICENSE"

    %% Styles
    classDef hardware fill:#add8e6,stroke:#000,color:#000
    classDef firmware fill:#90ee90,stroke:#000,color:#000
    classDef comm fill:#dda0dd,stroke:#000,color:#000
    classDef host fill:#ffdead,stroke:#000,color:#000
```
