AI on the Edge Device Documentation
repository·main·Indexed 27 days ago
https://github.com/jomjol/ai-on-the-edge-deviceA project using an ESP32-CAM and TensorFlow Lite to convert analog water, gas, and electricity meter readings into digital data via edge-based AI. Features include image processing for ROI extraction, a web interface for administration, OTA updates, and data integration with MQTT, InfluxDB, and Home Assistant.
What's inside AI on the Edge Device
- AI on the Edge Device is a project that uses an ESP32-CAM to digitize analog meters (water, gas, or electricity). It utilizes edge computing to process images locally, extracting meter values using TensorFlow Lite (TFLite) without requiring cloud computing. The device captures photos at set intervals, identifies Regions of Interest (ROIs), and runs AI models to produce a digitized value.
Key Features of AI on the Edge Device
mainThe device provides several capabilities for meter digitization and data integration:
- AI/ML: TensorFlow Lite (TFLite) integration with an easy-to-use wrapper.
- Image Processing: Inline processing including feature detection, alignment, and ROI extraction.
- Hardware: Small, affordable ESP32-based device with integrated camera and illumination.
- Connectivity & Control: Web interface for administration, OTA (Over-the-Air) updates via Wi-Fi, and MQTT protocol support.
- Data Integration: Full integration with Home Assistant, support for InfluxDB (versions 1 and 2), and a REST API for data access.
Key Features of Miniz
mainMiniz provides several specialized capabilities for embedded and high-performance applications:
- Zlib Compatibility: Implements zlib and Deflate standards with a portable, single-source/header implementation.
- Stream-based Processing: Supports coroutine-style stream processing (not block-based). The zlib-style API functions can be called one byte at a time.
- Low-level Codecs: The
tdefl(compressor) andtinfl(decompressor) low-level APIs use simple state structs that can be saved/restored viamemcpy. These APIs do not use the heap. - Archive & Image Support: Includes APIs for reading/writing/appending
.ZIParchives and writing.PNGformat image files. - Real-time Compression: Features a specialized real-time compressor designed to compete with
fastlzandminilzo.
Flash the ESP32 Firmware
mainInitial firmware installation must be done via a USB connection. Subsequent updates can be performed via OTA (Over-the-Air) using the web interface.
Available flashing methods:
- Web Installer and Console (Preferred): A browser-based tool that flashes the ESP32 and allows log extraction over USB.
- Espressif Flash Tool
- ESPtool (command-line tool)
Refer to the Installation documentation for detailed steps.
Setup the SD Card
mainThe SD card is required for device operation. It can be set up in two ways:
- Automatic Setup: After flashing the firmware, the SD card can be configured automatically via the built-in access point. The SD card must be FAT formatted.
- Manual Setup: You can manually prepare the SD card by following the manual installation guide.
Use the Web-Installer to flash the ESP32
mainThe Web-Installer is a browser-based tool used to flash the AI on the Edge Device firmware onto your ESP32-CAM. The files required for the installer are automatically updated during each release via GitHub Actions.Enable Setup Mode for the next device start
mainSet the
SetupModeparameter totrueto ensure the device remains in Setup Mode after its next restart.Important: This parameter cannot be configured via the Web Interface Configuration Page. It must be set through other available configuration methods (such as direct parameter manipulation if supported by your interface).
Manually edit MaxRateValue in the configuration file
mainWhen editing the configuration file manually, you cannot use
MaxRateValueas a standalone key. Because this parameter is specific to each number sequence defined in the ROIs (Regions of Interest), you must prefix the parameter with the name of the<NUMBER>sequence followed by a dot.Example: If your number sequence is named
main, the configuration key must bemain.MaxRateValue.main.MaxRateValueSet up a prepared demo on the SD Card
mainTo use a prepared demo setup, copy the specific configuration and image files into the
configfolder of your SD Card, then restart the device. This allows you to test the device using pre-defined reference images and settings.Required files to copy to the SD Card
configfolder:config.iniref0.jpgref1.jpgreference.jpgprevalue.ini
Use the Gasmeter Value History Downloader
mainThe Gasmeter Value History Downloader is a tool designed to download datafiles (
*.txtfor versions before V13.0.1 or*.csvfor versions V13.0.1 and newer) from an ESP32 device. It extracts the last value of each day and stores them in a single consolidated*.csvfile.Prerequisites
- Enable DataLogging: You must activate DataLogging in your device configuration via
Configuration / Data Logging / DataLogActive. - Retention Policy: Ensure your device's data retention setting (in days) is greater than or equal to the number of days you intend to download.
Configuration Variables
To use the tool, you must provide the following parameters:
- URL to Logfile-Path on Device: The base URL where the files are hosted, typically
http://<ESP32-IP-Address>/fileserver/log/. - Download datafiles to: A local directory path where the raw files will be saved (e.g.,
D:\Gaszaehler\Auswertung\Log-Downloads\). - Output CSV-File: The local path and filename for the consolidated daily values file (e.g.,
D:\Gaszaehler\Auswertung\DailyValues.csv). - Download past # days: The maximum number of past days to download (starting from yesterday). This value must be less than or equal to your device's configured data retention value. Note that the tool does not download data for the current day.
- Enable DataLogging: You must activate DataLogging in your device configuration via
Prepare the SD Card for AI on the Edge Device
mainTo set up the SD card for the device, do not copy the contents of the
sd-card/folder from this repository directly onto your SD card. Doing so will result in a non-functional setup.Instead, you must use the artifacts generated by the Build-Pipeline. The files in the
htmlfolder within this repository are only templates; the functionalhtmlfolder required for the device is generated during the GitHub Actions build process.Download Latest Releases
mainThe latest firmware and release assets can be found on the official GitHub Releases page.
https://github.com/jomjol/AI-on-the-edge-device/releases