Webtool for managing Motion on Raspberry Pi

Raspberry PI Morion Webtool

A few months ago I setup a small surveillance system at home with motion detection using a Rapsberry Pi, Motion detection software and a webcam, following roughly these instructions for a low cost Raspberry Pi surveillance camera.

For a while I managed the surveillance system via SSH on my smartphone. It worked great but I was getting tired of SSH, so I finally got my act together and developed a small web-tool to do the work for me. It’s a very simple tool and all it does is check the status of the system and allow me to switch it on or off via the browser on my phone.

Here is how you can install my web tool.

(For installing Motion and setting up your Raspberry Pi, please follow the instructions on the link posted above)

  • Install Apache ( sudo apt-get install apache2 )
  • Install PHP5 (sudo apt-get install php5)
  • Install PHP5-gd (sudo apt-get install php5-gd) – this will enable PNG support, used by the function that displays the On/Off buttons depending on the status of Motion.

Download and install the web-tool

  1. At the Raspberry PI console type these commands, pressing “Enter” after each of them.
  2. cd /var/www
  3. sudo mkdir motion
  4. cd motion
  5. sudo wget http://itechlog.com/projects/motion-webtool.tar.gz
  6. sudo tar zxvf motion-webtool.tar.gz
  7. Allow web server user www-data to run sudo commands for motion and pkill (pkill is used to kill processes by their names) – this is probably a little unsecure and lazy, but your RasPi should be only accessible within you network so it’s not a big deal – suggestions are welcome though.

Permissions – How to.

  • sudo visudo (to edit sudoers)
  • and add the following lines:

www-data ALL=(root) NOPASSWD:/usr/bin/motion
www-data ALL=(root) NOPASSWD:/usr/bin/pkill

  • To save press shift+o, Enter to confirm overwrite, shift+x to exit
  • Start Apache: sudo service apache2 start

Then access the tool via your browser: http://<ip>/motion (where <ip> is the ip address of your Raspberry Pi, which should have been setup as a static IP).

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>