Skip to main content

House Alarm

A house alarm system combining motion detection, proximity monitoring and event logging.

info

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

Block Diagram

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

Kicad Schematic

Hardware pictures

Hardware picture

Hardware picture

Bill of Materials

DeviceUsagePrice
Rapspberry Pi Pico WThe microcontroller35 RON
PIR HC-SR501Motion Sensor6 RON
HC-SR04Distance Sensor15 RON
SG90 180°Servomotor12 RON
1602 LCDLCD Display15 RON
KeypadKeypad7 RON
MicroSD ModuleMicroSD Card Slot Module5 RON
Activ BuzzerBuzzer1.5 RON
Push ButtonButton1 RON
Jumper WiresConnecting components7 RON
BreadboardProject board10 RON

Software

LibraryDescriptionUsage
embassy-rpRP2040 pheripheralsUsed for accesing the pheripherals of the microcontroller
embassy-timeTime LibraryUsed for creating timeouts and delays
embassy-futuresFutures libraryUsed for asynchronous development
embassy-syncSynchronization primitivesUsed for syncronizing asynchronous tasks
embassy-embedded-halI2C and SPI busses for embedded hal implemented in embassyUsed to create a SPI bus for the MicroSD
heaplessData structures that don’t require dynamic memory allocationUsing Strings from this library
ag-lcdDisplay libraryUsed for writing to the display
embedded-sdmmc-rsSD Card libraryUsed for writing to the MicroSD
  1. https://howtomechatronics.com/projects/arduino-security-alarm-system-project/
  2. https://www.instructables.com/Arduino-Motion-Sensing-Alarm/