An open-source, ultra-low-power Edge AI sensor node utilizing an ESP32 microprocessor and INMP441 digital microphone to detect illegal logging operations via on-device Convolutional Neural Network (CNN) inference, featuring real-time telemetry routing.
Illegal logging presents a critical threat to global forest ecosystems. Traditional monitoring methodologies heavily rely on manual patrols, which are resource-intensive, slow, and geographically limited. The Forest Ranger project proposes a scalable, automated monitoring solution: a distributed network of low-power acoustic sensors designed to continuously analyze ambient forest audio.
This system leverages TinyML principles to execute an 8-bit quantized Convolutional Neural Network directly on the edge device (ESP32). By classifying acoustic signatures locally rather than streaming continuous audio data to cloud servers, the architecture significantly reduces bandwidth consumption, ensures operational privacy, and minimizes power requirements. Upon positive classification of a chainsaw acoustic signature, the system generates a lightweight JSON payload and dispatches a real-time push notification to relevant authorities via the Telegram Bot API.
The hardware architecture is divided into the current laboratory-tested Minimum Viable Product (MVP) and the proposed specifications for field deployment.
Phase 1: MVP Prototype (Current Implementation)
- Microprocessor: ESP32 NodeMCU (30-Pin, ESP-WROOM-32 module). Selected for its optimal balance of computational capability, integrated wireless stacks, and cost-efficiency.
- Acoustic Sensor: INMP441 Omnidirectional MEMS Microphone. Selected for its integrated I2S (Inter-IC Sound) interface, which bypasses the ESP32's internal Analog-to-Digital Converter (ADC) to provide high-fidelity, noise-free digital audio capture.
- Prototyping Platform: Standard 830-Tie Point Breadboard with Male-to-Male (M2M) jumper routing.
- Power Supply: 5V USB direct connection.
Phase 2: Proposed Field Deployment
- Telemetry Migration: Transition from IEEE 802.11 (Wi-Fi) to an SX1278 LoRaWAN Transceiver. This enables a Star Topology Mesh network capable of transmitting telemetry data over 5-10 kilometer ranges in off-grid environments.
- Power Management: Integration of a 5V 5W Monocrystalline Solar Panel coupled with an 18650 Lithium-Ion Battery Shield (utilizing a TP4056 charge controller) for sustained autonomous operation.
Strict adherence to the I2S protocol mapping is mandatory.
Important Hardware Constraint: The INMP441 microphone requires a strict 3.3V power supply. Connecting the VDD pin to a 5V source will result in permanent hardware failure.
| INMP441 Sensor | ESP32 (30-Pin) | Signal Description |
|---|---|---|
| VDD | 3V3 | 3.3V Logic Power Supply |
| GND | GND | System Ground |
| L/R | GND | Channel Selection (Grounding selects the Left Audio Channel) |
| WS | GPIO 15 | Word Select (Left/Right Clock Synchronization) |
| SCK | GPIO 14 | Continuous Serial Clock |
| SD | GPIO 32 | Serial Data (Digital Audio Stream) |
The acoustic classification system was developed and validated using the Edge Impulse platform. The pipeline processes raw audio waveforms into visual features, which are then analyzed by a neural network.
- Input: 16 kHz audio sampled via the I2S interface.
- Feature Extraction: The raw audio is processed into a Mel-filterbank Energy (MFE) spectrogram. This method transforms the time-domain audio signal into a frequency-domain visual representation, prioritizing the frequency bands most relevant to human and mechanical acoustic signatures.
- DSP Performance: The feature extraction process requires approximately 40 ms of processing time and consumes 22 KB of peak RAM on the ESP32.
- Network Type: Convolutional Neural Network (CNN).
- Optimization: The model underwent Int8 Quantization using the EON (Edge Optimized Neural) Compiler. This process converts 32-bit floating-point weights into 8-bit integers, drastically reducing the model's memory footprint with negligible loss in accuracy.
- Inference Performance: The final quantized model requires only 1 ms of inferencing time, 12.8 KB of peak RAM, and 40.3 KB of Flash memory storage.
During the validation phase against the test dataset, the Int8 Quantized model achieved the following metrics:
- Overall Accuracy: 100.0%
- Validation Loss: 0.00
- F1 Score: 1.00 (Perfect precision and recall across both "Background" and "Chainsaw" classes).
The firmware is written in C++ utilizing the Arduino core for ESP32.
The following libraries must be installed within the compilation environment:
UniversalTelegramBot(Handles API requests and payload formatting).ArduinoJson(Required for parsing Telegram API responses).Edge Impulse Inferencing Library(Custom C++ library exported from the trained model).
To compile the firmware, users must configure their specific network and API credentials.
- Navigate to the
firmware/forest_ranger/directory. - Locate
secrets_template.hand rename it tosecrets.h. - Input the required parameters:
#define WIFI_SSID "ENTER_WIFI_SSID_HERE" #define WIFI_PASSWORD "ENTER_WIFI_PASSWORD_HERE" #define TELEGRAM_BOT_TOKEN "ENTER_BOT_TOKEN_HERE" #define TELEGRAM_CHAT_ID "ENTER_CHAT_ID_HERE"