Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. from picamera import PiCamera
  3. import telebot
  4. from telebot import types
  5. import time
  6. import os
  7.  
  8. bot = telebot.TeleBot("")
  9. GPIO.setmode(GPIO.BOARD)
  10. pir = 11
  11. GPIO.setup(pir, GPIO.IN)
  12. adminId = ''
  13. camera = PiCamera()
  14.  
  15. camera.resolution = (640, 480)
  16.  
  17.  
  18. time.sleep(2)
  19. while True:
  20.    if GPIO.input(pir):
  21.       camera.capture('/home/pi/pir/image.jpg')
  22.       pho = open('/home/pi/pir/image.jpg', 'r')
  23.       bot.send_photo(adminId, pho)
  24.       camera.start_recording('/home/pi/pir/video.h264')
  25.       camera.wait_recording(5)
  26.       camera.stop_recording()
  27.       vid = open('/home/pi/pir/video.h264', 'r')
  28.       bot.send_document(adminId, vid)
  29.       os.remove("/home/pi/pir/video.h264")
  30.       os.remove("/home/pi/pir/image.jpg")
  31.       time.sleep(2)
  32.    time.sleep(0.1)
  33.  
  34.  
  35.  
  36.  
  37. # RUN
  38. bot.polling(none_stop=True)
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement