├── LICENSE ├── README.md ├── add_data.php ├── connect.php ├── fire.py ├── gas.py ├── index.php └── main.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Sheikh Nawab Arzoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **Smart Alert System** 2 |     3 | 4 | ------------ 5 | 6 | It's a alert system which will provide real-time alert on fire or LPG gas Leak in your house and it will monitor the house temperature and Methane ppm concentration in air via a Web portal. If the sensor records more than 60 degree temperature or 1000 ppm *(you can modify on script)* of methane concentration then it would send directly sms alert to the registered mobile number. 7 | 8 | ##### Requirements: 9 | 1. Raspberry Pi 10 | 2. ADC121C_MQ4 (Measure Methane Concentration in PPM) 11 | 3. DHT-11 (Measure Temperature) 12 | 4. GSM module (To send SMS) 13 | 14 | ##### Prerequisite: 15 | First raspbian os needs to be installed on SD card then run the following codes 16 | ```` 17 | sudo apt-get update 18 | sudo apt-get upgrade 19 | sudo apt-get install python-pip 20 | sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev 21 | sudo python -m pip install --upgrade pip setuptools wheel 22 | sudo pip install cffi 23 | sudo pip install smbus-cffi 24 | sudo pip install Adafruit_DHT 25 | git clone https://github.com/sakearzoo/Smart_Alert_System.git && cd Smart_Alert_System 26 | chmod +x fire.py 27 | chmod +x gas.py 28 | chmod +x main.py 29 | ```` 30 | 31 | After then you need to modify the `connect.php` file with proper credentials, Add your phone number to `fire.py` and `gas.py` and finally update the `main.py` with proper website address. 32 | 33 | ##### Now all is Set !! 34 | 35 | To run the script you need to enter th following code: 36 | ```` 37 | Sudo ./main.py 38 | or 39 | sudo python main.py 40 | ```` 41 | 42 | --------- -------------------------------------------------------------------------------- /add_data.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /connect.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fire.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import serial 3 | import RPi.GPIO as GPIO 4 | import os, time 5 | 6 | GPIO.setmode(GPIO.BOARD) 7 | 8 | # Enable Serial Communication 9 | port = serial.Serial("/dev/ttyUSB3", baudrate=9600, timeout=1) 10 | 11 | # Transmitting AT Commands to the Modem 12 | # '\r\n' indicates the Enter key 13 | 14 | port.write('AT'+'\r\n') 15 | rcv = port.read(10) 16 | print rcv 17 | time.sleep(1) 18 | 19 | port.write('ATE0'+'\r\n') # Disable the Echo 20 | rcv = port.read(10) 21 | print rcv 22 | time.sleep(1) 23 | 24 | port.write('AT+CMGF=1'+'\r\n') # Select Message format as Text mode 25 | rcv = port.read(10) 26 | print rcv 27 | time.sleep(1) 28 | 29 | port.write('AT+CNMI=2,1,0,0,0'+'\r\n') # New SMS Message Indications 30 | rcv = port.read(10) 31 | print rcv 32 | time.sleep(1) 33 | 34 | # Sending a message to a particular Number 35 | # Eneter your number in place of 1234567890 36 | 37 | port.write('AT+CMGS="1234567890"'+'\r\n') 38 | rcv = port.read(10) 39 | print rcv 40 | time.sleep(1) 41 | 42 | port.write('Emergency Fire Alert Please check sensor log for more info'+'\r\n') # Message 43 | rcv = port.read(10) 44 | print rcv 45 | 46 | port.write("\x1A") # Enable to send SMS 47 | for i in range(10): 48 | rcv = port.read(10) 49 | print rcv 50 | -------------------------------------------------------------------------------- /gas.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import serial 3 | import RPi.GPIO as GPIO 4 | import os, time 5 | 6 | GPIO.setmode(GPIO.BOARD) 7 | 8 | # Enable Serial Communication 9 | port = serial.Serial("/dev/ttyUSB3", baudrate=9600, timeout=1) 10 | 11 | # Transmitting AT Commands to the Modem 12 | # '\r\n' indicates the Enter key 13 | 14 | port.write('AT'+'\r\n') 15 | rcv = port.read(10) 16 | print rcv 17 | time.sleep(1) 18 | 19 | port.write('ATE0'+'\r\n') # Disable the Echo 20 | rcv = port.read(10) 21 | print rcv 22 | time.sleep(1) 23 | 24 | port.write('AT+CMGF=1'+'\r\n') # Select Message format as Text mode 25 | rcv = port.read(10) 26 | print rcv 27 | time.sleep(1) 28 | 29 | port.write('AT+CNMI=2,1,0,0,0'+'\r\n') # New SMS Message Indications 30 | rcv = port.read(10) 31 | print rcv 32 | time.sleep(1) 33 | 34 | # Sending a message to a particular Number 35 | # Eneter your number in place of 1234567890 36 | 37 | port.write('AT+CMGS="1234567890"'+'\r\n') 38 | rcv = port.read(10) 39 | print rcv 40 | time.sleep(1) 41 | 42 | port.write('Emergency Gas leak Alert Please check sensor log for more info'+'\r\n') # Message 43 | rcv = port.read(10) 44 | print rcv 45 | 46 | port.write("\x1A") # Enable to send SMS 47 | for i in range(10): 48 | rcv = port.read(10) 49 | print rcv 50 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |
10 |ID | 41 |Date | 42 |Temperature | 43 |Humidity | 44 |Methane Concentration | 45 | 46 |'.$row["id"].' | '; 72 | echo ''.$row["date"].' | '; 73 | echo ''.$row["temperature"].' | '; 74 | echo ''.$row["humidity"].' | '; 75 | echo ''.$row["ppm"].' | '; 76 | 77 | echo ''; 78 | } 79 | ?> 80 |