Skip to main content

Intrusion Detection

Security system that performs different actions based on the distance of a person or an object

info

Author: Zafar Azzam
GitHub Project Link: https://github.com/UPB-FILS-MA/project-Azzamjoy44

Description

  • I will use an Ultrasonic sensor to detect an object, and to see how close an object is to the sensor. Based on how close the object is, certain actions will happen.

  • When the sensor will detect an object within a specific range (e.g., 70 cm) an LED will light up. If the object gets even closer to the sensor (e.g., 50 cm) the LED will remain lit and a buzzer (alarm) will start buzzing. And when the object comes even closer ( e.g., less than or equal to 30cm), the LED will remain lit and the buzzer will keep buzzing and two servo motors (with carboard attached) will rotate 90 degrees (one servo motor will rotate clockwise, the other servo motor will rotate anticlockwise) to show a closing gate.

  • If the object starts moving away, and moves beyond a specific distance (e.g., 30 cm) from the sensor, the two servo motors will rotate back to their initial state, but the buzzer will keep buzzing and the LED will remain lit. If the object keeps moving further away and moves beyond another specific distance (e.g., 50 cm), the buzzer will stop buzzing but the LED will remain lit. And finally, when the object moves further away (e.g., more than 70 cm), the LED will turn off.

  • An LCD will be constantly displaying the distance between the object and the sensor.

Motivation

I decided on this idea because of its real world applications. This project is an inexpensive and portable method of identifying intrusion in an area. The initiative aims to raise awareness of health and safety issues, particularly in enclosed environments, by utilizing the Raspberry Pi Pico's capabilities. With the help of this gadget, users can be informed about any risks in real time and be equipped to act quickly. In the end, people's living and working conditions become safer.

Architecture

ArchitectureArchitecture

Log

Week 6 - 12 May

I managed to make the HC-SR04 ultrasonic sensor work properly. I also managed to make the LED turn on and remain lit when the distance between an object and the sensor is less than or equal to 60 cm, and the LED turns off when the object goes beyond 60 cm away from the sensor.

Week 7 - 19 May

I was able to make the buzzer start buzzing, and keep the LED lit on, when the distance between an object and the sensor is less than or equal to 45 cm. Now when the object is more than 45 cm away from the sensor and is less than or equal to 60 cm away from the sensor, the buzzer stops buzzing, but the LED remains lit and the LED functionalities are intact. I managed to make the LCD 1602 I2C work but I need to integrate the LCD into my project.

Week 20 - 26 May

I managed to make the LCD work with my project and it now displays in real-time how far away an object is from the sensor. I also successfully integrated both servo motors into my project. So when an object is less than 30 cm away from the sensor, one servo motor will rotate 90 degrees clockwise and the other servo motor will rotate 90 degrees anti-clockwise. And when the object goes beyond 30 cm away from the sensor, both servo motors will go back to their initial state. The project is now complete.

Hardware

  • I'm using the Raspberry Pi Pico WH development board, which has the RP2040 microcontroller chip that handles processing and interfaces with every piece of hardware.

  • Components will be connected using a breadboard and female-to-male jumper wires, male-to-male jumper wires, and female-to-female jumper wires.

  • Object detection and distance measurement will be handled by the HC-SR04 Ultrasonic sensor. Various states will be indicated by; a monochromatic LED that is connected with a 1K resistor to limit the current, a Buzzer, and two SG90 Servo motors.

  • An I2C LCD will be used to display the distance between the sensor and the object in real-time.

  • The complete system can be powered on a 9V battery, which makes the system portable and independent.

These are images of the physical hardware and connections Hardware1 Hardware2

Schematics

KiCad

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico WHThe Microcontroller56.23 RON
Ultrasonic Sensor (HC-SR04)Object detection6.49 RON
LCD 1602 I2CThe Display16.34 RON
Sets of Resistors 10R-1MCurrent Modulation12.29 RON
Micro USB CableFor flashing the program to the microcontroller3.48 RON
BreadboardFor connections10.14 RON
Jumper WiresFor connections11.86
Female-to-male WiresFor connections5.79 RON
Male-to-male WiresFor connections2.85 RON
Female-to-female WiresFor connections7.99 RON
9V BatteryDC Voltage source29.74 RON
9V Battery HolderDC Voltage source holder1.29 RON
LEDsIndicator0.45 RON
BuzzersIndicator1.40 RON
Servo MotorsIndicator11.99 RON

Software

LibraryDescriptionUsage
lcd1602-driverDriver for the LCD 1602 I2CUsed to operate the LCD 1602
heaplessUsed to make strings on the picoNeeded to convert data to string in order to display the data on the LCD 1602 I2C
hc_sr04 moduleDriver for the HC-SR04 Ultrasonic SensorUsed to operate the HC-SR04 Ultrasonic Sensor
pwmPulse-Width ModulationUsed for controlling the servo motors and the buzzer's noise level
embassy-executorAsynchronous Executor for Embedded Rust SystemsUsed for task scheduling and asynchronous programming
embassy-rpHardware Abstraction Layer for the RP2040Used to operate the peripheral devices connected the Raspberry Pi Pico
embassy-timeTime management libraryThis library is used for managing timekeeping, timeouts and delays
gpioLibrary for handling GPIO functionalitiesUsed to control and configure GPIO pins on the microcontroller board
logLightweight Logging FacadeUsed for logging messages
embassy-usb-loggerUSB implementation of the log crateUsed for logging messages over USB
  1. Using an Ultrasonic sensor with Raspberry Pi Pico
  2. Using a servo motor with a Raspberry Pi Pico