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.
-
Review the RPi-KittyCam Circuit Building Instructions for the components involved in building the Pi circuit.
-
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.
-
Follow instructions found for Lego PIR Housing (instructables member tocsik) to build the PIR housing and mount to SmartiPi case.
-
Use the GoPro grab bag of mounts to mount the chassis to the wall: GoPro Grab Bag
Follow the steps below to install the backend service to a fresh Raspberry Pi:
-
Install Ubuntu on Raspberry Pi using the process described in the guide.
-
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
-
Clone this repository (e.g.
git clone git@github.com:jasonajack/raspi-camera-pir.git
). -
Install the
raspivid
utility:./install-raspivid-ubuntu.sh
-
Change run-level to not boot the graphical user interface (saves resources):
sudo systemctl set-default multi-user.target
-
Install dependencies for the NodeJS service:
./install-ubuntu.sh
-
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.
-
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
-
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. -
Protect your password by making the file read-only by
root
user exclusively:sudo chmod go-rw /etc/wpa_supplicant/wpa_supplicant.conf
-
Enable the WPA supplicant service:
sudo systemctl start wpa_supplicant sudo systemctl enable wpa_supplicant
-
Stop and disable the NetworkManager service, because it interferes with the WPA Supplicant service:
sudo systemctl stop NetworkManager sudo systemctl disable NetworkManager
-
Test by rebooting and then checking
ip addr
:sudo reboot now ### After reboot... ip addr
-
-
Install the camera module as a Systemd service:
./install-systemd.sh
-
Alternatively you can run by hand:
./run.sh
-
Verify the service is running:
journalctl -u raspi-camera-pir -f
This module was inspired by the RPi-KittyCam module for giving me the idea of using the RPi for motion-triggered video capture.