PIR based security video

Discussion in 'The Projects Forum' started by tindel, Apr 17, 2016.

  1. tindel

    Thread Starter Active Member

    Sep 16, 2012
    568
    193

    20160419_195020_2.jpg
    20160419_195239_2.jpg

    Well, I finally finished a project! So many projects start out - but never finish in my home... either due to complexity or I lose interest - or both. This time I got thru an entire project though and want to share with the world.

    This project is released freely under the General Public Licensing Agreement found here: http://www.gnu.org/licenses/gpl-3.0.en.html

    This code uses a Odroid C1+, wiringPi API, guvcview, a USB based webcam, and a PIR sensor to detect occupancy and to record a video locally and transfer it to a remote server somewhere. Optionally, a LED (or other 3.3V device) can be hooked up to a GPIO output to give visual indication that the PIR sensor has tripped. The code should be easily adaptable to the RaspberryPi - although I have not tried it personally.

    The device uses the typical PIR sensor available from amazon for hobbyist electronics with three pins PWR, GND, and Trip Status. It's important to note that PWR is typically 5V, and Trip Status is usually 3.3V logic.

    I used an old USB enabled webcam from Logitech that I had laying around from a previous laptop I no longer use.

    Here's what you need to do to get the program running
    1. Install guvcview here: http://guvcview.sourceforge.net/downloads.html
      Code (Text):
      1. sudo add-apt-repository ppa:pj-assis/ppa
      2. sudo apt-get update
      3. sudo apt-get install guvcview
    2. Install wiringPi
      Code (Text):
      1. git clone https://github.com/hardkernel/wiringPi
      2. cd wiringPi
      3. ./build
    3. Download attached source code and place in it's own directory - possibly ~/Code/OccSensorTrigVid
    4. Connect sensor and LED to Odroid GPIO header as follows:
      • PIR PWR to Odroid pin 2
      • PIR Status to Odroid pin 7
      • PIR GND to Odroid pin 9
      • LED-Anode to Odroid pin 18
      • LED-Cathode (thru a resistor) to Ordoid pin 20
    5. Mount a drive to /mnt/guvcview. I can't be much help here because it's extreamly device dependant - however take a look at this link: http://ubuntuhandbook.org/index.php/2014/08/map-network-drive-onto-ubuntu-14-04/
    6. Make the following directory ~/Video/guvcview
    7. Compile and run source code
      Code (Text):
      1. sudo gcc -o OccSensorTrigVid OccSensorTrigVid.c VideoRecord.c -lwiringPi -lwiringPiDev -lpthread
      2. sudo ./OccSensorTrigVid
      Note : pressing 'q <return>' will cleanly exit out of the program.
    Video Description:


    Captured Video:


    Potential future development (I.E. Let me know what you'd like to see and I'll try to accommodate you):
    • Write a program that occasionally removes files older than ~2 weeks old from the server location.
    • Verify operation on a RaspberryPi
    • I have noticed that occasionally on startup the mounted drive does not mount properly and the files are saved to a local /mnt drive
    • Move occupancy specific code to the main program and make the video capture code more universal.
    • Incorporate a IR capable video camera
    • Add ambient light detector to auto adjust exposure. Or get the camera auto adjusting the exposure.
    • Build a housing to hold everything.

    See attached source code
     
    Last edited: Apr 20, 2016
    Sinus23 and Marcus2012 like this.
  2. ScottWang

    Moderator

    Aug 23, 2012
    4,850
    767
    Now, waiting for mods team to discussing.
     
  3. Wendy

    Moderator

    Mar 24, 2008
    20,764
    2,534
    I think it is ready to go, though I would leave this thread here and copy the first post in the Completed Projects area.
     
  4. tindel

    Thread Starter Active Member

    Sep 16, 2012
    568
    193
    I made the updates to the images I wanted to after discovering that the PIR sensor wasn't actually tripping through the window. If it's still acceptable I'll copy it and take it over to the completed project forums, as requested.
     
  5. ScottWang

    Moderator

    Aug 23, 2012
    4,850
    767
    I think you could copy it to the Completed Projects Forum now.

    In the future, if the members interested in this, they will ask you, if you still here then you can answer them.
     
Loading...