Animal Detection and Alert System using Raspberry Pi and YOLO
Abstract
Human–animal conflict is a serious problem in rural and forest-adjacent areas, leading to crop damage and threats to human safety. This project presents a low-cost, edge-based intelligent system that detects the presence of animals within a predefined distance and identifies the type of animal using a deep learning model. The system uses a Raspberry Pi 4 and an ultrasonic sensor to detect proximity. Once an object is detected within 1 meter, a camera module is activated and a YOLO-based object detection model is used to classify the animal. Based on the detected animal (pig, cow, or elephant), a corresponding sound alert is played repeatedly to scare the animal away. The system continuously monitors the distance and stops operation when the animal leaves the area. Objectives
To detect the presence of animals within a specified distance using an ultrasonic sensor
To identify the type of animal using a deep learning-based object detection model (YOLO)
To generate audio alerts corresponding to the detected animal
To reduce unnecessary computation by activating the camera only when required
To develop a low-cost and energy-efficient edge AI solution
Hardware Requirements
Raspberry Pi 4 Model B (4GB recommended)
Ultrasonic Sensor (HC-SR04)
Raspberry Pi Camera Module
Speaker / Audio Output Device
Voltage Divider (for ECHO pin protection)
Power Supply (5V, 3A)
SD Card (32GB or higher)
Software Requirements
Raspberry Pi OS (64-bit)
Python 3
OpenCV
Ultralytics YOLOv5
Pygame
RPi.GPIO
PyTorch
System Methodology
The ultrasonic sensor continuously measures distance.
If an object is detected within 1 meter, the camera module is activated.
A single image frame is captured and passed to the YOLOv5 model.
The model detects and classifies the animal.
If the detected animal is pig, cow, or elephant, the corresponding sound is played 5 times.
The system rechecks the distance.
If the object is no longer within 1 meter, the system returns to idle state.
Block Diagram (Textual Description)
Ultrasonic Sensor → Raspberry Pi → Camera Module → YOLO Detection → Audio Alert System
Applications
Prevention of crop damage in agricultural fields
Early warning system in forest border areas
Wildlife monitoring systems
Smart farming solutions
Advantages
Low power consumption
Edge-based processing (no internet required)
Modular and scalable design
Real-time response
Limitations
Detection accuracy depends on lighting conditions
Limited to predefined animals
Performance constrained by Raspberry Pi hardware
Future Scope
Addition of more animal classes
Integration with GSM module for alerts
Use of thermal cameras for night detection
Cloud-based data logging and analytics
Hardware acceleration using Coral TPU
Conclusion
This project demonstrates the effective integration of embedded systems and artificial intelligence for real-world problem solving. By combining proximity sensing with deep learning-based object detection, the system minimizes power consumption while providing accurate and timely alerts. The project highlights the potential of edge AI in solving practical challenges in agriculture and wildlife management.
Developed By
Dhruv
Minor Project – Electronics and Communication Engineering (ECE) 6th semester