Raspberry Pi Motion Following Network Camera Project

October 19, 2014, updated January 14, 2015

This is the project page for raspberrypi-motion, a Raspberry Pi based motion tracking network camera. It's a Buildroot (bsquask) based project that incorporates the software and hardware necessary to create a prototype motion tracking pan and tilt network camera. You can jump right to the github page or continue reading.

The center of the motion tracking is a modified version of motion. It's a very naive and simplistic approach, but it's also lightweight and easy to setup and customize. As always, it would not be to hard to take this project and switch to OpenCV and do full face tracking or obstacle avoidance.

Here are some shots of the setup. I'll post more with a video later.

IMAG0945.jpg IMAG0931.jpg

IMAG0925.jpg IMAG0924.jpg


  • Automatic motion detection and adjusting the motion to the camera's center field of view
  • 180 degree pan and tilt motion
  • Network interface for viewing the live stream

Hardware Overview

Raspberry Pi Model B 756-8308 Motherboard (RASPBRRYPCBA512)

RioRand 2 Pcs TowerPro SG90 9G micro servo motor

Raspberry PI 5MP Camera Board Module

ZITRADES Aircraft FPV dedicated nylon Pan/Tilt

The Raspberry Pi and camera mount are mounted to the top of a plastic project box. The Raspberry Pi is attached with a couple of offsets. I also made some plastic spacers to mount the camera to the camera mount with some bolts. The camera boards is actually much smaller than what the camera mount supports so it will not hold it out of the box and due to the configuration of the camera board itself, it can't be mounted to a flat surface nicely.


There's not much of a schematic, but here it is. If you were to improve on this, put some isolation between the servos and the Raspberry Pi, but I have not had any problems yet.


There are two main hardware interfaces: driving the 2 micro servos and handling the camera. It turns out, the camera is well supported as a v4l2 device out of the box with the latest official Raspberry Pi kernel, so the more interesting thing is driving the servos. Driving a standard RC servo is really simple. It's just a simple PWM (Pulse Width Modulation) where the duty cycle controls the position of the servo. The problem is the Raspberry Pi only has a single hardware PWM. Trying to bitbang a PWM in software is out of the question on Linux. It turns out, needing more than one PWM is a common pitfall and many others have already taken to implementing PWM's using DMA to drive many gpio pins. This works really well and I've taken advantage of one of those projects: raspberrypi-pwm.

For building, see the README.

Potential Improvements

  • Add a complete web interface where the camera can be configured and allow the pan and tilt to be manually controlled.
  • Record sound.
  • When in idle (no motion detected for some length of time), listen for sound to find motion.
  • While this does work, the Raspberry Pi is definitely strained on CPU. I've played around with both the motion and Raspberry Pi CPU settings and have definitely found some major improvements, but it's still not where I'd like it before pushing an update.

Related Posts


Comment November 2, 2014 by anonymous
Hi very nice working setup. Good work. Just want to add few notes. 1. I made a compilation from your source and possible it is usefully also to share already compiled files - ping me if you want? 2. I suggest to add wlan packages support. 3. I suggest to pack all os into NOOBS fast and interactive menu for loading images and formatting SDs more info here: https://github.com/raspberrypi/noobs In general - well done!
Comment July 24, 2015 by anonymous
Hi Can you share the compiled files, I struck on building the builroot. I am newbie to Linux. I am interested in this project.
Comment January 3, 2016 by rvilsker
I can share - please tell me where to upload.