Installing Motion On Raspberry Pi

This blog was written in May 2016 so you should not have to suffer the pain of earlier users who had to struggle to get motion running on a raspberry Pi. This blog does assume you are using the raspberry pi camera but its a pretty similar setup for other cameras.

Recipe for success:

Pick ONE of the following cameras: A new 8MP camera was released in April 2016 replacing the 5 Megapixel camera but the 5MP is a little cheaper. Decide on whether you want the normal camera or NOIR camera (which is better for night viewing).

1 Raspberry Pi Camera Module 5 Megapixel
1 Raspberry Pi NoIR Camera Module 5 Megapixel
1 Raspberry Pi Camera Module v2.1 – 8MP, 1080p
1 Raspberry Pi NoIR Camera Module v2.1 – 8MP, 1080p


1 Raspberry Pi 3 Model B 1.2 GHz Quad-Core ARM Cortex-A53 Motherboard – Green

1 SanDisk Ultra Imaging 8 GB microSDHC Memory Card plus SD Adapter up to 48 MB/s, Class 10

1 Raspberry Pi Official Universal Power Supply Unit

1 Raspberry Pi 3 Model B case, Better Raspberry Pi 3 case – High quality PC Protective Case with 2x Heatsinks for Raspberry Pi 3 Model B, Pi 2 Model B & Pi Model B+ (Transparent)

Grab a HDMI cable from Poundland as well if you want to test connected to a TV before trying the remote stream.

(1) Install the OS and network (see my blog on install the OS on a raspberry PI)

(2) Use raspi-config to enable the camera.


(3) execute sudo nano /etc/modules and add the following text at the bottom


and use cntrl-x to save

(4) Install motion with the following commands:

sudo apt-get install motion

Then ammend the motion config file as follows:

edit /etc/motion/motion.conf and ensure the following parameters are set:

(this was the most difficult bit to ensure you can watch the stream from your network)

sudo nano /etc/motion/motion.conf

daemon on
framerate 2 
# vga recommended if using a B or B+
width 640
heigh 480
# 720p for raspberry pi 2 or 3 only
# width 1280
# height 720
ffmpeg_video_codec mpeg4 
webcam_localhost off 
stream_localhost off
webcam_localhost off
control_localhost off
webcontrol_localhost off

cntrl-X to save and the reboot the pi with the following command

sudo reboot

After the PI has rebooted you should be able to see access the stream via


and you should be able to access the control channel on 


and thats it.

WhereThingsAreBorn :)



One thought on “Installing Motion On Raspberry Pi

  1. Hello,

    Any other specific instructions for the 8MP camera?
    Since it can do 1080P@30FPS the width, height, framerate should be different. Anybody experimented with this? I wonder what bandwidth would a high quality HD stream require with this cam.


Leave a Reply

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

You are commenting using your 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