Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- from picamera import PiCamera
- import telebot
- from telebot import types
- import time
- import os
- bot = telebot.TeleBot("")
- GPIO.setmode(GPIO.BOARD)
- pir = 11
- GPIO.setup(pir, GPIO.IN)
- adminId = ''
- camera = PiCamera()
- camera.resolution = (640, 480)
- time.sleep(2)
- while True:
- if GPIO.input(pir):
- camera.capture('/home/pi/pir/image.jpg')
- pho = open('/home/pi/pir/image.jpg', 'r')
- bot.send_photo(adminId, pho)
- camera.start_recording('/home/pi/pir/video.h264')
- camera.wait_recording(5)
- camera.stop_recording()
- vid = open('/home/pi/pir/video.h264', 'r')
- bot.send_document(adminId, vid)
- os.remove("/home/pi/pir/video.h264")
- os.remove("/home/pi/pir/image.jpg")
- time.sleep(2)
- time.sleep(0.1)
- # RUN
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement