Hardware-Leitfaden
ESP32 für Anomaly Detection mit TensorFlow Lite Micro
The ESP32 runs autoencoder-based anomaly detection with TFLite Micro by learning normal sensor patterns and flagging deviations. Models under 20 KB fit easily in the 520 KB SRAM, leaving headroom for Wi-Fi reporting and multi-sensor monitoring.
Veröffentlicht 2026-04-01
Hardware-Spezifikationen
| Spez. | ESP32 |
|---|---|
| Prozessor | Dual-core Xtensa LX6 @ 240 MHz |
| SRAM | 520 KB |
| Flash | 16 MB |
| Konnektivität | Wi-Fi 802.11 b/g/n, Bluetooth 4.2 BR/EDR + BLE |
| Preisbereich | $2-5 (Chip), $5-15 (Board) |
Kompatibilität:
Anomaly detection is the most resource-efficient ML workload — typical autoencoder models are 10-20 KB with minimal Inferenz-Latenz. The ESP32's 520 KB SRAM bietet over 16x die 32 KB Mindestanforderung. This headroom matters because anomaly detection often runs alongside other Anwendungslogik: Sensor-Abfrage, data buffering, Wi-Fi communication, and threshold management. TFLite Micro's static memory allocation model works well here — allocate a fixed tensor arena and the rest is available for the application. The Xtensa LX6 architecture is fully supported by TFLite Micro with CMSIS-NN-equivalent optimizations. The ULP co-processor can handle Sensor-Abfrage during deep sleep, waking the main processor only when readings exceed configurable thresholds. Wi-Fi enables real-time anomaly reporting to MQTT brokers or HTTP endpoints.
Erste Schritte
- 1
Set up sensor data collection
Verbinde vibration (ADXL345), temperature (DS18B20), or current sensors (ACS712) to the ESP32 via I2C or ADC. Log baseline data during normal operation — you need 1000+ samples of 'normal' behavior to train an effective autoencoder.
- 2
Train an autoencoder in TensorFlow
Build a small autoencoder (3-4 layers, 10-20 neurons per layer) in TensorFlow/Keras. Train only on normal data — the model learns to reconstruct normal patterns. High reconstruction error indicates an anomaly.
- 3
Quantize and convert the model
Apply int8 post-training quantization with TFLite converter. The quantized autoencoder should be under 20 KB. Convert to a C array with xxd -i for embedding in firmware.
- 4
Implement anomaly scoring on ESP32
Führe Inferenz aus on each sensor reading window. Calculate reconstruction error (MSE between input and output). Set an anomaly threshold based on the error distribution from validation data. Report anomalies via MQTT when the error exceeds the threshold for N consecutive windows.
Alternativen
ESP32-C3 with TFLite Micro
Half the cost ($1-3 chip) with 400 KB SRAM — more than enough for anomaly detection. Single-core RISC-V is sufficient. Best choice for high-volume, cost-sensitive deployments.
STM32L4 with TFLite Micro
Ultra-low-power (< 100 nA shutdown) for battery-opebewertet monitoring. 128 KB SRAM is sufficient for anomaly models. No Wi-Fi — use BLE or wired connection for data reporting.
Häufige Fragen
- What type of anomaly detection model runs on ESP32?
- Autoencoders are the standard approach. A small autoencoder (3-4 layers, 10-20 KB quantized) learns to reconstruct normal sensor patterns. When the reconstruction error exceeds a threshold, the system flags an anomaly. No need to label failure modes — the model only needs normal data for training.
- How accurate is anomaly detection on ESP32?
- Accuracy depends on the quality of training data and threshold calibration. With 1000+ normal samples and proper sensor placement, autoencoder-based detection typically achieves 90-95% true positive rate at <5% false positive rate. Tune the threshold using validation data with known anomalies.
- Can the ESP32 monitor multiple sensors simultaneously für anomalieerkennung?
- Yes. The ESP32's 520 KB SRAM handles multi-channel input (vibration + temperature + current) within a single autoencoder. The dual-core architecture lets one core handle sensor sampling while the other runs inference. Typical multi-sensor anomaly detection uses under 50 KB total RAM.
Anomalieerkennung mit ForestHub orchestrieren
Sensoren und Geräte melden Anomalien; ForestHub auf dem Linux-Edge-Gateway korreliert sie über MQTT/Modbus/OPC-UA und handelt an der Linie als deterministischer, auditierbarer Graph.
Kostenlos starten