LumaGuard
Context-Aware Micro-Workspace Hazard & Proximity Guard
Role: Embedded Firmware Architecture, State Machine & PlatformIO CI
- SRAM Footprint
- 729 / 2,048 B (35.6%)
- ATmega328P PlatformIO build
- Flash Footprint
- 21,660 / 30,720 B (70.5%)
- Includes Adafruit GFX + SSD1306
- Bench Scenarios
- 9 / 9 Passed (IT-01..09)
- Physical 830-pt breadboard tests
- Target Cycle Timing
- 250 ms Flame · 800 ms Stale
- Non-blocking millis() scheduler
01 · Problem Definition & Objectives
Engineering Problem
Direct sensor-to-buzzer threshold circuits in workbench environments suffer from nuisance alarms on momentary sparks/camera flashes, rapid output chatter near single trip distances, and silent failure when an ultrasonic echo path disconnects.
Intended Outcomes
- Filter optical flame transients via continuous >= 250 ms confirmation before hazard escalation.
- Eliminate proximity boundary chatter using bi-level hysteresis (trip <= 30.0 cm, clear > 33.0 cm held >= 350 ms) and EMA distance smoothing.
- Detect missing ultrasonic echoes after 800 ms (displaying NO ECHO / ZONE UNKNOWN) while persisting lifetime hazard activations in ATmega328P EEPROM.
02 · System Architecture
Architecture & Signal Flow
Non-blocking millis() cooperative executive on ATmega328P (16 MHz, 5V) polling HC-SR04 ultrasonic ranging (D2/D3) and IR flame sensing (D9/A0), driving a 0.96" SSD1306 I2C OLED (0x3C), Green/Red LEDs (D4/D5), 2.4 kHz piezo buzzer (D6), and dual-mode pushbutton (D7).
HC-SR04 Ultrasonic Ranging
TRIG D2 · ECHO D325 ms echo timeout, 0.60/0.40 EMA smoothing, 30.0 cm trip / 33.0 cm clear hysteresis.
Hardware bench tested (IT-02, IT-07, IT-08)
IR Optical Flame Channel
DO D9 · AO A0Triggers on DO LOW or AO <= 800 held >= 250 ms; clears after 1,200 ms hold at AO >= 850.
Hardware bench tested (IT-03, IT-04)
Operator Pushbutton & EEPROM
D7 (INPUT_PULLUP) · Addr 0x000035 ms debounce, <2 s audio mute vs >=2 s ARM/DISARM toggle, 0xF17E hazard counter.
Hardware bench tested (IT-05, IT-06, IT-09)
Local OLED & Audio/Visual Outputs
I2C 0x3C · D4/D5 LEDs · D6 BuzzerSSD1306 128x64 telemetry screen + Safe/Hazard LEDs + 2.4 kHz variable-cadence piezo.
Hardware bench tested (IT-01..IT-04)
03 · Implementation & Design Rationale
Technical Implementation Details
- Non-Blocking Scheduling (`src/main.cpp`): Polls sensors every 100 ms, refreshes SSD1306 OLED every 250 ms, and logs serial telemetry every 500 ms without blocking delay() calls.
- Single-Button Operator Control: INPUT_PULLUP switch (35 ms debounce) handles short press (< 2.0 s) to silence active buzzer while keeping visual alert active, and long press (>= 2.0 s) to toggle ARMED / DISARMED.
- Non-Volatile Counter: EEPROM address 0x0000 stores magic signature 0xF17E plus a 32-bit `hazardStarts` counter verified across power cycles.
Key Engineering Decisions
- Enforced >= 250 ms continuous optical confirmation before triggering flame alerts and 1,200 ms hold (AO >= 850, DO = HIGH) to clear.
- Implemented bi-level proximity hysteresis (30.0 cm trip / 33.0 cm clear) and 800 ms stale-echo timeout rather than holding the last valid distance.
- Removed an initially tested DHT22 sensor from the final circuit and firmware after unreliable single-wire read tests.
04 · Verified Individual Contributions
My Direct Engineering Work
- Authored the C++ non-blocking millis() executive, temporal persistence, bi-level hysteresis, and single-button mute/arm state machine
- Built EEPROM event-counter persistence (signature 0xF17E) and SSD1306 I2C telemetry display formatting
- Configured automated PlatformIO (`nanoatmega328`) CI build checks via GitHub Actions
Technical Challenges
- Filtering transient optical flashes and threshold chatter near 30 cm without introducing sluggish hazard response
- Ensuring disconnected or out-of-range ultrasonic sensors visibly report NO ECHO / ZONE UNKNOWN instead of falsely signalling SAFE
05 · Verified Outcomes & Future Scope
Verified Results & Demonstrations
- All 9 bench integration scenarios (IT-01 through IT-09: Armed Nominal, Zone Intrusion, 250 ms Flame Hold, Dual Hazard, Short-Press Silence, Long-Press Arm/Disarm, Hysteresis Clear, Echo Timeout, EEPROM Power-Cycle) observed passing on physical breadboard.
- PlatformIO `nanoatmega328` build passes with 729 bytes / 2,048 bytes RAM (35.6%) and 21,660 bytes / 30,720 bytes Flash (70.5%).
- Physical 830-point solderless breadboard prototype assembled and photographed displaying live OLED state ("Luma Guard / Armed / Dist: 12.5 cm").
Authentic Project Visuals

Proposed Future Scope (Not Yet Implemented)
- Transition from solderless 830-point breadboard wiring to a rigid enclosure and soldered prototype carrier if extended beyond the academic bench scope.
- Add UART/telemetry export or secondary thermal sensing only after bench characterization.