# ivan-sev/gyver433 architecture

> Architecture diagram of the GitHub repository ivan-sev/gyver433, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivan-sev/gyver433
- Repository: https://github.com/ivan-sev/gyver433

## Overview

#### Purpose and packaging
Gyver433 is a lightweight Arduino C++ library for transmitting and receiving packets over inexpensive 433 MHz ASK/OOK radio modules. It is distributed as an Arduino library, with metadata in `library.properties`; consumers include the public header `src/Gyver433.h`.

#### Primary entry points
Applications instantiate compile-time pin-bound templates:
- `Gyver433_TX<pin, CRC>` for synchronous packet transmission.
- `Gyver433_RX<pin, buffer, CRC>` for packet reception, either polled or driven from a hardware pin-change interrupt.
The public API and most protocol implementation are concentrated in `src/Gyver433.h`; CRC algorithms are declared/implemented in `src/G433_crc.h` and `src/G433_crc.cpp`.

#### On-air protocol and transmit stage
The transmitter emits a synchronization/train pulse, a low start pulse, pulse-width-encoded data bits, and a train-length stop pulse. Timing and bitrate are compile-time configurable (`G433_SPEED`, train-mode defines). `sendData()` serializes arbitrary typed data and appends configured CRC; `write()` sends raw bytes without automatic CRC. The central TX logic is in `src/Gyver433.h`.

#### Receive state machine and execution modes
The receiver measures input signal transitions and reconstructs framed bytes according to the same timing protocol. It has three control boundaries:
- Polling: `tick()` samples the radio pin non-blockingly; missed transitions are possible while user code blocks.
- Blocking polling: `tickWait()` stays active through receipt.
- Interrupt-driven: application ISR calls `tickISR()` on `CHANGE`, allowing asynchronous capture while the main loop is busy.
These modes share the RX decoder/buffer implementation in `src/Gyver433.h`; interrupt attachment remains the sketch’s responsibility.

#### Packet integrity, buffering, and quality
RX accumulates decoded bytes in a caller-sized fixed buffer, exposes byte/buffer access, and validates configured CRC before reporting a completed packet. Generic `readData()` copies accepted payloads into application types. CRC8, XOR, or no CRC are selectable; reusable CRC routines live in `src/G433_crc.h` and `src/G433_crc.cpp`. The receiver can track a rolling successful-packet ratio and expose it as RSSI-like quality, optionally compiled out.

#### Platform and hardware boundaries
The library targets Arduino-compatible platforms through Arduino pin/time APIs and is intended for 433 MHz transmitter/receiver pairs such as FS1000A and SYN480R. AVR receives an optimized I/O-oriented design, while portability relies on standard Arduino APIs; ESP8266 interrupt handlers require the application to use `IRAM_ATTR`. RF wiring, voltage, antenna, noise, and hardware interrupt/PCINT availability are outside the library.

#### Integration examples
Sketches demonstrate standard data transfer, raw byte transport, typed-structure payloads, ISR reception, and LCD output:
`examples/demo_tx/demo_tx.ino`, `examples/demo_rx/demo_rx.ino`, `examples/raw_tx/raw_tx.ino`, `examples/raw_rx/raw_rx.ino`, `examples/tx433_struct/tx433_struct.ino`, `examples/rx433_struct/rx433_struct.ino`, and `examples/rx433_lcd/rx433_lcd.ino`.

