Raspberry Pi Webcam Server Project
The Raspberry Pi is a small, cheap mini-computer that runs Linux. It’s great for tinkering with, and there are many projects online to try. In this project, I have used Linux ‘motion’ software to setup the device as a Raspberry Pi Webcam Server.
The Raspberry Pi Webcam Server will need to monitor and detect movement and will initially be set to record .AVI video files to its 16GB SD Card. This folder will be open to the network for easy viewing, transferring & deleting of the recorded video files.
In a future revision, the Raspberry Pi Webcam Server will be modified to save directly to either an attached USB hard drive or another networked PC share folder.
The video footage will also be streamed live to my local network and available through the browser on any device.
To complete this project I used:
- A Raspberry Pi
- A SanDisk Ultra 16 GB Class 10 SD Card
- A Logitech C615 HD webcam
- An externally powered 4 port USB hub
- A Logitech MK320 Wireless keyboard & mouse
Booting the Raspberry Pi Webcam Server
I chose to prepare the SD card using a Windows PC. This involved downloading an SD card image from the Raspberry Pi website for free.
To place the image on to the SD card, I used Win32DiskImager for Windows.
Once completed, I inserted the SD Card into the Raspberry Pi and connected the externally-powered USB hub, Keyboard adapter and LAN cable, then I turned on the Raspberry Pi.
Setting up the Raspberry Pi Webcam Server
The standard Login and password for the system is username: pi and the password: raspberry
After logging into the Raspberry Pi, the first step was to configure the Raspberry Pi using the Raspi-Config tool. I expanded the Root FileSystem, set the correct Time Zone and Locale, Enabled SSH, and set the device to Boot to Desktop option.
Tip: The Raspberry Pi can be reconfigured by running the following command from a terminal window:
I also experimented with overclocking the Raspberry Pi and settled on the medium overclocking choice of 900MHz.
Now that the Raspberry Pi boots to the desktop, the next step was to ensure the Raspberry Pi operating system is up to date, using:
sudo apt-get update
sudo apt-get upgrade
I then downloaded and installed motion and ffmpeg
udo apt-get install motion ffmpeg
and installed samba
sudo apt-get install samba samba-common-bin
I created a folder on the Raspberry Pi SD Card where motion will save the .AVI videos to.
udo mkdir /home/pi/motion
sudo chmod 777 /home/pi/motion
I then edited the Samba configuration file to add the motion folder as a Network Share.
sudo nano /etc/samba/smb.conf
After entering the correct network details near the top of the Samba configuration file:
workgroup = MyNetwork
wins support = YES
I then added the following text to the bottom of the Samba configuration file.
comment=RaspberryPi Motion Share
browseable = yes
writeable = yes
guest ok = yes
A quick check from another PC on the network confirms the folder is now visible.
Configuring the Raspberry Webcam Server
Now the Raspberry Pi is ready for me to setup the Motion configuration file:
sudo nano /etc/motion/motion.conf
I set the following items
Here’s a copy of my completed motion.conf
The full list of Motion Configuration Options are listed here:
Next, I enabled the motion daemon by editing this configuration file:
sudo nano /etc/default/motion
and I changed
Now start the Motion server service:
sudo service motion start
To restart the motion software following changes:
sudo /etc/init.d/motion restart
Rather than using a WiFi adapter, I have chosen to use an existing Netcomm NP-204 Broadband Over Powerline adapter, which will provide power and LAN cable internet connection to the Raspberry Pi.
I had already set my Network Router to provide the Raspberry Pi with a static IP address of 192.168.1.20 for previous projects. The picture below shows that Address Reservation in the Router Configuration webpage.
Now any network connected device, including PCs, Tablets and Smart Phones can now browse to 192.168.1.20:8081 to view the live stream of images from the Webcam.
To remotely configure the motion server, I browse to 192.168.1.20:8081. The image below is a screenshot taken on a Samsung Galaxy running Firefox for Android.
The Raspberry Pi Webcam Server project is now complete.