How to make a Basic Security Camera | Raspberry Pi

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024
  • Making a Basic Raspberry Pi Security Camera! In this video I teach you how to use the Camera Module and PIR sensor to take motion triggered photos with your raspberry pi! Also, there will be no video next week due to travels. I'll see you soon!
    _________________________________________________________________
    Code:
    import RPi.GPIO as GPIO
    import time
    from picamera import PiCamera
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(11, GPIO.IN)
    camera = PiCamera()
    i=0
    while True:
    i+=1
    state = GPIO.input(11)
    if state==0:
    print "We're clear"
    time.sleep(0.1)
    elif state==1:
    print "STOP RIGHT THERE!"
    camera.capture('/home/pi/PIR/pics/image{0:04d}.jpg'.format(i))
    ______________________________________________________________
    Music:
    Instrumental produced by Chuki: / chukimusic

Комментарии • 58

  • @willyz4391
    @willyz4391 7 лет назад

    I'm trying to do this sec. camera with motion sensor, I am using a pi3 so I'm using the GPIOs connection instead of the breadboard, the software is working except that the camera is not taking pics. can you help me out?

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Hey, double to check to make sure you have the camera module enabled.
      Here is a more detailed description about using the camera: www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/

    • @willyz4391
      @willyz4391 7 лет назад

      Hey Ethan, thanks for replying, I had to change the code to (GPIO.BCM) and (17, GPIO.IN). I see you have the recording option on the link, but how to I add the recording code to the pictures code? can you help me

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Hey! Instead of the camera capture line, use the following
      camera.start_preview()
      camera.start_recording('/home/pi/video.h264')
      sleep(10)
      camera.stop_recording()
      camera.stop_preview()
      *Note: Make sure you change the path from '/home/pi/video.h264' to whatever you want it to be.
      Let me know if you need more help!

    • @willyz4391
      @willyz4391 7 лет назад

      I am using the PIR motion sensor so I wanted to include the code you have in the link, but I am not good at python. What do I need to change or replace?

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад +1

      NOT TESTED: but try this
      import RPi.GPIO as GPIO
      import time
      from picamera import PiCamera
      GPIO.setwarnings(False)
      GPIO.setmode(GPIO.BOARD)
      GPIO.setup(11, GPIO.IN)
      camera = PiCamera()
      i=0
      while True:
      i+=1
      state = GPIO.input(11)
      if state==0:
      print "We're clear"
      time.sleep(0.1)
      elif state==1:
      print "STOP RIGHT THERE!"
      camera.start_preview()
      camera.start_recording('/home/pi/PIR/pics/video.h264')
      sleep(10)
      camera.stop_recording()
      camera.stop_preview()

  • @saltypengiun9007
    @saltypengiun9007 6 лет назад +2

    Thank you so much for this guide. It has helped me on my hidden camera school project and was much more helpful than other guides I used.

  • @matthewfinch8795
    @matthewfinch8795 7 лет назад +5

    Thanks, your video gets right to the point. Great Job

  • @MrBobWareham
    @MrBobWareham 4 года назад +1

    Nice banging music just loved listening to that all through the video !! and why didn't you use Rapsberry pi motion eye??

  • @nikorizky6952
    @nikorizky6952 7 лет назад +1

    Thank you !
    Very helpful and explained in great detail, I hope you will continue to make this science with things cool and new. once again thank you very much, you really helped me when I was stuck and trouble

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Thanks for the feedback! :))

    • @lombaardcj
      @lombaardcj 6 лет назад

      What happened to your channel on all things Rpi?

  • @ReflectingMe2024
    @ReflectingMe2024 6 лет назад +1

    Great video, especially for me as a newcomer to the RPi. Is there a way one could get the pi to send an image when detected either via sms or upload to Dropbox etc? This would be a great way to alert me to who called at my house when I’m not home.

    • @megaraitei
      @megaraitei 5 лет назад

      Hey did you get the answer to this?
      I'm trying to get the camera to click 2 pics per second and when it gets all clear it should upload all those images to FTP or cloud or email.
      .something on those lines.
      I am not a programming guy, so I find this difficult.

  • @kristinanikolic5719
    @kristinanikolic5719 7 лет назад

    Great job, thank you! I'm trying to take 5 pictures when motion is detected while camera is streaming, but when pictures are taken, camera needs to continue streaming. Can you please help me with that?

  • @jirikolda3709
    @jirikolda3709 6 лет назад +1

    amazing video man really usefull in comibinatin with some other scripts

  • @jackjarvis424
    @jackjarvis424 7 лет назад +1

    Great vid. Cheers! :)

  • @user-qh1bw7vc3n
    @user-qh1bw7vc3n 7 лет назад +1

    Great job

  • @cmatfew
    @cmatfew 7 лет назад

    I'm looking to do the same thing as you but save a 10s or so video instead of taking pictures, would you know how to accomplish this? Nice video though!

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад +1

      Instead of camera.capture() use: raspivid -o video.h264 -t 10000
      For more Information: www.raspberrypi.org/documentation/usage/camera/raspicam/raspivid.md

  • @ahmedabdalkadem5827
    @ahmedabdalkadem5827 6 лет назад

    How to help me get the code to run the motion sensor and code capture image when the movement I need him and thank you

  • @jafodan1
    @jafodan1 6 лет назад +1

    Camera is not working with this script. Any ideas? It does scroll saying "we're clear" but does not stop when I get in front of the camera and make movements.

    • @jafodan1
      @jafodan1 6 лет назад +1

      The camera does take photos tho, just not video from what I can tell

    • @ethanspitips5903
      @ethanspitips5903  3 года назад

      @@jafodan1 The program just takes pictures. But you can take the pictures and make a video with them!

  • @user-qh1bw7vc3n
    @user-qh1bw7vc3n 7 лет назад +1

    Its working

  • @CRIMIN4LxSK3PT3X
    @CRIMIN4LxSK3PT3X 7 лет назад

    but what coding software are you using? just the command prompt or python?

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Hey! I'm using python language and I'm using the text editor PICO to write my code ( PICO can be accessed through the terminal).

  • @shannaharriola3019
    @shannaharriola3019 6 лет назад

    Can you help me? Kindly state all the things to do to achieve this project, from beggining to end. What languages are you using? And the codes also. Pleaase. Coz its my school s final project. I badly need help

    • @shannaharriola3019
      @shannaharriola3019 6 лет назад

      How to connect it in the Pc to view the pictures taken . And what Os are you using. Pls state all of it

  • @jeetshah6554
    @jeetshah6554 7 лет назад

    Hello.I am working on a project where I have connected pir motion sensor to arduino uno and connected my webcam to raspberry pi.What I want to do is when motion is detected my webcam should be triggered so that it can capture photo and then send it through email.I am little bit aware that this can be achieved using serial communication but still I need help.

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Sounds like an awesome project!
      Here are some links to help you get started:
      create.arduino.cc/projecthub/eani/diy-how-to-use-the-arduino-uno-to-send-an-email-sms-an-28ac4d
      playground.arduino.cc/Code/PIRsense
      Let me know if you need more assistance!

  • @piyushanand3912
    @piyushanand3912 6 лет назад

    I used this code with some modifications for an ultrasonic sensor and save the pics as stated in this code... But it says name ( 'i' is not defined ) in the picture saving line of the code

    • @ethanspitips5903
      @ethanspitips5903  3 года назад +1

      Hmm. Make sure you're spelling the name of the program right if you're running it from the command line. Also, try locating the program in the file explorer (try looking for an image icon for the program). If these things still don't work please send me pictures of the error you get.

  • @pradeepikatarun1289
    @pradeepikatarun1289 6 лет назад

    hi the code is working for me ...but it says only we re clear it is not capturing any image what
    should i do....the motion is detected by the camera or the motion sensor plz help me with
    this?

    • @ethanspitips5903
      @ethanspitips5903  3 года назад

      Sorry you're having issues, it seems like there may be a problem with the GPIO communication with the sensor - so I would double check that.

  • @matthewfinch8795
    @matthewfinch8795 7 лет назад

    what do you save the pics directory as??

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      I saved it as 'pics'.
      The path to it would be '/home/pi/PIR/pics/'

  • @matthewfinch8795
    @matthewfinch8795 7 лет назад

    I am running the program a python program and it says that 'i' is not defined

    • @ethanspitips5903
      @ethanspitips5903  7 лет назад

      Hmm. Make sure you're spelling the name of the program right if you're running it from the command line. Also, try locating the program in the file explorer (try looking for an image icon for the program). If these things still don't work please send me pictures of the error you get.

  • @andreivataselu9166
    @andreivataselu9166 6 лет назад +1

    NAV recorded his Yosemite verse on the same microphone as you

  • @غذاءالعقل-ف1د
    @غذاءالعقل-ف1د 7 лет назад

    جميل

  • @dhanalakshmispillai9969
    @dhanalakshmispillai9969 4 года назад

    Please help me 1)Would you please help me to write this code based on when an motion is detected with PIR sensor through raspberry Pi 3 trigger the pi camera to capture the images to load it into a web browser.(based on IOT technique ) 2) 1)Would you please help me to write this code based on when an motion is detected with PIR sensor through raspberry Pi 3 trigger the pi camera to capture the images and send an alert email.(based on IOT technique) Please please help me to write the python code in any of these sections.

  • @paulbailey6251
    @paulbailey6251 6 лет назад +1

    Turn off the music and speak up! Otherwise a very useful contribution - thanks

  • @tocatchasnark1471
    @tocatchasnark1471 6 лет назад

    Doesn’t work,
    No help at all .
    Not explained very well

    • @ethanspitips5903
      @ethanspitips5903  3 года назад

      Sorry I couldn't help, please message me if you want help 1 on 1!