Intrusion Detection
Security system that performs different actions based on the distance of a person or an object
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
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
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico WH | The Microcontroller | 56.23 RON |
Ultrasonic Sensor (HC-SR04) | Object detection | 6.49 RON |
LCD 1602 I2C | The Display | 16.34 RON |
Sets of Resistors 10R-1M | Current Modulation | 12.29 RON |
Micro USB Cable | For flashing the program to the microcontroller | 3.48 RON |
Breadboard | For connections | 10.14 RON |
Jumper Wires | For connections | 11.86 |
Female-to-male Wires | For connections | 5.79 RON |
Male-to-male Wires | For connections | 2.85 RON |
Female-to-female Wires | For connections | 7.99 RON |
9V Battery | DC Voltage source | 29.74 RON |
9V Battery Holder | DC Voltage source holder | 1.29 RON |
LEDs | Indicator | 0.45 RON |
Buzzers | Indicator | 1.40 RON |
Servo Motors | Indicator | 11.99 RON |
Software
Library | Description | Usage |
---|---|---|
lcd1602-driver | Driver for the LCD 1602 I2C | Used to operate the LCD 1602 |
heapless | Used to make strings on the pico | Needed to convert data to string in order to display the data on the LCD 1602 I2C |
hc_sr04 module | Driver for the HC-SR04 Ultrasonic Sensor | Used to operate the HC-SR04 Ultrasonic Sensor |
pwm | Pulse-Width Modulation | Used for controlling the servo motors and the buzzer's noise level |
embassy-executor | Asynchronous Executor for Embedded Rust Systems | Used for task scheduling and asynchronous programming |
embassy-rp | Hardware Abstraction Layer for the RP2040 | Used to operate the peripheral devices connected the Raspberry Pi Pico |
embassy-time | Time management library | This library is used for managing timekeeping, timeouts and delays |
gpio | Library for handling GPIO functionalities | Used to control and configure GPIO pins on the microcontroller board |
log | Lightweight Logging Facade | Used for logging messages |
embassy-usb-logger | USB implementation of the log crate | Used for logging messages over USB |