Things used in this project

Schematics

SMART HOME SECURITY SYSTEM
Untitled iddtenjwiv

Code

SMART HOME SECURITY SYSTEMPython
Its a python code that can be run in Python 3 IDLE
#!/usr/bin/env python
# encoding: utf-8

import os
import smtplib
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart

COMMASPACE = ', '

def main():
    sender = 'projectteamgeck@gmail.com'
    gmail_password = '9620955777'
    recipients = ['mtech.kiran@gmail.com']
    
    # Create the enclosing (outer) message
    outer = MIMEMultipart()
    outer['Subject'] = 'mail'
    outer['To'] = COMMASPACE.join(recipients)
    outer['From'] = sender
    outer.preamble = 'You will not see this in a MIME-aware mail reader.\n'

    # List of attachments
    attachments = ['/home/pi/image/image1.jpg']

    # Add the attachments to the message
    for file in attachments:
        try:
            with open(file, 'rb') as fp:
                msg = MIMEBase('application', "octet-stream")
                msg.set_payload(fp.read())
            encoders.encode_base64(msg)
            msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(file))
            outer.attach(msg)
        except:
            print("Unable to open one of the attachments. Error: ", sys.exc_info()[0])
            raise

    composed = outer.as_string()

    # Send the email
    try:
        with smtplib.SMTP('smtp.gmail.com', 587) as s:
            s.ehlo()
            s.starttls()
            s.ehlo()
            s.login(sender, gmail_password)
            s.sendmail(sender, recipients, composed)
            s.close()
        print("Email sent!")
    except:
        print("Unable to send the email. Error: ", sys.exc_info()[0])
        raise

from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime

camera = PiCamera()
pir = MotionSensor(4)
while True:
    pir.wait_for_motion()
    print ("motion detected")
    camera.capture('/home/pi/image/image1.jpg')
    filename = datetime.now().strftime("/home/pi/videos/%Y-%m-%d_%H.%M.%S.h264")
    camera.start_recording(filename)
    pir.wait_for_no_motion()
    camera.stop_recording()
    main()
Buzzer ModulePython
Its a python code that can be run remotely through a VNC Viewer in a Python 3 IDLE to alert the neighbors about the intrusion
from gpiozero import Buzzer
from time import sleep
buzzer = Buzzer(17)
while True:
    buzzer.on()
    sleep(1)
    buzzer.off()
    sleep(1)

Credits

Img 20161214 135201 evxfxpw8c4
Kiran M P

Assistant Professor

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

PIR Motion Sensor with Raspberry Pi
Easy
  • 404
  • 9

Full instructions

Quick project to interface PIR sensor to Raspberry Pi.

Windows 10 IoT Core - Reading Heart Rate Pulses
Easy
  • 632
  • 7

Full instructions

In this short blog post, I will show you how to connect a Heart Rate Pulse Sensor to you Raspberry Pi running Windows 10 IoT Core.

Boost Your Google Home With Prota OS for RPi
Easy
  • 1,119
  • 6

Full instructions

Extend your Google Home features to smart light, smart speakers, smart cam and smart appliances with those DIY tricks based on Raspberry Pi.

AssistantPi
Easy
  • 3,677
  • 32

Full instructions

Bring both Google Assistant and Alexa to your Raspberry Pi.

Internet Streaming Radio with Google AIY
Easy
  • 2,276
  • 20

Protip

Make a voice-activated Internet streaming radio with your Raspberry Pi and Google AIY. Can also be used to play MP3s or other audio files.

A LoRaWAN "The Things Network" Gateway for Windows IoT Core
Easy
  • 1,894
  • 14

Full instructions

Build your own LoRaWAN "The Things Network" packet-forwarding gateway on Windows 10 IoT Core in native .NET code.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback