Parisasamane jafaryEhsan AerabiErfan Saghabashi
Published

RaspBerryDoorBell

This project is used in many places like home, office, company and etc. and if you start it, you will quickly get to the goal!

EasyShowcase (no instructions)24 hours852
RaspBerryDoorBell

Things used in this project

Story

Read more

Schematics

RaspBerryDoorBell circuit

in fact:

Code

start.py

Python
First
import RPi.GPIO as GPIO
import time
import os
import telepot
from time import sleep 
from picamera import PiCamera 
GPIO.setmode(GPIO.BCM)

def handle(msg):
    chat_id = msg['chat']['id']
    command = msg['text']
    print(msg['chat']['username'])
    print('Got command: %s' % command)
    
    if command == '/start':
#            bot.sendMessage(chat_id, 'Listening')
	    os.system("python /home/pi/button.py")     

bot = telepot.Bot('509596748:AAEPt5VvC2w_9izdV2giyOddl7X03XmwP-0') 
bot.message_loop(handle) 
print('The code is running') 

while 1:
    time.sleep(1)

button.py

Python
Second
import RPi.GPIO as GPIO
import time
import telepot
import os
from time import sleep 
from picamera import PiCamera 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.OUT)

try:
 while True:
    input_state = GPIO.input(18)
    if input_state == False:
	 GPIO.output(22, True)
	 time.sleep(1.5)
	 GPIO.output(22, False)
     	 os.system("python /home/pi/photo.py")
except:
	 GPIO.cleanup()

photo.py

Python
third
import telepot
import time
from time import sleep 
from picamera import PiCamera 
import RPi.GPIO as GPIO


def handle(msg):
    chat_id = msg['chat']['id']
    command = msg['text']
    print(msg['chat']['username'])
    print('Got command: %s' % command)
         
    if command == '/photo':
                camera = PiCamera()
	        camera.capture('bot.jpg')
                bot.sendPhoto(chat_id,open('/home/pi/bot.jpg','rb'))
                camera.close()
		
bot = telepot.Bot('509596748:AAEPt5VvC2w_9izdV2giyOddl7X03XmwP-0') 
bot.message_loop(handle) 
while 1:
	time.sleep(1)

Credits

Parisa

Parisa

1 project • 14 followers
Haedware engineer
samane jafary

samane jafary

1 project • 4 followers
iT engineering student
Ehsan Aerabi

Ehsan Aerabi

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

Erfan Saghabashi

1 project • 18 followers

Comments