https://github.com/nbsp1221/pi-home-security-system
🏠 Home security system using Raspberry Pi with IoT sensors and web interface
https://github.com/nbsp1221/pi-home-security-system
mqtt raspberry-pi
Last synced: 3 months ago
JSON representation
🏠 Home security system using Raspberry Pi with IoT sensors and web interface
- Host: GitHub
- URL: https://github.com/nbsp1221/pi-home-security-system
- Owner: nbsp1221
- License: mit
- Created: 2024-05-31T19:02:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T14:07:49.000Z (about 1 year ago)
- Last Synced: 2025-10-24T00:32:33.334Z (8 months ago)
- Topics: mqtt, raspberry-pi
- Language: Python
- Homepage:
- Size: 791 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🏠 Raspberry Pi Home Security System

A comprehensive home security system utilizing Raspberry Pi, equipped with temperature, humidity, flame, gas, and motion sensors, along with a live camera stream.
The system is built to store detection records in a MySQL database and can send alerts via MQTT.
> This project was developed as a school course project.
## Features
- **Temperature and Humidity Monitoring**: Logs data at regular intervals.
- **Flame Detection**: Detects and logs fire incidents.
- **Gas Detection**: Detects and logs gas leaks.
- **Motion Detection**: Logs motion events and captures video recordings.
- **Relay Control**: Allows remote control of a connected relay.
- **Live Camera Streaming**: Provides a real-time video feed.
- **MQTT Alerts**: Sends alerts for flame, gas, and motion detections.
- **Web Interface**: Displays sensor data and video streams.
## Hardware Requirements
- Raspberry Pi (any model with GPIO support)
- DHT11 Temperature and Humidity Sensor
- Flame Sensor
- Gas Sensor
- Ultrasonic Distance Sensor
- Relay Module
- Camera Module (compatible with Raspberry Pi)
- Breadboard and Jumper Wires
## Software Requirements
- Raspberry Pi OS
- Python 3
- Mosquitto MQTT Broker
## Installation
### Step 1: Install packages
```bash
sudo apt update
sudo apt install ffmpeg mosquitto mosquitto-clients
```
### Step 2: Configure Mosquitto
Modify the Mosquitto configuration file to allow connections from any IP address and enable anonymous access.
```bash
sudo nano /etc/mosquitto/mosquitto.conf
```
Add the following lines to the configuration file:
```conf
bind_address 0.0.0.0
allow_anonymous true
```
Save the file and restart the Mosquitto service:
```bash
sudo systemctl restart mosquitto
```
### Step 3: Set Up Virtual Environment and Install Python Packages
Run the provided `setup.sh` script to create a virtual environment and install the required Python packages.
```bash
chmod +x setup.sh
source setup.sh
```
## Configuration
Create a `.env` file in the project directory and configure the following environment variables.
You can use the provided `.env.example` as a template:
```bash
MQTT_HOST=localhost
MQTT_PORT=1883
MYSQL_DATABASE=pi
MYSQL_USER=root
MYSQL_PASSWORD=raspberry
MYSQL_HOST=localhost
MYSQL_PORT=3306
WEB_SERVER_USER=pi
WEB_SERVER_PASSWORD=raspberry
WEB_SERVER_PORT=8000
```
## Usage
Run the application by executing:
```bash
python3 app.py
```
Access the web interface by navigating to `http://:8000` in your browser.