In heavy industrial facilities such as steel mills, installing revenue-grade power meters across every secondary branch or remote feeder is cost-prohibitive. However, auxiliary parameters—like reactive power (inductive and capacitive) and power factors—are already monitored by local power-factor correction units and sub-panels.
This project implements an edge neural soft sensor running on a bare-metal ESP32. By feeding 6 auxiliary telemetry parameters into an INT8-quantized Multilayer Perceptron (MLP), the microcontroller predicts real-time active power consumption (Usage_kWh) with laboratory-grade accuracy, zero cloud dependencies, and minimal silicon footprint.
Hardware & Key Performance Metrics
- Runtime Framework: TensorFlow Lite for Microcontrollers (TFLM)
- Model Size: 4.23 KB Flash (compared to 34.1 KB Float32 baseline)
- SRAM Tensor Arena: 772 Bytes
- On-Device Inference Latency: 121 microseconds
- Model Accuracy (Hold-out test set, N=7, 008): R^2 Score: 0.9991 | Mean Absolute Error (MAE): 0.608 kWh
System Architecture
The pipeline takes 6 industrial telemetry inputs:
1) Lagging_Reactive_Power_kVarh
2) Leading_Reactive_Power_kVarh
3) CO2(tCO2)
4) Lagging_Power_Factor
5) Leading_Power_Factor
6) NSM (Number of Seconds from Midnight)
Edge Pipeline Workflow:
- MinMax Normalization: Input features are normalized using precomputed training ranges directly on the MCU.
- INT8 Quantization: Features are scaled to integer representation (
q = x / scale + zero_point). - TFLM Inference: The INT8 neural network executes inside a dedicated 772-byte memory arena.
- Dequantization: Model output is translated back into engineering units (
Usage_kWh).
Running floating-point neural networks on microcontrollers without hardware FPUs introduces significant latency. By applying Post-Training Quantization (PTQ) with a representative telemetry dataset:
- Size Reduction: ~87.6% drop in binary weight footprint.
- Speedup: Inference drops from ~650 µs (emulated float) down to121 µs per sample.
- Accuracy Trade-off: Negligible performance degradation (Float32 MAE: 0.463 kWh vs INT8 MAE: 0.608 kWh).
The full source code, Python training pipelines, test suite, and pre-compiled ESP32 binaries (firmware.bin and .tflite model) are available under the MIT license on GitHub:













Comments