Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 10 | |||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
| ||||||
The purpose of this project is to provide extra security for your personal home. The sensor detects when the door opens and emits a shrill sound and sends us an email alert. At the same time the application can be controlled through a web page Through the web page we can start or stop the application.
import sys
import RPi.GPIO as GPIO
import time
import smtplib
GPIO.setmode(GPIO.BCM)
buzzer = 23
trig = 3
echo = 4
GPIO.setwarnings(False)
GPIO.setup(2,GPIO.OUT)
GPIO.output(2,0)
GPIO.setup(buzzer,GPIO.OUT)
GPIO.setup(trig,GPIO.OUT)
GPIO.setup(echo,GPIO.IN)
GPIO.output(trig, False)
time.sleep(0.5)
while True:
GPIO.output(trig, True)
time.sleep(0.00001)
GPIO.output(trig, False)
while GPIO.input(echo)==0:
pulse_start = time.time()
while GPIO.input(echo)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance = pulse_duration * 17150
distance = round(distance, 2)
print("Distance:",distance,"cm")
if distance <= 15:
GPIO.output(buzzer,GPIO.HIGH)
server=smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login("proiect.smlab","SMlab12345")
msg="A trecut cineva pe langa sensor"
server.sendmail("[email protected]","[email protected]",msg)
server.quit()
time.sleep(0.5)
else:
GPIO.output(buzzer,GPIO.LOW)
time.sleep(0.5)
GPIO.cleanup()
sys.exit()
<html>
<head>
<?php
if (isset($_POST['start'])) //Start
{
exec('sudo python /var/www/proiectSM.py');
}
if (isset($_POST['stop'])) // Stop
{
exec('sudo python /var/www/led_On.py');
exec('sudo pkill -f /var/www/proiectSM.py');
}
?>
<title>Alarma </title>
</head>
<body background="FX3.png">
<center>
<table witdh="400" border="1" bgcolor="silver">
<td>
<Font color='blue'><b>
<center>
Universitatea Tehnica 'Gh.Asachi' Iasi - Fac. Automatica si Calculatoare<br>
<br>
</Font><b>
<center> <h1> <Font color='navy'>
Alarma<br>
</h1></font>
<center>
<form method="post">
<table
style="width: 50%; text-align: left; margin-left: auto; margin-right: auto;"
border="1" cellpadding="2" cellspacing="2">
<tr>
<td style="text-align: center;"><button name="start"><font face="impact" color="green">Start</button></td></font>
<td style="text-align: center;"><button name="stop"><font face="impact" color="red">Stop </button></td> </font>
</tr></font>
</table>
</form>
<font color="navy">
<br>
© 2021 Fac. Automatica si Calculatoare
</td>
</table>
</body>
</html>











Comments