You are building a critical IoT safety device — a smart smoke and fire detector. It monitors 12 environmental variables in parallel: temperature, humidity, TVOC, eCO2, raw hydrogen, ethanol, barometric pressure, and five particulate matter metrics.
The industry standard for Edge AI demands megabytes of Flash, custom memory allocators, a dynamic runtime, and a dependency chain long enough to make you reconsider the whole project. This project takes a different path: train the network on desktop, export it as a standalone C header, and drop it directly into any firmware. No runtime. No framework. No dependencies.
The DataNo synthetic data. The Smoke Detection Dataset — collected in the field at 1 Hz by German researcher Stefan Blattmann — provides real environmental readings under real conditions: normal rooms, controlled wood-burning tests, outdoor air, active indoor smoke formation.
12 environmental features: Temperature, Humidity, Barometric Pressure, Raw H2, Raw Ethanol, eCO2, TVOC, PM1.0, PM2.5, NC0.5, NC1.0, NC2.5.
The CNT column — a sequential row counter — was dropped. It caused the network to memorize row position instead of learning chemistry. Classic data leakage.
Class balance: 44, 757 fire events vs 17, 873 clean air samples. Undersampled to 35, 746 balanced rows.
Architecture12 → 8 → 4 → 1. ReLU hidden layers, Sigmoid output. 96 weights total.
TrainingTrained with Hasaki 刃先 — a CLI C++ tool that trains feedforward networks on desktop and exports standalone C headers.
Adam optimizer, learning rate 0.001, early stopping with patience 1000. Converged at epoch 2, 013. Final validation loss: 0.000008.
Results on unseen data (7, 150 samples)True Negatives: 3, 547 — clean air correctly identified True Positives: 3, 598 — fire events correctly flagged False Positives: 4 — 0.11% of clean-air cases False Negatives: 1
Accuracy: 99.93%. Sensitivity: 99.97%.
The 3.8 kB headerThe entire model — weights, biases, activation functions, and inference code — fits in 3.8 kB of Flash. Generated by Hasaki, it drops directly into any C/C++ firmware with no dependencies.
Firmware integrationThe state accumulator requires 3 consecutive predictions above 0.5 before triggering the alarm. A real fire doesn't disappear in 3 seconds. An isolated sensor spike does.
Note on hardwareThis project demonstrates the full training and export pipeline using a real-world dataset. Physical sensor integration follows the same pattern as any ESP32 project — the header drops in, predict() runs, the rest is sensor reading and normalization.
SourceGitHub: https://github.com/AlexRosito67/hasaki-smoke-detectorHasaki: https://github.com/AlexRosito67/hasakiDataset: https://www.kaggle.com/datasets/deepcontractor/smoke-detection-dataset








Comments