anetezepa / Bees Summer Public

Bees Summer

HappyBees: Distributed IoT Beehive Monitoring System Summer Model

Audio
temperature moisture weight

About this project

HappyBees: Distributed IoT Beehive Monitoring System

beewatch_logo.png

HappyBees is a distributed IoT beehive monitoring system. It uses edge ML on a Raspberry Pi Pico 2 W to detect swarming events via acoustic analysis and uploads telemetry to a central server with a real-time dashboard. The project is powered by Bee Summer and Bee Winter models.

HappyBees_small.gif


Architecture

The model is a Convolutional Neural Network (CNN) classifier originally developed in PyTorch. To ensure efficiency on the Pico 2 W, the pipeline follows three steps:

  1. Develop: Custom PyTorch Convolutional Neural Network (CNN).
  2. Integration: Integrated via Edge Impulse's Bring Your Own Model (BYOM) feature - use ONNX to export.
  3. Deploy: Exported as an optimized TensorFlow Lite neural network (C++ library).

It took us 7 models before we got here.


Biological Basis

Bees exhibit regular daily and seasonal patterns that machine learning can predict. They forage during the day and return to the hive at night to process nectar (fanning) and regulate temperature.

These distinct activities create predictable acoustic, temperature and humidiity snensor readings. By focusing on "Summer" patterns, the model distinguishes high-energy events like swarming or queen piping from standard hive activities.

Screenshot 2025-11-30 at 20.43.42.png


Summer model

The Summer model detects swarming/piping events based on acoustic analysis. Key points:

  • Primary Feature: Spike Ratio - The model primarily uses the ratio of current audio energy to historical average. A spike > 1.3 indicates increasing activity (potential swarm), while < 0.7 indicates decreasing activity (normal settling).
  • Why "Always Swarming" on Fresh Start - With no history, spike ratio = 1.0 (steady state), which the model treats as potentially concerning. After 5-6 readings, the rolling average stabilizes.
  • Gain Calibration - Different microphone circuits require different gain compensation. Default is 0.35 for TLC272CP op-amp. Adjust with g command until FFT bins are 0.02-0.06 for a quiet room.

Key insight: The model detects changes in acoustic activity, not absolute sound levels. It is most sensitive to the "spike ratio" feature, which compares current audio energy to a rolling historical average.

output.gif


Model Architecture

1.1 Input Features (20 elements)

The model expects a 20-element float32 feature vector:

Index Feature Range Description
0 Temperature 0-50 C Hive internal temperature
1 Humidity 0-100% Hive internal humidity
2 Hour 0-23 Time of day
3 Spike Ratio 0.1-10+ Current density / Rolling average
4-19 FFT Bins 0.0-1.0 Frequency magnitudes (125-594 Hz)

For input details and how to extract them correctly for audio features (FFT Bins), see specifics on HappyBees GitHub Model Guide.

Temperature and humidity can be used as raw numbers.


1. 2 Sensor wiring

happybees_schematic.png

sensors_top.jpeg

sensor_wiring_back.jpg

The bees build mathematically perfect hexagons, and here I am making solder joints that look like a pigeon flew over the board and just let go.

Use hardware at your own risk.

Thankfully you can try out the model using numeric inputs here at Edge Impulse Studio.


1.3 Output Classes

Index Label Meaning
0 Normal Hive operating normally
1 Event Potential swarming/piping activity

Technical Specifications

The Summer Model is a custom 1D-CNN designed for time-series classification of sensor fusion data.

For full code see the HappyBees GitHub.

Feature Specification
Architecture 1D Convolutional Neural Network (PyTorch)
Weight Layers 5 (3 Convolutional + 2 Fully Connected)
Input Shape (Batch, 1, N_Features) (Dynamic)
Output Binary Classification [Normal, Event]
Format ONNX (with embedded Min/Max scaling)

Architecture Flow

The model condenses high-dimensional audio/sensor data into abstract features using three reduction blocks:

  1. Input: Normalization Wrapper (x - min) / scale
  2. Feature Extraction: 3x Blocks of Conv1dBatchNormReLUMaxPool1d
    • Filter growth: 16 → 32 → 64 filters
  3. Classification: FlattenLinear (64 neurons) → Dropout (0.2) → Output

Training Parameters

  • Optimizer: Adam (lr=0.002) with StepLR scheduler (halves LR every 5 epochs).
  • Loss: CrossEntropyLoss.
  • Epochs: 15 (tuned for early convergence without overfitting).

Watch demo

Watch HappyBees Demo on YouTube


Want to learn more?

More details on the summer model can be found in HappyBees GitHub Model Guide.

More details on the whole project can be found on HappyBees GitHub.

Check out the Winter Bees Edge Impulse project

summer_ei_numeric

Run this model

On any device

Dataset summary

Data collected
8m 20s
Sensors
temperature, humidity, hour, audio_spike_ratio, hz_122.0703125, hz_152.587890625, hz_183.10546875, hz_213.623046875, hz_244.140625, hz_274.658203125, hz_305.17578125, hz_335.693359375, hz_366.2109375, hz_396.728515625, hz_427.24609375, hz_457.763671875, hz_488.28125, hz_518.798828125, hz_549.31640625, hz_579.833984375 @ 1Hz
Labels
bee_activity

Project info

Project ID 835586
License 3-Clause BSD
No. of views 393
No. of clones 0