Posts: 6
Joined: Sat Nov 05, 2016 11:39 am

Pi Camera and Motion

Mon Nov 21, 2016 7:38 pm

There are lots of google entries on this and most of them old. I have tried to get motion to work with my pi camera but to no avail. I have followed the instructions here " ... etect-cam/"
and here " ... me-1314466" and here " ... nce-camera"
All are old and fail at some point.
The forum has a large post on the whole topic of problems with motion and pi camera.
Can anyone point me to a site or article that is recent and works?
I'm using Pi Camera and Pi 3B. I know the hardware works.
Last edited by auditdata on Wed Nov 23, 2016 4:39 pm, edited 2 times in total.

Posts: 1
Joined: Tue Nov 22, 2016 3:53 pm

Re: Pi Camera and Motion

Tue Nov 22, 2016 4:05 pm

I installed Motioneyeos on the same HW and it's working great OTB. ... stallation
Only problem is during the night as my camera is in a window facing street with lights - they are sufficient for a good picture with the "-ex night" mode setting with raspistill, but I can't set it up in motioneye :(

Posts: 19
Joined: Thu Feb 05, 2015 8:27 pm

Re: Pi Camera and Motion

Tue Nov 22, 2016 8:41 pm

Where those projects letting you down - how far do you get before you hit problems?
As you point out, most of those sites are comparatively old and the initial setup doesn't really relate to a Pi3B.

I started as you with a lot of frustrations, trying to get some sort of security camera system going. (And TBH, i still get frustrated now when my requirements exceed my very limited experience).
I now have 2 systems working pretty well using motion, but it takes time and there's always something to make work {better}. So any setup is not going to be perfect from the start.
But still they are a vehicle for my learning and continual improvement.

I started using the adafruit tutorial. But also used a lot of googling trying to make "broken" stuff work. ... a/overview
1 don't recall it being foolproof, but it's not far off.

If i may offer one tip, i'd suggest to break down each "big" project into smaller step, and break down those further into even smaller ones.
Before uploading pictures automatically from the picamera to dropbox, just get used to taking pictures. Or editing motion.conf. Or uploading files manually to dropbox. Or whatever....
When you've a better understanding of how each bit works, then when the bigger projects don't work you may have a better understanding of why.

Good luck....


Posts: 6
Joined: Sat Nov 05, 2016 11:39 am

Re: Pi Camera and Motion

Wed Nov 23, 2016 11:08 am

Hi Mal,
Thanks for response.
I have started again. I know the hardware works as if I install using MotioneyeOS it is fine but I want to use the pi for other things so want motion installed with the normal OS
First problem today was after install "motion".
The next step is to install "libjpeg62"
this gets the response
"Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libjpeg62-turbo' instead of 'libjpeg62'
libjpeg62-turbo is already the newest version.
libjpeg62-turbo set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 128 not upgraded.
pi@pithree3:~ $ "

no idea what to do next?

User avatar
Posts: 10828
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Pi Camera and Motion

Wed Nov 23, 2016 11:16 am

How To ask Questions :-
WARNING - some parts of this post may be erroneous YMMV


Posts: 6
Joined: Sat Nov 05, 2016 11:39 am

Re: Pi Camera and Motion

Wed Nov 23, 2016 12:25 pm

OMG It works.
Simple in the end..... but see Pitfalls at the bottom.
Thanks Mal for putting me on the right track
Don't use Motion-MMAL as in many articles and posts. It is much simpler.....
So for the poor others trying this, here is what I did and the pitfalls.
first install the hardware Pi Camera
enable it in the config Raspberry Pi Configuration in the GUI

The first thing is motion can be used in its unmodified form. The trick to this is to get the PI camera to behave as a USB type webcam using the special add on module

first install motion in the straight forward way

Code: Select all

sudo apt-get install motion
then the good news is that bcm2835-v4l2 is already on your system if you have the latest OS

To start it type

Code: Select all

sudo modprobe bcm2835-v4l2
To check it is working type

Code: Select all

