13 Jan 2016

Motion detection security system using a Linux computer and old Android phone(s)
  • Install and setup IP Webcam on Android phone(s), change settings, start server and turn off the screen to help prevent overheating (removing the back cover also helps) and for conserving power, even if it is plugged in.

  • Install motion software on the Linux computer (sudo apt-get install motion if using Ubuntu) and set it up (edit /etc/motion/motion.conf)

    • ffmpeg_cap_new off # to only capture images
    • netcam_url http://phone-ip-address:8080/video
    • netcam_userpass login:password # if any
  • Install and setup mutt for sending emails from Linux computer

  • Install inotify-tools on the Linux computer (for monitoring the creation of new image files)

  • Create a Bash script for monitoring motion’s temporary directory for new files (You should change my@email.com for your email but the default MONITORDIR directory should be fine)

      #!/bin/sh
      MONITORDIR="/tmp/motion/"
      inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
    
      timestamp() {
        date +"%T"
      }
    
      do
      echo "File ${NEWFILE} is attached.\r\n" | mutt -s "Motion detected @ $(timestamp)" my@email.com -a ${NEWFILE}
      done
    
  • Start motion software on Linux computer

  • Start the Bash script on the Linux computer for monitoring for new image files in /tmp/motion/ and automatically emailing them to you.

You should now be getting 1 email per image captured when motion is detected.

I changed the camera resolution to 1280x720 and the motion config setting “treshold” to 750, to increase sensitivity.