Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lallassu/rpicam

Raspberry PI Surveillance Automation
https://github.com/lallassu/rpicam

ansible camera motion motion-detection raspberry-pi surveillance

Last synced: 15 days ago
JSON representation

Raspberry PI Surveillance Automation

Awesome Lists containing this project

README

        

# Automated Raspberry PI Camera Surveillance Setup
![cam](https://github.com/Lallassu/rpicam/blob/master/camera.jpg)
*The picture above is my setup with an RPI 3 with camera and nightvision added. It's in a (relativly) water proof box
and has a small fan to circulate the air inside the box to lower the temperature about 10 degrees celcius.*

## About
This is a Ansible scripted automated setup of an Raspberry PI with an attached camera.

After running the script the raspberry will have the surveillance software "motion" running
with cronjobs and scripts setup to make it run after reboot. It will record files as avi and save
to the tmpfs mounted directory /home/pi/Dropbox/.

The reason for saving recordings to a tmpfs filesystem is that the memory card will otherwise be
trashed after a while with too many read/writes.

The dropbox_uploader script is used to upload the files to Dropbox since there is currently no
Dropbox client for ARM. Hence, an Dropbox app is required that will receive the files. It will end up
in a path such as "Dropbox/Apps//".

There will also be a cronjob installed that removes recordings after 7 days from the raspberry.

When an alarm is triggered an email will be sent (in this case using gmail through postfix) with an
snapshot from the recorded movie to the specified email address including recorded timestamp and
from which host.

### Alarm Email Example
**Subject:** rpi_cam2: Motion detection

**ALERT:** Motion detection(2017-08-24 07:56:08), CAMERA: rpi_cam2

![Image Preview](https://github.com/lallassu/rpicam/blob/master/example.png)

## Prerequisites
* Raspberry PI (v3 tested) with an camera attached to the camera slot.
* Host with ansible 1.2+ installed.
* Raspian installed on the memory card.
* Download raspian lite image.
https://downloads.raspberrypi.org/raspbian_lite_latest
* Format the memory card with FAT32 filesystem.
* Write the image to the card (see below)
* To make Dropbox upload work, create an application in Dropbox.
* Enable SSH on the raspberry (raspi-config -> interface -> enable ssh)
* Enable Camera on the raspberry (raspi-config -> interface -> enable Camera)
* Copy SSH key to the raspberry (default password is "raspberry" in the raspian image, please do change!) (see below)
* TP-cable to connect raspberry with first time (before wifi is setup through the ansible script)

### Commands
# Write raspian image to disk
$ sudo dd bs=1m if=.img of=/dev/ conv=sync
# Copy ssh key
$ ssh-copy-id pi@
# Enable camera and ssh
$ sudo raspi-config

## Configure
Configure all settings in *configure_me.yml*. This is the main configuration file for settings such as
email, dropbox upload etc.

Hosts are configured one per line in *hosts* file. Only thing to specify here is IP and preferred hostname.

## Usage
ansible-playbook playbook.yml

The script will finish by rebooting the raspberry. The motion software will be running inside a
screen and you can watch the process with 'screen -r motion' logged in as user 'pi'.

You will also be able to live view the camera using the credentials you configured in *configure_me.yml*.

http://:8080/

## NOTE
This has only been tested on Raspberry PI 3. Should be working with at least v2 as well (otherwise adjust RAM for tmpfs).