Intruder Detection System Using Arduino Uno R3
Intruder Detection System Using Arduino Uno R3
Department of CSE
Lab Project Report
Submitted To:
Mr. Ovishake Sen
Lecturer, Department of CSE
Southeast University
Submitted By:
Name: Saleh Ibne Omar
ID: 2017000000040
Name: MD Jabir Hussain Shuvo
ID: 2018000000129
Name: Morjina Akter
ID: 2018000000102
Date of Submission:
12 October 2022
1
Title:
Theory:
Apparatus:
Hardware: Arduino Uno R3, Ultrasonic sonar sensor HC-SR04, Servo motor SG90,
Temperature and humidity sensor DHT11, Active buzzer speaker, Red LED, 1/4w
resistor, Breadboard, Jumper wires.
Implementation:
The system uses Arduino Uno R3 as the mainboard, the servo motor used here acts
as the actuator of the sonar sensor which has been mounted on top of the servo
motor, whenever the servo rotates to a certain degree the sonar sensor also rotates,
and the DHT11 sensor acts as the dynamic temperature detection for the sonar
system to work properly in any weather conditions, it is well known that sonar
system emits ultrasonic waves continuously and the speed of the wave depends on
the temperature of the surrounding environment. The active buzzer and the LED is
there just for alerting mechanism, all the sensors and output devices get power
2
equally from the breadboard where a positive and negative column is directly
connected to the Arduino’s VCC and GND port respectively.
Circuit Diagram:
Ultrasonic sonar sensor: The VCC and GND pin of the sensor is connected to the
positive and negative column of the breadboard respectively, the trig pin is
connected to the 8th digital port and the echo pin is connected to the 9th port of the
Arduino.
Servo motor: The VCC and GND wire of the motor is connected to the positive and
negative column of the breadboard respectively, and the Pulse wire is connected to
the 5th digital PWM port of the Arduino.
Temperature and Humidity sensor: The VCC and GND pin of this sensor is
connected to the breadboard similarly to the sonar sensor and servo motor, and the
Data pin is connected to the 3rd digital pin of the Arduino.
Active buzzer: The positive pin of the buzzer is connected to the 11th digital port of
the Arduino Uno and the negative pin is connected to the negative column of the
breadboard.
3
Red LED: The positive pin of the LED is connected to the 13th digital pin of the
Arduino through a ¼ w ohm resistor and the negative pin is connected to the
negative column of the breadboard.
Applications:
Intruder detection
Radar system
Security system to protect expensive items
Source Code:
#include <dht.h>
#include <Servo.h>
dht DHT;
Servo servo;
int tempSensorPin = 3;
int servoPin = 5;
int trigPin = 8;
int echoPin = 9;
void rotateServo(){
if(servoIncr){
servo.write(servoDeg);
if(servoDeg%5==0){
4
calculateDistance();
alertOn();
delay(servoDelay);
else if(!servoIncr){
servo.write(servoDeg);
if(servoDeg%5==0){
calculateDistance();
alertOn();
delay(servoDelay);
velocity = (velocity/1000000.00)*100;
void calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
Serial.print("Distance = ");
Serial.println(distance, 4);
5
void alertOn(){
if(distance<=30){
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 500);
Serial.println("Intruder Detected!");
void setup() {
Serial.begin(9600);
servo.attach(servoPin);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
void loop(){
delay(500);
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
Serial.println(currTemp);
calculateVelocity(currTemp);
Serial.print("Velocity = ");
Serial.println(velocity, 4);
rotateServo();
6
Serial Monitor Output:
7
Discussion:
The servo motor of this embedded system can rotate from 50 degrees to 130 degrees
and vice versa, the ultrasonic sonar sensor is mounted on the top of the servo motor
so when the servo rotates the sonar rotates along with it, for every multiplier of 5
for a certain degree the sonar emits ultrasonic sound and then the distance is
calculated, from 50 to 130 and 130 to 50-degree rotation the sonar sensor calculates
distance 32 to 34 times and looks for an object within 30cm if an object is detected
within the range this system turns on the Buzzer and Red LED.
Limitations:
The servo motor used in the system cannot rotate 360 degrees
The system cannot detect objects which move at a high speed
The range of the sonar sensor used for this system is only 2cm to 400cm
If the system calculates distance for every degree change of the servo
motor’s actuator then the servo rotation becomes very slow
To solve slow servo rotation the distance measurements were reduced, the
system only measures when the rotated degree is a multiplier of 5
The system has a delay of 500ms for every repetition of the actual operation
Conclusion:
By doing this intruder detection system project we learned how embedded systems
works and how to develop one from scratch, we also learned how an intrusion
detection system works and how it can be used for different security purposes. The
various tools we used to develop this system gave us a thorough understanding of
their working mechanisms, uses, and limitations.
8
References:
Source code:
https://github.com/salehibneomar/intruder-detection-system-using-
arduino/blob/main/Code.ino
Circuit Diagram:
https://www.tinkercad.com/things/7jAxSHx9GCI?sharecode=NcGwdITaJqLtMb5a8T
GkpMQ5E_MzUGqQr4rZQTOXKLQ
Video:
https://youtube.com/shorts/6TDajTS58bI
Articles:
https://forums.raspberrypi.com/viewtopic.php?t=184576
https://www.teachmemicro.com/ultrasonic-sensor-temperature-compensation/