House Alarm
A house alarm system combining motion detection, proximity monitoring and event logging.
Author: Smarandache Mihai
GitHub Project Link: https://github.com/UPB-FILS-MA/project-Mihai1803
Description
A house alarm system triggered by motion detection and proximity monitoring. It includes the following features:
- Detection of motion presence using a motion sensor
- Proximity monitoring using a distance sensor mounted on a servomotor rotating 180 degrees
- Activation of a buzzer alarm when motion is detected and the presence is close enough
- Deactivation of the buzzer alarm by entering a code using a keypad
- Displaying the entered code on an LCD screen
- Logging of detection events to a MicroSD card
- Automatic shutoff of the buzzer alarm if the code is not entered within 1 minute
Motivation
I chose this as my first embedded project because it allows me to put into practice the skills and knowledge that I have gained throughout this course. Implementing a house alarm system involves integrating various components such as motion sensors, distance sensors, keypad input, and the LCD display, thus allowing me to apply concepts ranging from hardware interfacing to software development.
Moreover, this project presents a real-life application that can be scaled and potentially benefit others by enhancing security measures in homes.
Overall, this project not only consolidates my learning but also offers a solution to a practical problem.
Architecture
The project has the following architecture:
- Raspberry Pi Pico: The Pico has the role of connecting all the components between them
- LCD: Connected to the Pico via I2C, the LCD provides an interface for displaying system statuses, messages and inputs
- Motion and Distance Sensors: These sensors detect motion and proximity separately. They provide input to the pico about potential intruders
- Servormotor: The servormotor is controlled by the Pico through PWM and it serves as a platform for mounting the distance sensor so that it can rotate 180°
- Buzzer: Controlled by PWM, the buzzer is triggered when motion is detected in proximity to the sensors. It acts as an audible alarm
- Keypad and Push Button: The keypad allows the user to input a code to disarm the alarm. Aditionally, a stop button provides a manual override to stop the alarm if necessary
- MicroSD Card: Used for data logging and storage, the MicroSD card records system events, sensor reading and alarm triggers
Log
Week 6 - 12 May
- Uploaded the initial documentation for the project
- Began assembling the hardware
- Started working on the software
Week 7 - 19 May
- Completed the hardware
- Updated the documentation for the hardware milestone
- Continued developing the software
Week 20 - 26 May
- Made adjustments to the code to implement all desired features
- Completed the software and uploaded it to the project repository
- Tested the software and hardware to ensure that everything works properly
Hardware
The hardware setup for this project consists of a Raspberry Pi Pico microcontroller as the main control unit. It utilizes a PIR HC-SR501 motion sensor and an HC-SR04 ultrasonic distance sensor to detect potential intruders. The ultrasonic distance sensor is mounted on an SG90 servomotor, which rotates 180 degrees to provide a broader detection range.
For data logging and storage, a microSD module is used to log on a MicroSD every alarm trigger and store the disarm code of the alarm system. Users can input the disarm code using a 4x4 matrix keypad, and a 1602 LCD display is used to show the input code, alarm triggers, and system messages.
To provide control, there are two push buttons: one for submitting the code entered via the keypad and another for manually stopping the alarm.
Schematics
Hardware pictures
Bill of Materials
Device | Usage | Price |
---|---|---|
Rapspberry Pi Pico W | The microcontroller | 35 RON |
PIR HC-SR501 | Motion Sensor | 6 RON |
HC-SR04 | Distance Sensor | 15 RON |
SG90 180° | Servomotor | 12 RON |
1602 LCD | LCD Display | 15 RON |
Keypad | Keypad | 7 RON |
MicroSD Module | MicroSD Card Slot Module | 5 RON |
Activ Buzzer | Buzzer | 1.5 RON |
Push Button | Button | 1 RON |
Jumper Wires | Connecting components | 7 RON |
Breadboard | Project board | 10 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-rp | RP2040 pheripherals | Used for accesing the pheripherals of the microcontroller |
embassy-time | Time Library | Used for creating timeouts and delays |
embassy-futures | Futures library | Used for asynchronous development |
embassy-sync | Synchronization primitives | Used for syncronizing asynchronous tasks |
embassy-embedded-hal | I2C and SPI busses for embedded hal implemented in embassy | Used to create a SPI bus for the MicroSD |
heapless | Data structures that don’t require dynamic memory allocation | Using Strings from this library |
ag-lcd | Display library | Used for writing to the display |
embedded-sdmmc-rs | SD Card library | Used for writing to the MicroSD |