Prerequisites & Equipment:
You are going to need the following:
A Raspberry Pi Model B or greater.
A USB WiFi Adapter (Edimax – Wireless 802.11b/g/n nano USB adapter is used here).
A USB webcam with microphone / USB microphone (Logitech USB Webcam is used here).
An SD Card flashed with the Raspbian OS (Here is a guide if you need)
Access to the Raspberry either via a keyboard and a monitor or remotely.
Make sure you’re up-to-date:
To check for update and to install them enter the following command:
sudo apt-get update
Step 1: Installing the Motion.
Now, We need to install Motion package using the command line, Following Command can be used
sudo apt-get install motion
Fig. 2: Installation Of Motion Package For Raspberry Pi
This will take a few minutes to download and install. Just type “y” to proceed with the installation since some supporting packages will be installed during the installation process.
Note: If you are going to use Raspberry Pi camera module, since current version of motion does not yet support the Raspberry Pi camera module, we need to download and install a special build with support for this camera module by using these commands.
sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
Step 2: Configure the software.
After installation of the package next step is to edit some of the config files so that the motion service will start to run up and be available on the local network.
First thing we have to edit is the motion.conf file. Type the below command
sudo nano /etc/motion/motion.conf
This is quite a large conf file but the points you need to edit are:
Fig. 3: Configuring Motion Software For Raspberry Pi
DAEMON = OFF (change to ON)
Fig. 4: Editing Motion Configuration File
Webcam_localhost = ON (Change to OFF)
Next we need to enable the Daemon (service):
sudo nano /etc/default/motion
Fig. 5: Command To Enable Daemon Service For Raspberry Pi
start_motion_daemon = no (change to yes)
Step 3: Start the webcam server.
Fig. 6: Start The Webcam Server For Raspberry Pi
Ensure your webcam is plugged into the USB port on your Raspberry Pi and start the service:
sudo service motion start
If you want to stop the service, then use the command:
sudo service motion stop
To restart the service, then use the command:
sudo service motion restart
With the service started you can now open a web page on your normal computer and by going to the IP of the Raspberry Pi on port 8081 (in the address bar) you should be able to view your webcam.