Foresight
Inspiration
Forests are not only vulnerable to illegal human activity. They are also home to complex ecosystems containing countless species, including endangered animals whose habitats are increasingly threatened.
We created Foresight to help preserve these natural habitats by continuously listening to the forest environment. By monitoring changes in acoustic activity, Foresight can help identify threats such as chainsaws, gunshots, vehicles, and other human disturbances, while also providing insight into the health and activity of the surrounding ecosystem.
Our long-term goal is not simply to detect illegal deforestation, but to protect the natural habitat of animals and endangered species by giving conservation teams continuous, real-time intelligence about what is happening inside the forest.
How We Built It
Foresight uses connected acoustic beacons to capture environmental audio and send it to a backend for analysis.
The backend:
- Decodes incoming audio.
- Uses YAMNet for sound classification.
- Calculates forest soundscape health using the Acoustic Complexity Index.
- Combines threat likelihood with acoustic changes.
- Correlates events across multiple beacons.
- Displays alerts and system status on a live dashboard.
The current demonstration combines a physical acoustic beacon with simulated beacons. The map uses representative forest coordinates, while the hardware is being tested locally.
Scaling to Hundreds of Beacons
A real deployment could contain hundreds of acoustic beacons operating simultaneously. We therefore designed Foresight around an asynchronous, distributed architecture rather than requiring one server process to handle every beacon sequentially.
Beacons can perform lightweight processing locally and transmit relevant events, metadata, and short audio segments rather than continuously streaming large amounts of raw audio.
The backend can place incoming data into a message queue, allowing multiple processing workers to analyze recordings in parallel. As the number of beacons increases, additional workers can be added horizontally without changing the individual beacon architecture.
This also helps maintain low latency. Heartbeats and event metadata can be processed almost immediately, while computationally heavier tasks such as YAMNet classification can happen asynchronously. The system can therefore continue accepting new beacon data even when previous recordings are still being analyzed.
For large-scale deployments, we also plan to explore LoRa/LoRaWAN communication for low-power, long-range transmission of beacon metadata and detected events to a gateway. Because LoRa is not designed for high-bandwidth raw audio, larger audio samples would be transmitted through a higher-bandwidth connection when necessary.
Reliable Audio Processing
Raw microphone data can contain electrical bias, wind, fans, traffic, and other background noise. To improve reliability, each sample passes through filtering and noise suppression before being displayed or uploaded.
Digital Sample Conversion
The microphone produces a signed signal inside a 32-bit I2S sample. The firmware shifts it into a practical audio range:
$$ x_n = \left\lfloor \frac{r_n}{2^{16}} \right\rfloor $$
where (r_n) is the raw I2S sample and (x_n) is the converted sample.
float x = (float)(rawValue >> RAW_TO_16BIT_SHIFT);
Slow signal drift and electrical bias are removed using a first-order high-pass filter:
$$ y_n = x_n - x_{n-1} + \alpha y_{n-1} $$
Here, (\alpha) controls how gently the filter removes low-frequency drift.
float y = x - hpPrevInput + hpCoefficient * hpPrevOutput;
hpPrevInput = x;
hpPrevOutput = y;
Adaptive Noise Gate
Instead of using only a fixed threshold, Foresight continuously estimates the surrounding ambient noise:
$$ N_n = (1-\eta)N_{n-1}+\eta|y_n| $$
The adaptive threshold is then calculated as:
$$ T_n = \max(N_n \times \lambda,F) $$
where:
- (N_n) is the estimated ambient noise.
- (\eta) is the adaptation rate.
- (\lambda) is the noise multiplier.
- (F) is the minimum noise floor.
The signal is passed through only when:
$$ |y_n|>T_n $$
Otherwise, it is treated as noise:
$$ z_n = \begin{cases} y_n,&|y_n|>T_n\ 0,&|y_n|\leq T_n \end{cases} $$
The firmware also briefly holds the gate open after detecting a loud sound. This prevents real events from being fragmented as their waveform crosses zero.
int32_t magnitude = abs(filtered);
float threshold = noiseEstimate * noiseMultiplier;
if (threshold < NOISE_FLOOR)
threshold = NOISE_FLOOR;
if (magnitude > threshold) {
gateHoldCounter = GATE_HOLD_SAMPLES;
}
Sensitivity and Clipping Protection
After filtering, digital sensitivity is applied:
$$ g_n=S\times z_n $$
The result is then limited to the valid signed 16-bit PCM range:
$$ p_n=\operatorname{clip}(g_n,-32768,32767) $$
if (sample > 32767)
sample = 32767;
if (sample < -32768)
sample = -32768;
This allows the microphone gain to be adjusted without corrupting the uploaded audio.
Real-Time OLED Visualization
The OLED displays the same filtered and gated signal used for backend processing. This makes the local waveform a direct representation of the signal being analyzed.
For each display column, the firmware selects the strongest signed sample:
$$ p_{\text{column}}= \operatorname*{arg\,max}_{z_n}|z_n| $$
The value is scaled to the OLED's vertical range:
$$ v_n= \operatorname{clip} \left( \frac{S\times z_n\times M}{R}, -M,M \right) $$
where (M) is the maximum display swing and (R) is the expected microphone peak range.
The sign is preserved, so the waveform moves above and below the centerline like a true oscilloscope trace.
Audio Classification
YAMNet is Foresight's audio classification model. It analyzes incoming WAV audio and produces probabilities for different sound categories.
The system maps relevant results into categories such as:
- Chainsaw
- Gunshot
- Engine
- Vehicle
- Chopping
- Wind
- Animal and bird sounds
A lightweight fallback classifier is available when YAMNet is unavailable. It considers signal duration, spectral content, transient behavior, and sustained energy. Loudness alone is not treated as proof of a gunshot, because chainsaws and engines can also be extremely loud.
Beyond threat detection, animal and bird acoustic activity can provide useful information about species presence and ecosystem activity, allowing the same infrastructure to contribute to habitat monitoring.
Measuring Forest Soundscape Health
Foresight calculates an Acoustic Complexity Index using spectral changes over time.
For each time frame (t) and frequency bin (k), (X_{t,k}) represents the spectral magnitude. The ACI is approximated as:
$$ \mathrm{ACI}= \frac{1}{K} \sum_{k=1}^{K} \frac{ \sum_{t=2}^{T}|X_{t,k}-X_{t-1,k}| }{ \sum_{t=2}^{T}X_{t,k} } $$
This measures changes in acoustic energy across time and frequency. It helps Foresight estimate whether the soundscape is active, stable, or experiencing unusual disruption.
Threat Scoring
Foresight can combine the sound classifier's threat score with changes in the surrounding soundscape to improve confidence in detected events.
Final Score = 0.7 × Threat Score + 0.3 × ACI Change
This prevents the system from relying on a single measurement. A possible threat becomes more important when both the classifier and the soundscape indicate abnormal activity.
This approach reduces reliance on a single signal by considering both the detected sound and changes in the wider acoustic environment. This prevents the system from relying on a single measurement. A possible threat becomes more important when both the classifier and the soundscape indicate abnormal activity.
What We Learned
We learned that environmental audio classification is more complex than simply detecting loud sounds. Chainsaws, engines, gunshots, and natural sounds can all produce strong signals, but their duration, frequency patterns, and energy behavior are different.
We also learned that reliability depends on the complete system:
- Microphone calibration
- Noise suppression
- Signal scaling
- Network stability
- Audio encoding
- Model loading
- Backend processing
- Clear visualization
Separating audio capture from network communication was especially important. The microphone and OLED can continue operating even when Wi-Fi or backend processing is delayed.
Challenges
One major challenge was false gunshot detection. An earlier version classified any signal with a high peak as a gunshot. This caused close-range chainsaw recordings to be mislabeled.
We improved the system by adding:
- A DC-blocking filter
- An adaptive noise gate
- Configurable sensitivity
- Clipping protection
- Sustained-energy analysis
- YAMNet classification
- Real-time OLED feedback
Another challenge was streaming audio from a resource-constrained microcontroller. Instead of storing a large recording in memory, the beacon processes audio in chunks and streams it to the backend while continuously updating the OLED.
Future Development
Future work includes collecting licensed field recordings, evaluating YAMNet in real forest environments, improving adaptive soundscape baselines, optimizing battery life, and deploying the backend with secure cloud storage.
We also plan to explore LoRa/LoRaWAN-based low-power communication, more sophisticated animal and species detection, improved multi-beacon event localization, and distributed backend infrastructure capable of supporting hundreds or potentially thousands of acoustic beacons.
Our long-term goal is to create a mass-deployable forest intelligence network that helps conservation teams detect human threats, monitor ecosystem activity, understand animal habitats, and protect endangered species. It aims to provide continuous environmental awareness without requiring constant human presence in remote forests.
Built With
- ai
- autodesk-fusion-360
- esp32
- flask
- iot
- javascript
- machine-learning
- postgresql
- react
- tensorflow
- yamnet


Log in or sign up for Devpost to join the conversation.