Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!

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,355
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
2 projects • 8 followers
Contact
mehdi asadi
1 project • 3 followers
Contact
mobin rabie
1 project • 3 followers
Contact
Ehsan Aerabi
18 projects • 60 followers
Researcher on IoT and Embedded Systems
Contact
Erfan Saghabashi
2 projects • 22 followers
Contact

Comments

Please log in or sign up to comment.