The Problem: Varroa Destructor
Varroa mites are parasitic mites that attach to honeybees and feed on their hemolymph (bee blood). Left unchecked, they can devastate an entire colony within months. Early detection is absolutely critical—but manually inspecting thousands of bees is time-consuming and often catches infestations too late.
Traditional monitoring methods involve sticky boards, alcohol washes, or visual inspections during hive checks. These are invasive, labor-intensive, and only give you a snapshot of a single moment in time. We needed something better.
System Overview
System in Action
Here's what the system looks like in practice, from the mites we're detecting to the alerts in action.
A varroa mite (reddish-brown) attached to a honeybee. These parasites are only 1-2mm but can devastate entire colonies.
YOLOv11n model output showing detected mites with bounding boxes and confidence scores.
Automated alert received when the system detects potential varroa presence, with annotated image attached.
Hardware Setup
Each hive has its own monitoring station, completely solar-powered and weatherproof. Here's what goes into each setup:
- Camera: 4K resolution camera module (critical for catching tiny mites)
- Computer: Raspberry Pi 4 (handles image capture and uploads)
- Power: Solar panel + battery system (fully off-grid operation)
- Mounting: Custom 3D-printed housing positioned above hive entrance
- Storage: Local SD card backup + cloud upload to server
- Network: WiFi connection to home network for uploads
Camera Positioning
The cameras are mounted directly above the hive entrance, pointing down at a 45° angle. This captures bees as they enter and exit, giving us clear views of their backs—where varroa mites typically attach. The 4K resolution is essential because varroa mites are only 1-2mm in size.
Model Training
I used YOLOv11n (YOLO "nano" - the lightweight version) for object detection. Here's how I trained it:
1. Dataset Preparation
Found approximately 7,000 labeled images of varroa-infected bees on Ultralytics' open dataset. These images show bees with clearly visible varroa mites attached, along with bounding box annotations marking exactly where the mites are located.
2. Model Selection
Chose YOLOv11n because:
- Speed: Fast enough to process images in near real-time on a Raspberry Pi
- Accuracy: Good balance between detection accuracy and computational efficiency
- Size: Small model footprint suitable for edge deployment
3. Training Configuration
Training Parameters
Epochs: 100 Batch size: 16 Image size: 640x640 Augmentation: Enabled (flips, rotations, brightness adjustments) Validation split: 20% Hardware: NVIDIA GPU (local training)
4. Results
After training, the model achieved:
- Precision: ~85% (when it says "varroa detected," it's right 85% of the time)
- Recall: ~78% (catches about 78% of actual varroa infestations)
- Inference time: ~200ms per image on Raspberry Pi
System Architecture
Here's how the entire system works, from camera to inbox:
graph TD
A[4K Camera] -->|Every 30 min| B[Raspberry Pi]
B -->|Capture Image| C[Local Storage]
C -->|Upload via WiFi| D[Server Directory]
D -->|Cron Job Every 30min| E[Analysis Script]
E -->|Load Image| F[YOLOv11n Model]
F -->|Run Inference| G[Varroa Detected?]
G -->|No| H[Log and Continue]
G -->|Yes| I[Generate Alert]
I -->|Email| J[Beekeeper Inbox]
I -->|Include| K[Annotated Image]
I -->|Include| L[Hive Identifier]
I -->|Include| M[Detection Confidence]
J -->|Manual Review| N[Inspect Hive]
Detailed Workflow
Step 1: Image Capture (Every 30 Minutes)
A cron job on each Raspberry Pi triggers the camera every 30 minutes. The Pi captures a 4K image of the hive entrance, stamps it with a timestamp and hive ID, and saves it locally.
Crontab Entry (Raspberry Pi)
*/30 * * * * /home/pi/capture_image.sh
Step 2: Upload to Server
Each Raspberry Pi then uploads the image to a central server directory via rsync or SFTP. The filename includes the hive name and timestamp for easy identification.
Example Filename
padme_2026-02-08_0830.jpg galadriel_2026-02-08_0830.jpg frigga_2026-02-08_0830.jpg
Step 3: Automated Analysis
A separate cron job on the server runs every 30 minutes, scanning the upload directory for new images. For each new image:
- Load the image into memory
- Pass it through the YOLOv11n model
- Parse detection results (bounding boxes, confidence scores)
- If varroa mites are detected above a confidence threshold (e.g., 70%), flag the image
Pseudocode: Analysis Script
for each new_image in upload_directory:
results = model.predict(new_image)
if results.detections.confidence > 0.70:
annotated_image = draw_boxes(new_image, results)
hive_name = extract_hive_from_filename(new_image)
timestamp = extract_timestamp(new_image)
send_alert_email(
to="beekeeper@berryjerrybees.com.au",
subject=f"⚠️ Varroa Alert: [hive_name]",
body=f"Varroa detected at [timestamp]",
attachment=annotated_image
)
log_detection(hive_name, timestamp, confidence) Step 4: Email Alert
When varroa is detected, I receive an email with:
- Subject line: "⚠️ Varroa Alert: [Hive Name]"
- Body: Timestamp, confidence score, and detection details
- Attachment: The original image with bounding boxes drawn around detected mites
- Hive location: Which queen's hive needs attention
Why Email Alerts?
Email is simple, reliable, and doesn't require maintaining a separate dashboard or app. I get push notifications on my phone, can view the image immediately, and have a searchable history of all detections. Plus, I can forward alerts to other beekeepers if I'm away.
Step 5: Manual Verification & Action
Once I receive an alert, I:
- Review the image: Check if the detection is a true positive (sometimes pollen or debris can trigger false positives)
- Inspect the hive: Do a physical inspection within 24 hours
- Take action: If confirmed, treat the hive immediately (oxalic acid vaporization, formic acid strips, etc.)
- Update records: Log the detection and treatment in my hive management system
Data Flow
Here's a simplified view of how data moves through the system:
sequenceDiagram
participant C as Camera
participant RPi as Raspberry Pi
participant S as Server
participant M as ML Model
participant B as Beekeeper
C->>RPi: Capture image (every 30min)
RPi->>RPi: Save locally
RPi->>S: Upload via WiFi
S->>S: New images detected
S->>M: Run inference
M->>M: Analyze for varroa
alt Varroa detected
M->>S: Return detections
S->>B: Send email alert
S->>S: Log event
else No varroa
M->>S: No detections
S->>S: Log clear result
end
Real-World Impact & Results
🎯 Project Status: Prevention-First Approach
So far, I'm fortunate to report zero varroa detections across all six hives. This system wasn't built in response to an infestation—it's a proactive, passion project designed to catch problems before they start. Think of it as an early warning system that complements my existing monitoring methods, particularly alcohol washes.
The goal was never just to detect varroa after it appears, but to build a continuous monitoring system that gives me peace of mind and catches the first signs of trouble weeks earlier than traditional methods alone.
✅ What's Working Well
- Continuous peace of mind: 24/7 monitoring without disturbing the hives
- Complements alcohol washes: Visual monitoring between invasive sampling
- Non-invasive: No need to open hives or stress bees for routine checks
- Historical data: Building a baseline dataset of healthy hive entrance activity
- Scalable: Easy to add more cameras as the apiary grows
- Learning experience: Deep dive into computer vision and edge computing
⚠️ Challenges & Ongoing Improvements
- False positives: Pollen, wood debris, and bee shadows can trigger alerts
- Weather dependency: Heavy rain or fog can obscure the camera
- Night detection: Currently daylight-only; considering IR LEDs for night vision
- Model refinement: Need more real-world varroa images from my specific setup
- Power management: Winter months with less sunlight can be challenging
Next-Generation Improvements
🎨 K-Means Color Clustering for False Positive Reduction
One of the biggest challenges with the current system is false positives—pollen, shadows, and debris can sometimes be mistaken for varroa mites. The next major improvement I'm working on is using K-means clustering to analyze the color profile of detected objects.
How K-Means Will Help:
- Color signature analysis: Varroa mites have a distinct reddish-brown color (~RGB 139, 69, 19)
- Cluster dominant colors: Extract the main colors from each detected bounding box
- Compare against varroa profile: Check if the dominant cluster matches known varroa coloration
- Secondary validation: Only trigger alerts if both YOLO detection AND color clustering agree
- Reduce false positives: Filter out yellow pollen, dark shadows, and wood fragments
Conceptual Workflow
# After YOLO detects potential varroa
if yolo_detection.confidence > 0.70:
# Extract the detected region
cropped_region = image[bbox.y1:bbox.y2, bbox.x1:bbox.x2]
# Apply K-means clustering (k=3 to find dominant colors)
kmeans = KMeans(n_clusters=3)
colors = kmeans.fit(cropped_region.reshape(-1, 3))
dominant_color = colors.cluster_centers_[0]
# Check if dominant color matches varroa profile
varroa_color_range = ([120, 50, 10], [160, 90, 40]) # RGB range
if is_color_in_range(dominant_color, varroa_color_range):
confidence_boost = 1.2 # Increase confidence
send_alert()
else:
# Likely false positive - log but don't alert
log_potential_false_positive()
This approach should dramatically reduce false positives from yellow pollen (which clusters toward RGB ~255, 200, 0) and dark shadows (which cluster toward low RGB values). By combining computer vision object detection with color analysis, we get a much more robust detection system.
Other Planned Enhancements
- Multi-class detection: Expand model to detect other pests (small hive beetle, wax moths)
- Bee counting: Track hive population and foraging activity over time
- Temperature sensors: Integrate thermal monitoring for brood health
- Edge processing: Run inference directly on Raspberry Pi to reduce server load
- Historical trend analysis: Detect patterns that precede infestations
- Mobile app: Real-time push notifications instead of email
- Other Detection Models: Explore DETR or YOLO v12 to fine tune and minimise false positives
Technology Stack
graph LR
A[Hardware Layer] --> B[Raspberry Pi 4]
A --> C[4K Camera Module]
A --> D[Solar Panel System]
E[Software Layer] --> F[Python 3.11]
E --> G[Ultralytics YOLOv11]
E --> H[OpenCV]
E --> I[PIL/Pillow]
J[Infrastructure] --> K[Linux Server]
J --> L[Cron Jobs]
J --> M[SMTP Email]
J --> N[rsync/SFTP]
O[ML Pipeline] --> P[Model: YOLOv11n]
O --> Q[Dataset: ~7000 images]
O --> R[Framework: PyTorch]
Questions? Want to Build Your Own?
I'm happy to share more details about the setup, code, or answer questions from fellow beekeepers interested in implementing similar systems. This kind of technology could be game-changing for small-scale beekeepers who don't have time for constant manual monitoring.
Get in touch: hello@berryjerrybees.com