$ show jomjol/AI-on-the-edge-device
This repository implements a complete embedded IoT system for automated meter reading (water, gas, electricity) using an ESP32-CAM with on-device TensorFlow Lite inference. The firmware captures images, performs alignment and ROI extraction, runs digit and analog pointer recognition via quantized TFLite models, applies post-processing (consistency checks, rate limiting, decimal shift), and publishes readings via MQTT, InfluxDB (v1/v2), Webhook, or a built-in REST API. The architecture follows a modular flow-control pattern with separate components for camera control, image processing, neural network inference, configuration, logging, and output protocols. A full-featured web interface provides setup wizards, live data graphs, OTA updates, and file management. The system is designed for low-power edge deployment on ESP32 with PSRAM and SD card storage.
The LLM identified 4 files worth highlighting for reuse:
A standalone, header-only C++ library for reading and writing 24-bit BMP images. Provides pixel access, color space conversions, geometric transforms (subsample, upsample, rotate), edge detection (Sobel), histogram, PSNR, and drawing primitives (lines, circles). Includes predefined colormaps for scientific visualization. No external dependencies beyond the C++ standard library, making it easily reusable in any embedded or desktop project.
A self-contained, public-domain compression library implementing deflate, inflate, and ZIP archive handling. Used in this project for OTA firmware updates and file serving. The library is a single C file with minimal dependencies, suitable for resource-constrained embedded systems. It can be extracted and reused in any project requiring compression or archive support.
A custom MQTT outbox implementation that uses PSRAM (external SPI RAM) to buffer outgoing messages, addressing memory constraints on ESP32. It provides a circular buffer with atomic operations for thread-safe enqueue/dequeue, and integrates with the ESP-MQTT client. This pattern is reusable for any ESP32 project needing reliable MQTT publishing with limited internal RAM.
A lightweight HTTP Basic Authentication filter implemented as a lambda wrapper for ESP-IDF's HTTP server. It validates credentials against a configurable username/password and returns 401 on failure. The implementation is minimal, self-contained, and can be easily adapted to protect any HTTP endpoint on ESP32 or similar platforms.