Raspberry Pi B with Camera Module and Motion

I was struggling to find a step by step process for getting the camera module + motion up and running on the pi with recent instructions due to broken links and missing repositories so I figured I’d write up what worked for me as of

Dec 23, 2015

This is using a raspberry pi B, 2015-11-21-raspbian-jessie-lite, and an ethernet connection to the internet.

I initially set mine up using the camera module and a usb wifi module but those two together seem to draw more current than the board can supply, which caused brown outs and a corrupted sd card.

To the steps:

As with most things, start with

sudo apt-get update

sudo apt-get upgrade


sudo reboot

Install video dependencies (this was the hard part to find lately)

sudo apt-get install -y libjpeg-dev libavformat56 libavformat-dev libavcodec56 libavcodec-dev libavutil54 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev

Install motion and its dependencies

sudo apt-get install motion

Update Oct 29, 2016: The newer versions of motion available for raspberry pi now have mmal support built in so the instructions struck through below should no longer be necessary. 

From your home directory download this prebuild version of the motion application

wget https://www.dropbox.com/s/6ruqgv1h65zufr6/motion-mmal-lowflyerUK-20151114.tar.gz -O motion-mmal-lowflyerUK-20151114.tar.gz

Unpack it

tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz

Copy the unpacked version of motion over the stock one

sudo cp ./motion /usr/bin/motion

Copy the unpacked motion-mmalcam-both.conf to /etc/motion.conf

sudo cp ./motion-mmalcam-both.conf /etc/motion.conf

Run raspi-config and enable the camera, and any other pi options you like

sudo raspi-config

Reboot again

sudo reboot

Test it


If the application seems to be running ok then at this point you should be able to browse to http://:8081 and see a live view of your camera.

If that’s working, and you’d prefer motion to start on boot, edit the file at /etc/default/motion, and change start_motion_daemon=yes

The bulk of this information was harvested from this forum thread, thanks to all the guys on that thread for their explainations. Hopefully this consolidation of info will help some people.

Here’s a link to the current motion github https://github.com/Motion-Project/motion




2 responses to “Raspberry Pi B with Camera Module and Motion”

  1. Brian J Hoskins says :

    I spent a little while yesterday trying to get to the bottom of this, but the problem is that there are so many outdated posts around. This results in a bunch of mis-information that has to be waded through. The Rpi is a victim of its own success in that regard; it’s so popular that everyone and his dog is writing about it. And, with all the different configurations and setups out there, no single post about a subject is guaranteed to be valid for everyone.

    Today I found your post and a tick-mark straight away is that you make it perfectly clear what your setup is before explaining your procedure. That makes it very easy to determine whether the information will be relevant to me or not.

    My setup was very close (though not exact) so I decided to try your procedure, and it worked just fine.

    The only thing I am left unclear about having completed your procedure is whether or not the pre-built motion-mmal software is still required, or if the current version of motion has the Rpi Camera support built in. Still, the method you describe here results in a fully working, basic motion installation which sends video data out onto port 8081.

    My setup is:

    Pi: Raspberry Pi 2 Model B V1.1
    OS: Raspbian Lite 2016-09-23
    NET: USB WIFI dongle

    Thanks for the post!

    • rhasbury says :

      Thanks for that. I know exactly what you mean, every time you find instructions these days the first step is to scour the page for a date because you might be looking at something from years ago.

      I believe the mmal support has been added since I wrote this. A few days ago I switched this same Pi over to OSMC from raspbian, and in the fresh install all I had to do was do sudo apt-get install motion, then copy my old config file in, and it seemed to work. I don’t know if OSMC shares the same repos as raspbian, but I’m sure they can’t be too far apart so the raspbian one is very likely to have the support also.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: