Raspberry Pi Security Camera

This is Project #2 for my Raspberry Pi camera module. Thanks to many people’s hard work on building the motion detection library, it becomes fairly easy to transform Pi into a security camera.

Step 1: Install Motion: apt-get install motion will only download version 3.2, I need to manually download and install the latest version 4.0.1:

wget https://github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_jessie_motion_4.0.1-1_armhf.deb
sudo apt-get install gdebi-core
sudo gdebi pi_jessie_motion_4.0.1-1_armhf.deb

Step 2: Copy motion.conf to the current project path, and modify it based on the needs. There is an overwhelming list of parameters for Motion, but it is important to read it through:

sudo cp /etc/motion/motion.conf ./motion.conf
sudo chown pi motion.conf

I made the following changes:

  • daemon on
  • process_id_file /home/pi/Projects/PiCam/motion.pid
  • width 1280
  • height 720
  • framerate 100
  • uncomment mmalcam_name because I am using Raspberry Pi camera
  • auto_brightness on
  • output_pictures off
  • locate_motion_mode preview
  • text_changes on
  • target_dir /home/pi/Projects/PiCam/motion
  • stream_motion on
  • stream_maxrate 100
  • ffmpeg_output_movies on
  • ffmpeg_variable_bitrate 100
  • ffmpeg_video_codec mp4
  • stream_localhost off
  • webcontrol_localhost off
  • on_movie_start python /home/pi/Projects/PiCam/alert.py

Step 3: Run motion and open a browser with IP:8081 and see the stream!

Step 4: Now it is the fun part, how can I get notification when there is motion detected? That’s what alert.py script does. I will send an event to IFTTT, therefore, I will get a push notification on my phone via the IFTTT app. Then I will upload the video file to Dropbox by using DropBox API, so I can replay on my phone.

See alert.py code here on my GitHub.