Home Security and IP Camera

In this project, we plan to have a safe house, and at the same time we can simultaneously watch with the CCTV any place and work,

BeginnerWork in progress3,294
Home Security and IP Camera

Things used in this project

Story

Read more

Schematics

Schematics and circuit diagrams

Code

code

Python
For this code you should also download the necessary libraries
import telepot
import teleport
import RPi.GPIO as GPIO
import time
from subprocess import call
import threading

def handle(msg):   

    content_type, chat_type, chat_id = telepot.glance(msg)
    bot.sendMessage(chat_id, 'Hello')
    bot.sendPhoto(chat_id, open('/home/pi/Desktop/m.jpg', 'rb'))

    print('sent')

def main():  
    global bot
    bot = telepot.Bot('BOT-TOKEN')
    bot.message_loop(handle)

    while True:
        pass

 
def sensor():
	pir_sensor=11
	piezo = 7

	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(piezo,GPIO.OUT)
	GPIO.setup(pir_sensor, GPIO.IN)
	current_state=0
	try:
		while True:
			time.sleep(0.1)
			current_state=GPIO.input(pir_sensor)
			if current_state==1:
				print("gpio pin %s is %s" % (pir_sensor ,current_state))
				GPIO.output(piezo,True)
				time.sleep(1)
				GPIO.output(piezo,False)
				time.sleep(5)
                        call(["fswebcam", "-d","/dev/video0", "-r", "640x480", "--no-banner", "./m.jpg"])
			 


	except KeyboardInterrupt:
		pass
	finally:
		GPIO.cleanup()

s=threading.Thread(name='sensor' ,target=sensor)
m=threading.Thread(name='main' ,target=main)
s.start()
m.start()

Credits

mohamadbagher

mohamadbagher

2 projects • 8 followers
mehdi asadi

mehdi asadi

1 project • 3 followers
mobin rabie

mobin rabie

1 project • 3 followers
Ehsan Aerabi

Ehsan Aerabi

18 projects • 60 followers
Researcher on IoT and Embedded Systems
Erfan Saghabashi

Erfan Saghabashi

1 project • 22 followers

Comments