Code Monkey home page Code Monkey logo

diy-surveillance-with-smartphones's Introduction

DIY-Surveillance-with-Smartphones

DIY hack for a complete CCTV solution using open source software and smartphones.


alt tag

Open Source & Commercial Software Used:

Requirements:

  • Couple of smartphones, 1 of which should be rootable so you can use it as the zoneminder server (mileage will vary depending on the smartphone - I Used Samsung Galaxy S4, Galaxy S2, Blackberry Z30 and HTC Panache, out of which S4 was the zoneminder servers)
  • Mounts for the IP Camera Smartphones (I just used the cheap commercial ones for car dashboard)
  • tech and linux saviness: you'll need to root your phone, possibly troubleshoot linux issues when installing Linux Deploy as well as the start script, open up ports on your router if you want to access the web interface remotely, etc

Why run the surveillance server on a smartphone?

  • To avoid trusting 3rd party hosting services & having full control and flexibility
  • Practically no cost and minimal energy consumption - just have usb cables charging the phones at all times!
  • Because you can!

Disclaimer: Note that a smartphone is not meant to be run as a dedicated server and the CPU will likely be heating up with usage like this! Use at your own risk!

What the start.bash script does:

  • Automatically installs and configures zoneminder on the server phone
  • Sets up mail on the server using your gmail account so emails are sent to you when alarms are detected
  • Sets up cron and at jobs to toggle night vision on every configured ip camera based on the daily sunrise and sunset times
  • Monitors CPU Temperature, Disk Usage & Battery % on the surveillance server, does health check on ip cameras, and sends emails accordingly

Steps:

  1. Assign a static IP on each smartphone.

  2. Choose 1 of the android smartphones as the server: root it (I used Cyanogenmod), install Busy Boy app by meefik and then install Linux Deploy app.

  3. Open Linux Deploy, install Debian container: https://github.com/meefik/linuxdeploy/wiki/Installing-Debian

Set the following properties: - Installation path: /data/media/linux.img - Image Size: close to your devices max storage capacity - Select Component: SSH server alone is enough - Set GUI to off - Set Custom Mounts to on - Add mount points (use status option on main screen to view available mount paths)

Start the Debian container

  1. On your computer, clone this repo and edit config files in the conf directory with your custom settings. Enable passwordless ssh login into the server phone with:

    IP=ANDROID_SERVER_IP
    ssh android@$IP "mkdir -p ~/.ssh" && scp ~/.ssh/id_rsa.pub android@$IP:~/.ssh/authorized_keys
    

    (enter android phone pass - default should be changeme). And then copy over this repo into the phone using scp:

    scp -r [!.]* android@$IP:
    
  2. SSH into the phone (ssh android@$IP), sudo su, and execute start.bash to install zoneminder, dependencies, jobs, and common configurations.

  3. From a web browser on your computer, open zoneminder web interface at http://ANDROID_SERVER_IP/zm

Click Options, 
	Click Images tab
		Check Is the (optional) cambozola java streaming client installed (?) 
		Click Save
	Click Paths
		Change PATH_ZMS from /cgi-bin/nph-zms to /zm/cgi-bin/nph-zms Click Save
		Optional: under Paths change PATH_SWAP to /dev/shm (puts this process in RAM drive) Click Save
	Click Email
		Make sure OPT_EMAIL is checked
		EMAIL_SUBJECT and EMAIL_BODY are self explanatory
		In the EMAIL_ADDRESS field enter the email address you want to get these alarms
		Make sure NEW_MAIL_MODULES is checked
		EMAIL_HOST: put in localhost
		FROM_EMAIL: your email
Restart Zoneminder
  1. Setup all smartphones running Ip Webcam as monitors. See setup guide here and general guide on zoneminder monitors here

Other Notes

  • Setup port forwarding to access web console remotely, Install client Android app to view the feeds
  • To resize /dev/loop0 and increase space for the server container on the phone: Use losetup /dev/loop0 to see what file the loopback device is attached to, then you can increase its size with, for example, dd if=/dev/loop0 bs=1MiB of=/path/to/file conv=notrunc oflag=append count=xxx where xxx is the number of MiB you want to add. After that, losetup -c /dev/loop0 and resize2fs /dev/loop0 should make the new space available for use. Related: http://www.iwillfolo.com/how-to-re-partition-your-android-tablet-or-smartphone-all-options-included-change-size-fs-type-etc/2/
  • Security: Change default "changeme" password of the server! Create a password for the Zoneminder admin user on the web interface. Possible create other users on the system as well as for the zoneminder web interface with lower privileges, Configure apache to use https to encrypt all communication
  • See commits for minor relevant enhancements to the ZoneMinder web interface: https://github.com/tapans/ZoneMinder

Changelog:

  • 15-Feb-2016 initial commit
  • 25-Mar-2016 scripted email configurations
  • 02-Apr-2016 added daily job to toggle night vision settings for all configured ip cameras
  • 09-Apr-2016 added minutely run monitoring job: currently emails when cpu temperature, disk usage, battery %, etc is above set threshold.
  • 05-Jun-2016 add health check for ip cameras on the minutely monitoring job

diy-surveillance-with-smartphones's People

Contributors

tapans avatar

Watchers

Rob Sawyer avatar James Cloos avatar

Forkers

trinhvo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.