Sens-Nexus and ML Sensors
IoT cloud platform plus on-device ML on ESP32.
Summary
A Laravel cloud platform plus ESP32-S3 sensor firmware with on-device ML inference. Custom binary model format roughly ten times smaller than TFLite.
Problem
Embedded sensor systems for chemical detection need real-time on-device classification. Sending data to a server for inference is too slow and requires connectivity. TFLite Micro works but is large and constrained. The Sens-Nexus stack is end-to-end: a cloud platform that streams data, trains models, and distributes them to devices, plus firmware that runs inference at 10Hz with 20ms latency.
Architecture
Cloud platform: Laravel 12 with sensor streaming engine handling 20+ samples per second using a 100-sample cache buffer, lock-based concurrency, and CSV-on-disk to reduce I/O from hundreds per second to one per five seconds. Auto-discovery sensor configuration triggered by the first data burst. Multi-format model distribution: pickle, C header, binary, and ONNX. Custom SPCM binary model format: 16-byte header, embedded scaler params, flat node arrays at 20 bytes per node, 160-tree forest in roughly 55KB. Firmware: ESP32-S3 FreeRTOS dual-core (sensor I/O on Core 0, UI and inference on Core 1) with a 100ms cycle. SpectraScope MK4 with 18-channel spectral triad and OTA model management with hot-swap.
Outcomes
- Custom SPCM model format approximately 10x smaller than TFLite equivalent
- 20+ samples per second sensor streaming through the cloud platform
- 10Hz inference at 20ms latency with a 20KB tensor arena
- 13 chemical class real-time classification on-device
- OTA model hot-swap without device reboot
- Bayesian hyperparameter optimization with Hyperopt TPE
Hardest bits
- Custom binary model format with embedded scaler parameters and flat node arrays
- FreeRTOS dual-core architecture with non-blocking 100ms cycle covering sensor read, scaling, inference, serialization, broadcast, and display
- OTA model hot-swap during inference without dropping the prediction stream
- SPI bus arbitration for SD card and display sharing