Skip to content

Simple home surveillance with Raspberry Pi and Raspberry Pi Camera

License

Notifications You must be signed in to change notification settings

wolny/rpi-room-monitor

Repository files navigation

rpi-room-monitor

Simple home surveillance app to be installed on Raspberry Pi with the camera board.

The app scans the local network and checks if any of the configured trusted devices is present in the network. If at least one trusted device (MAC address) is discovered on the local network then any movement in the room is ignored. Otherwise if no trusted devices are present and the motion is detected within the camera range, the app captures the photo of the the room and uploads it to Flickr and/or the FTP server.

Phones, eReaders or other personal WiFi-capable devices should be picked as a "trusted devices", so that the surveillance is activated as soon as one leaves it's home WiFi range.

Motion detection module inspired by this great post.

Installation

On your Raspberry Pi:

  • sudo apt-get install arp-scan; arp-scan needs to be needs to be run as root in order to open a link-layer socket so one might add myuser ALL = (root) NOPASSWD: /usr/bin/arp-scan to the sudoers file
  • sudo pip3 install flickrapi
  • sudo apt-get install python-influxdb
  • install OpenCV
  • get the Flickr API key
  • python3 flickr_auth.py -c config.json in order to authenticate with flickr; needs to be run from the terminal within the X-server, since the Pi's default web browser will be opened
  • run the app: python3 monitor.py -c config.json
  • sudo cp delete_old_frames.sh /etc/cron.daily/delete-old-frames; all the frames on which the motion was detected will be kept in /tmp dir, this script cleans it up (by default removes images older than 4 days); make sure that the script in /etc/cron.daily doesn't have the .sh extension

On a box in your LAN (optional):

  • install FTP server
  • start influxdb + grafana docker containers:
sudo docker run -d -p 8086:8086 -v influxdb:/var/lib/influxdb influxdb
sudo docker run -d -p 3000:3000 grafana/grafana
  • create db to be used for collecting measurements:
curl -i -X POST 'http://localhost:8086/query' --data-urlencode "q=CREATE DATABASE pimonitor"

Configuration

Sample config.json:

{
  "arp_scanner_interval": 10,
  "state_check_interval": 4,
  "network_prefix": "192.168.0",
  "trusted_macs": [
    "test"
  ],
  "resolution": [
    800,
    600
  ],
  "framerate": 16,
  "flickr_enabled": true,
  "flickr_api_key": "FLICKR_API_KEY",
  "flickr_api_secret": "FLICKR_API_SECRET",
  "ftp_enabled": true,
  "ftp_host": "FTP_HOST",
  "ftp_user": "FTP_USER",
  "ftp_passwd": "FTP_PASSWD",
  "ftp_dir": "FTP_DIR",
  "influxdb_host": "INFLUXDB_HOST",
  "influxdb_port": "INFLUXDB_PORT",
  "influxdb_dbname": "INFLUXDB_DBNAME"
}
  • arp_scanner_interval - number of sec. between each ARP protocol scans used to determine MAC addresses present in the LAN
  • state_check_interval - number of sec. between photos (if any) are sent to Flickr/FTP server
  • network_prefix - consider only hosts with network addresses with this prefix (optional)
  • trusted_macs - list of trusted MAC addresses, which if present on the network disables the surveillance
  • the rest config values are self-explanatory

Recommended hardware

About

Simple home surveillance with Raspberry Pi and Raspberry Pi Camera

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published