ls -l /dev/video*
you should see something like this
crw-rw----+ 1 root video 81, 0 Nov 23 11:26 /dev/video0
next get the bcm2835-v4l2 to load at start up using

Code: Select all

sudo nano /etc/modules
and add at the end
then close the file
reboot and check it is loaded by

Code: Select all

ls -l /dev/video*
OK now time to edit the motion.conf file

Code: Select all

sudo nano /etc/motion/motion.conf
The changes you need to make are
daemon on
width 640
height 480
framerate 100
stream_localhost off

Close the file
next you need to fix an issue with motion or it only runs for a few seconds

Code: Select all

sudo mkdir /var/lib/motion
sudo chown motion:motion /var/lib/motion
reboot PI

OK now time to start motion

Code: Select all

sudo service motion start
Then go to a browser on your network and type

The is the IP of my Pi replace it with yours

and hey presto you should see the video from your pi camera.

I messed up initially as some of the articles incorectly us an underbar “_” instead of a dash “-“ in the name of the bcm2835-v4l2

Also in some articles the lowercase l (12th letter in the alphabet) in v4l2 looks like a 1. It is a lowercase l
This article has the mistakes but if you follow above you should be OK ... opbox-sync
I found the mods to motion.conf here ... me-1314466

Thanks also to Mal a star.

Posts: 1
Joined: Mon Apr 23, 2018 5:14 am

Re: Pi Camera and Motion

Tue May 15, 2018 11:05 pm

hi all,

Would just like to 'bump' this thread, it still works with these instructions :D
I have wasted a 'lot' of time googling everywhere else, I should of come straight here first :oops:
I have used this on a Raspberry Pi 0W and it works great, the refresh rate is a bit slow but I assume that is down to the available processor power.

Posts: 1
Joined: Sun Oct 01, 2017 6:44 am

Re: Pi Camera and Motion

Sun May 20, 2018 10:21 pm

I found also at the end I had to type

Code: Select all

sudo motion
to get it to start.


Posts: 32
Joined: Mon Apr 24, 2017 2:48 am
Location: Melbourne, Australia

Re: Pi Camera and Motion

Wed Jan 30, 2019 12:01 pm

I am having similar problems with the motion software and the pi camera

I am sure this worked a while ago but now I always get:

Active: active (exited)

as soon as I run

sudo service motion start

and no output results?

I reinstalled motion etc and rebooted many times

Do I have to configure the router to get the video - I have forgotten what I did before?

when I type myaddress:8081 it gives

unable to connect

Posts: 8
Joined: Wed Nov 27, 2019 7:37 am

Re: Pi Camera and Motion

Wed Nov 27, 2019 7:53 am

I know this is an old thread, but it's a top search in google and I'd like to offer a few tips to save you hours of troubleshooting.

The best guide that (almost) worked for my 3B+ is this: ... detection/

Its configs (from github) worked, and just needs some minor tweaking for quality, as daemon, etc - and use msmtp instead of ssmtp (details below).. Easy as.


If it's supposed to work but ssmtp / mpack just won't give any errors, and emails aren't received.. Or if you try to send an email, say via "mail" like

mail -s "Testing"
Hey there.. testing.
don't forget last dot.

And you get an error:

mail: cannot send message: Process exited with a non-zero status

If you're on Buster (

Code: Select all

$ cat /etc/os-release
), then ssmtp is no longer maintained and doesn't work anymore.

Instead, uninstall it (

Code: Select all

sudo apt-get --purge remove ssmtp
) and replace it with msmtp

Code: Select all

sudo apt-get install msmtp

Note: you have to manually create /etc/msmptrc and populate it (details & credit in below link) ... 7#p1517480

Code: Select all

$ sudo touch /etc/msmtprc

Code: Select all

$ service msmtpd start
Now it should work fine!

Code: Select all

pi@rb:~ $ echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t
and via mpack

Code: Select all

pi@rb:~ $ mpack -s "Testing 4 from T500" /home/pi/logs/motion/01-20191127185803-01.jpg
Both work! =D


Return to “Camera board”