zzlhr / raspi-camera-pir

Captures RaspiVid as images when motion is detected on the Raspi PIR and stores in MongoDB.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raspberry Pi Camera/PIR Monitor

Captures RaspiVid as images when motion is detected on the Raspi PIR and stores in MongoDB. This requires a MongoDB server be installed somewhere accessible on the same network as the Pi.

Building the Chassis

  1. Review the RPi-KittyCam Circuit Building Instructions for the components involved in building the Pi circuit.

  2. Use the SmartiPi case (LEGO compatible SmartiPi Raspberry Pi B+,2, and 3 w/ camera case and GoPro compatible mount – Gray) and assemble with Pi and Camera board module.

  3. Follow instructions found for Lego PIR Housing (instructables member tocsik) to build the PIR housing and mount to SmartiPi case.

  4. Use the GoPro grab bag of mounts to mount the chassis to the wall: GoPro Grab Bag

Installing on Raspi Ubuntu

Follow the steps below to install the backend service to a fresh Raspberry Pi:

  1. Install Ubuntu on Raspberry Pi using the process described in the guide.

  2. Next, install Git as follows:

    sudo apt-get update -y
    sudo apt-get upgrade -y
    sudo apt-get autoremove -y
    sudo apt-get install -y git
  3. Clone this repository (e.g. git clone git@github.com:jasonajack/raspi-camera-pir.git).

  4. Install the raspivid utility:

    ./install-raspivid-ubuntu.sh
  5. Change run-level to not boot the graphical user interface (saves resources):

    sudo systemctl set-default multi-user.target
  6. Install dependencies for the NodeJS service:

    ./install-ubuntu.sh
  7. Configure the WPA Supplicant service for your wlan0 device to enable connecting to a WiFi network on boot:

    NOTE: If you don't use WPA Supplicant, Ubuntu forces you to use it's horrible NetworkManager service which forces you to login first before it connects to WiFi; so we swap out NetworkManager for WPA Supplicant which connects automatically at boot time.

    1. Modify the network interfaces configuration file (sudo vim /etc/network/interfaces) and append the following to the file:

      # Setup wlan0
      #auto wlan0
      allow-hotplug wlan0
      iface wlan0 inet dhcp
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
      iface default inet dhcp
    2. Create the new wpa_supplicant.conf file (sudo vim /etc/wpa_supplicant/wpa_supplicant.conf):

      country=US
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      
      network={
        ssid="WirelessRouterName"
        psk="secretpassword"
        key_mgmt=WPA-PSK
      }

      NOTE: The password is in plain text, which isn't usually good (and for some reason, password hashes didn't work for me), but you can protect the file so only root can read it, which should be good enough.

    3. Protect your password by making the file read-only by root user exclusively: sudo chmod go-rw /etc/wpa_supplicant/wpa_supplicant.conf

    4. Enable the WPA supplicant service:

      sudo systemctl start wpa_supplicant
      sudo systemctl enable wpa_supplicant
    5. Stop and disable the NetworkManager service, because it interferes with the WPA Supplicant service:

      sudo systemctl stop NetworkManager
      sudo systemctl disable NetworkManager
    6. Test by rebooting and then checking ip addr:

      sudo reboot now
      
      ### After reboot...
      ip addr
  8. Install the camera module as a Systemd service:

    ./install-systemd.sh
  9. Alternatively you can run by hand:

    ./run.sh
  10. Verify the service is running:

    journalctl -u raspi-camera-pir -f

Credits

This module was inspired by the RPi-KittyCam module for giving me the idea of using the RPi for motion-triggered video capture.

About

Captures RaspiVid as images when motion is detected on the Raspi PIR and stores in MongoDB.

License:MIT License


Languages

Language:Shell 50.2%Language:JavaScript 49.8%