Rasperry Pi 3

This is a draft for me to remember what I did...

Don't forget to edit

sudo nano /etc/default/motion

to this:

# set to 'yes' to enable the motion daemon
start_motion_daemon=yes

If you don't do that, Motion will not start.

Allways remember to change the default raspberry password.

The heart of this project is the Raspberry Pi 3, and a cheap webcamera. You can't use the Pi cam module.

The following software has to bee installed:

  • motion

  • php7

  • libapache2-mod-php7

  • php7-mcrypt

Use the sudo apt-get install command:

sudo apt-get update sudo apt-get install motion php7.0 libapache2-mod-php7.0 php7.0-mcrypt

Before you start to modify the motion.conf file too much, be sure to make a copy of it.

Edit the /etc/motion/motion.conf file:

sudo nano /etc/motion/motion.conf

daemon on
setup off
width 640
heigth 480
framerate 60
quality 75
text_right %d:%m:%Y\n%T-%q
text_double on
target_dir /home/pi/motion
stream_port 8081
stream_quality 100
stream_motion on
stream_localhost off
control_localhost off
stream_maxrate 60

Here are the settings, when opening localhost:8080 in a browser.

You'll soon find out that the imagedir, in my case: target_dir /home/pi/motion is getting filled with images and with .avi's. The way to deal with that, if it's not mission critical to keep the .jpg's, is to add a line to sudo crontab, that will run every 5th minute.

At the command prompt:

sudo crontab -e

# m h dom mon dow command
*/5 * * * * rm /home/pi/motion/*jpg

Edit the /etc/dafault/motion file:

sudo nano /etc/default/motion

start_motion_deamon=yes

When the editing is done, restart the motion service:

sudo service motion restart

Sometimes you'll need to edit the /etc/motion/rc.local-file, and add motion right after fi. Like this:

_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
motion
exit 0

See the result:

localhost:8081 -> The live feed from the camera. (localhost or the IP adress Motion is running from.)

localhost:8080 -> Shows motion version, and how many cameras that are connected and in use. (localhost or the IP adress Motion is running from.)

Motion on github Motion