How ivan-sev/gyver433 works
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: Gyver433.h RX Decoder · G433_crc.h CRC Interface · demo_rx.ino RX Sketches · rx433_struct.ino Application ISR
Components 17
Arduino Library
- Library Metadata
library.properties - Public API · Pin-bound TX and RX templates.
src/Gyver433.h - TX Encoder
src/Gyver433.h - RX Decoder
src/Gyver433.h - Polling Capture · tick() and blocking tickWait().
src/Gyver433.h - ISR Capture · Sketch ISR calls tickISR() on pin changes.
src/Gyver433.h - RX Buffer & Payload · Caller-sized bytes exposed through read APIs.
src/Gyver433.h - Packet Quality · Optional successful-packet ratio.
src/Gyver433.h - CRC Interface
src/G433_crc.h - CRC Algorithms · CRC8, XOR, or no CRC selection.
src/G433_crc.cpp
Consumer Sketch
- TX Sketches · Standard, raw-byte, and typed payload transmitters.
examples/demo_tx/demo_tx.ino - RX Sketches · Polling, ISR, typed payload, and LCD receivers.
examples/demo_rx/demo_rx.ino - Application ISR · Attached on CHANGE; ESP8266 handlers need IRAM_ATTR.
examples/rx433_struct/rx433_struct.ino
Radio Hardware
- 433 MHz Transmitter · Such as FS1000A.
- On-Air Frame · Train, start, pulse-width data, and stop.
- 433 MHz Receiver · Such as SYN480R.
Other components
- Arduino Runtime · Pin, timing, and interrupt primitives.
Connections 20
- 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