Skip to main content

Object Detection and Alert System

Automated Surveillance and Notification Interface.

info

Author: Mahmoud Mirghani Abdelrahman
GitHub Project Link: https://github.com/UPB-FILS-MA/project-Abd210

Description

The project utilizes an HC-SR04 ultrasonic sensor, a servo motor ,an lcd, and a buzzer. Here's how it works:

Radar-like Functionality: The servo motor is attached to the ultrasonic sensor, allowing it to sweep back and forth like a radar. This setup helps the sensor detect objects across a range of angles.

Detection and Alerts: When an object is within range, the ultrasonic sensor measures the distance to the object and stops the servo motor's rotation. A buzzer then sounds, alerting me to the presence of an obstacle.

Real-time Feedback: The buzzer continues to sound until the object moves away, allowing the servo to resume its sweeping motion. During detection, the system displays the distance to the object and the servo's angle on an LCD screen, providing me with real-time information about the object's position.

This project effectively combines ultrasonic sensing, servo control, and audio alerts to create a functional radar-like detection mechanism with real-time feedback, making it suitable for obstacle detection and range measurement applications.

Motivation

I chose this project to create a functional radar-like system for obstacle detection and range measurement, utilizing my skills in ultrasonic sensing, servo control, and real-time feedback. I was also inspired by a YouTube video on similar technology.

Architecture

Architecture Scheme

    Components:
Sensor Module: The HC-SR04 ultrasonic sensor measures the distance to nearby objects.

Control Module:
A Raspberry Pi Pico microcontroller manages the sensor's operations, controlling the servo motor and processing data from the ultrasonic sensor.

Alert Module:
A buzzer provides an audio alert when an object is detected.

Display Module:
An LCD screen provides real-time feedback, displaying the distance to the detected object and the angle of the servo motor.

Connections:

LCD Screen: 
Connected to the Pico with:
SDA to PIN_16
SCL to PIN_17
Ground to Ground
VSYS to VDD
Ultrasonic Sensor:
Connected to the Pico with:
Trig to GP21
Echo to GP20
VCC to VBUS
Ground to Ground
Buzzer:
Connected to the Pico with:
Ground to Ground
Positive to PIN2
Servo Motor:
Connected to the Pico with:
Signal to PIN28
VCC to VBUS
Ground to Ground

Log

Week 6 - 12 May

I purchased the components for my project and tested them individually to ensure they worked properly. This initial testing phase helped me plan how to implement the code effectively.

I created the initial KiCad schematic and decided which pins to use for each component. During this process, I received assistance from the lab teachers for the servo motor because it wasn't functioning properly and it worked at the end.

By working step-by-step, I successfully managed to make all the components work independently. Each part performed as expected when tested on its own.

Now, I just needed to put everything together and finish the coding. Combining the individual codes and making sure everything worked together was the final step.

Week 7 - 19 May

Despite the initial setup, I connected everything to the Pico and modified the initial KiCad schematic to change some pins. This involved careful adjustments to ensure all connections were accurate.

I tried to integrate the code for all the components. The components I managed to combine were the LCD, ultrasonic sensor, and buzzer. Each of these worked perfectly when tested together.Everything worked except for the servo, which did not function.

I connected the pins and took photos of the hardware setup. I used my kicad schematic to do this.

Week 20 - 26 May

I successfully resolved most of the bugs in my code and managed to integrate the servo motor. Initially, the servo motor was not functioning correctly.

With the assistance of my lab teacher, we were able to troubleshoot the issue. Together, we modified the code to ensure the servo motor operated as intended.

Additionally, I attached the servo motor and the ultrasonic sensor, enhancing both the functionality and the overall appearance of the project.

Hardware

The hardware used includes:

  1. Raspberry Pi Pico: A microcontroller that manages the project's operations, controlling the servo motor, processing sensor data, and handling other components.

  2. HC-SR04 Ultrasonic Sensor: Measures the distance to nearby objects, providing range data for obstacle detection.

  3. Servo Motor: Moves the ultrasonic sensor back and forth in an arc, mimicking radar scanning.

  4. Buzzer: Provides an audio alert when an obstacle is detected.

  5. LCD Screen: Displays real-time feedback on the distance to detected objects and the angle of the servo motor. Detail in a few words the hardware used.

This is what the project looks like: Hardware picture This is an upclose picture of the wiring: Upclose Hardware picture

Schematics

Kicad schematic

Bill of Materials

DeviceUsagePrice
Rapspberry Pi Pico WThe microcontroller35 RON
Micro Servomotor SG90 90°The micro servomotor14 RON
Modul cu Buzzer activActive buzzer2,49 RON
Male to male jumper wiresWires6.98 RON
Male to female jumper wiresWires6.98 RON
Ultrasonic sensor HC-SR04measure distance and detect the object6.49 RON
lcd1602display9.83

Software

LibraryDescriptionUsage
pwmPulse-width modulationUsed for controlling the buzzer's sound intensity
embassy-executorAsynchronous executor for Rust embedded systemsUsed for task scheduling and asynchronous programming
embassy-timeTime management libraryUsed for time-based operations such as delays
embassy-rpPeripheral access libraryUsed for initializing and interacting with peripherals
logLogging facadeUsed for logging messages
embassy-usb-loggerUSB logger implementation for embassyUsed for logging messages over USB
gpioGPIO manipulationUsed for interacting with GPIO pins
HC-SR04HC-SR04 manipulation
Used for controlling the ultrasonic sensor
  1. DIY Radar with Ultrasonic Sensor