A cost-effective, real-time smart home security solution built with Raspberry Pi, MQTT, and Android, demonstrating the practical application of IoT principles in residential safety.
Warsha Kiringoda (waki2609@student.su.se)
Chang Liu (cl0024556@gmail.com / chli6238@student.su.se)
Ivoshani Senevirathne (lase4127@student.su.se)
The goal of this project is to design and implement a functional, low-cost home security system that enhances user convenience and safety. It features real-time monitoring, automated responses, and a mobile interface with three distinct operational modes to suit different security scenarios.
- Real-time Functionality: Alerts, light automation, and live camera feed.
- User Interaction: An Android-based mobile application for remote control and status monitoring.
- Multi-mode Operation: Three specialized modes: Stay, Away, and Night.
The system's behavior changes dynamically based on the selected mode:
| Mode | Purpose | Core Functions |
|---|---|---|
| Stay | Protects perimeter while allowing internal motion | Monitors doors/windows; records events without triggering loud alarms. |
| Away | High-level notification for unoccupied house | Monitors all sensors; sends instant push notifications for any event. |
| Night | Maximum alerting for sleeping hours | Monitors door/window sensors; triggers immediate alerts/alarms upon breach. |
- IoT System: Integrated with 3 sensors (Motion, Door, Window) and 1 control device (Raspberry Pi).
- Android App: Features login, live camera feed, light toggling, sensor status, and event history.
- Automation: Light auto-toggles based on motion detection.
- Hardware: Raspberry Pi, PIR Motion Sensor, Magnetic Reed Switches (Door/Window), TellDus/Tellstick.
- Protocols: MQTT (test.mosquitto.org) for low-latency, real-time communication between hardware and mobile app.
- Software:
- Backend: Python (RPi.GPIO, gpiozero libraries).
- Frontend: Android (Java/Kotlin), Simple HTML/CSS/JS for sensor simulation.
- Methodology: Scrumban with iterative testing.
- A Python script (
motionserver.py) runs on the Raspberry Pi, opening a port for HTTP POST requests. - Data (0 or 1) is published to the topic
iotproject/motionvia MQTT at 1-second intervals. - The Android app subscribes to this topic and updates the UI instantly upon state changes.
- Hardware: Magnetic reed switches connected to Raspberry Pi GPIO pins and Ground (GND).
-
Logic: * Closed: Magnet is near the switch (Circuit Closed)
$\rightarrow$ LOW signal.-
Open: Magnet moves away (Circuit Open)
$\rightarrow$ HIGH signal.
-
Open: Magnet moves away (Circuit Open)
-
Monitoring: Uses
gpiozeroto detect state transitions in real-time.
- Reliability: Ensured low-latency communication between the Raspberry Pi and the app by implementing the MQTT publish-subscribe model.
- System Setup: Overcame Raspberry Pi configuration hurdles through rigorous documentation consultation and connection testing.
- Logic Design: Defined mode-specific behaviors by simulating real-world security scenarios and user requirements.
- AI Integration: Implement AI for threat detection and passenger recognition via camera image analysis.
- Scalability: Expand the system to support multi-home management.
- UI/UX: Further enhance the Android application's data management and interface design.