Main entry points: [`src/Gyver433.h`](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h) (RX Decoder), [`src/G433_crc.h`](https://github.com/ivan-sev/gyver433/blob/main/src/G433_crc.h) (CRC Interface), [`examples/demo_rx/demo_rx.ino`](https://github.com/ivan-sev/gyver433/blob/main/examples/demo_rx/demo_rx.ino) (RX Sketches), [`examples/rx433_struct/rx433_struct.ino`](https://github.com/ivan-sev/gyver433/blob/main/examples/rx433_struct/rx433_struct.ino) (Application ISR)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["Arduino Library"]
  node_metadata["Library Metadata<br/>Arduino package<br/>[library.properties]"]
  node_public_api["Public API<br/>template API<br/>[Gyver433.h]"]
  node_tx["TX Encoder<br/>transmit stage<br/>[Gyver433.h]"]
  node_rx["RX Decoder<br/>receive state machine<br/>[Gyver433.h]"]
  node_polling["Polling Capture<br/>execution mode<br/>[Gyver433.h]"]
  node_isr_capture["ISR Capture<br/>execution mode<br/>[Gyver433.h]"]
  node_packet_buffer["RX Buffer &amp; Payload<br/>fixed buffer<br/>[Gyver433.h]"]
  node_quality["Packet Quality<br/>rolling metric<br/>[Gyver433.h]"]
  node_crc_api["CRC Interface<br/>integrity API<br/>[G433_crc.h]"]
  node_crc_impl["CRC Algorithms<br/>CRC implementation<br/>[G433_crc.cpp]"]
end

subgraph group_application["Consumer Sketch"]
  node_tx_sketch["TX Sketches<br/>examples<br/>[demo_tx.ino]"]
  node_rx_sketch["RX Sketches<br/>examples<br/>[demo_rx.ino]"]
  node_user_isr["Application ISR<br/>sketch responsibility<br/>[rx433_struct.ino]"]
end

subgraph group_radio["Radio Hardware"]
  node_rf_tx{{"433 MHz Transmitter<br/>ASK/OOK hardware"}}
  node_rf_link["On-Air Frame<br/>pulse protocol"]
  node_rf_rx{{"433 MHz Receiver<br/>ASK/OOK hardware"}}
end

node_arduino{{"Arduino Runtime<br/>platform API"}}

node_metadata -->|"packages"| node_public_api
node_tx_sketch -->|"uses TX"| node_public_api
node_rx_sketch -->|"uses RX"| node_public_api
node_public_api -->|"instantiates"| node_tx
node_public_api -->|"instantiates"| node_rx
node_tx -->|"appends CRC"| node_crc_api
node_rx -->|"validates CRC"| node_crc_api
node_crc_api -->|"implemented by"| node_crc_impl
node_tx -->|"uses timing and pin I/O"| node_arduino
node_rx -->|"reads transitions"| node_arduino
node_polling -->|"drives decoder"| node_rx
node_isr_capture -->|"drives decoder"| node_rx
node_user_isr -->|"calls tickISR"| node_isr_capture
node_rx_sketch -.->|"attaches when interrupt-driven"| node_user_isr
node_rx -->|"stores decoded bytes"| node_packet_buffer
node_rx -->|"records accepted packets"| node_quality
node_tx -->|"drives"| node_rf_tx
node_rf_tx -->|"transmits"| node_rf_link
node_rf_link -->|"carries"| node_rf_rx
node_rf_rx -->|"signal transitions"| node_rx

click node_metadata "https://github.com/ivan-sev/gyver433/blob/main/library.properties"
click node_public_api "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_tx "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_rx "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_polling "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_isr_capture "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_packet_buffer "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_quality "https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h"
click node_crc_api "https://github.com/ivan-sev/gyver433/blob/main/src/G433_crc.h"
click node_crc_impl "https://github.com/ivan-sev/gyver433/blob/main/src/G433_crc.cpp"
click node_tx_sketch "https://github.com/ivan-sev/gyver433/blob/main/examples/demo_tx/demo_tx.ino"
click node_rx_sketch "https://github.com/ivan-sev/gyver433/blob/main/examples/demo_rx/demo_rx.ino"
click node_user_isr "https://github.com/ivan-sev/gyver433/blob/main/examples/rx433_struct/rx433_struct.ino"

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_metadata,node_public_api,node_tx,node_rx,node_polling,node_isr_capture,node_packet_buffer,node_quality,node_crc_api,node_crc_impl toneBlue
class node_tx_sketch,node_rx_sketch,node_user_isr toneAmber
class node_rf_tx,node_rf_link,node_rf_rx toneMint
class node_arduino toneNeutral
```

## Components

### Arduino Library

- [Library Metadata](https://github.com/ivan-sev/gyver433/blob/main/library.properties): Arduino package · `library.properties`
- [Public API](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): template API · Pin-bound TX and RX templates. · `src/Gyver433.h`
- [TX Encoder](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): transmit stage · `src/Gyver433.h`
- [RX Decoder](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): receive state machine · `src/Gyver433.h`
- [Polling Capture](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): execution mode · tick() and blocking tickWait(). · `src/Gyver433.h`
- [ISR Capture](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): execution mode · Sketch ISR calls tickISR() on pin changes. · `src/Gyver433.h`
- [RX Buffer & Payload](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): fixed buffer · Caller-sized bytes exposed through read APIs. · `src/Gyver433.h`
- [Packet Quality](https://github.com/ivan-sev/gyver433/blob/main/src/Gyver433.h): rolling metric · Optional successful-packet ratio. · `src/Gyver433.h`
- [CRC Interface](https://github.com/ivan-sev/gyver433/blob/main/src/G433_crc.h): integrity API · `src/G433_crc.h`
- [CRC Algorithms](https://github.com/ivan-sev/gyver433/blob/main/src/G433_crc.cpp): CRC implementation · CRC8, XOR, or no CRC selection. · `src/G433_crc.cpp`

### Consumer Sketch

- [TX Sketches](https://github.com/ivan-sev/gyver433/blob/main/examples/demo_tx/demo_tx.ino): examples · Standard, raw-byte, and typed payload transmitters. · `examples/demo_tx/demo_tx.ino`
- [RX Sketches](https://github.com/ivan-sev/gyver433/blob/main/examples/demo_rx/demo_rx.ino): examples · Polling, ISR, typed payload, and LCD receivers. · `examples/demo_rx/demo_rx.ino`
- [Application ISR](https://github.com/ivan-sev/gyver433/blob/main/examples/rx433_struct/rx433_struct.ino): sketch responsibility · Attached on CHANGE; ESP8266 handlers need IRAM_ATTR. · `examples/rx433_struct/rx433_struct.ino`

### Radio Hardware

- **433 MHz Transmitter**: ASK/OOK hardware · Such as FS1000A.
- **On-Air Frame**: pulse protocol · Train, start, pulse-width data, and stop.
- **433 MHz Receiver**: ASK/OOK hardware · Such as SYN480R.

### Other components

- **Arduino Runtime**: platform API · Pin, timing, and interrupt primitives.

## Connections

- Library Metadata → Public API: packages
- TX Sketches → Public API: uses TX
- RX Sketches → Public API: uses RX
- Public API → TX Encoder: instantiates
- Public API → RX Decoder: instantiates
- TX Encoder → CRC Interface: appends CRC
- RX Decoder → CRC Interface: validates CRC
- CRC Interface → CRC Algorithms: implemented by
- TX Encoder → Arduino Runtime: uses timing and pin I/O
- RX Decoder → Arduino Runtime: reads transitions
- Polling Capture → RX Decoder: drives decoder
- ISR Capture → RX Decoder: drives decoder
- Application ISR → ISR Capture: calls tickISR
- RX Sketches → Application ISR: attaches when interrupt-driven
- RX Decoder → RX Buffer & Payload: stores decoded bytes
- RX Decoder → Packet Quality: records accepted packets
- TX Encoder → 433 MHz Transmitter: drives
- 433 MHz Transmitter → On-Air Frame: transmits
- On-Air Frame → 433 MHz Receiver: carries
- 433 MHz Receiver → RX Decoder: signal transitions
