The setup

To start the project I wrote a fresh image of Raspbian wheezy onto a 4GB SD card with win32diskimager. Raspberry was connected to my home router and accessed trought LAN with putty. I also used Logitech C270 webcam and Edimax EW-7811Un wireless adapter.

I resized the partition size with raspi-config, using expand_rootfs command:

sudo raspi-config

To set the proper timezone run:

sudo dpkg-reconfigure tzdata


References: [1] [2]

First we update the repository list, upgrade the system and install motion, the motion detection software. This will take a while, optionaly you can skip apt-get upgrade.

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install motion

We enable the motion daemon in /etc/default/motion by setting start_motion_daemon=yes and restart the system to see if it boots up properly.

sudo vi /etc/default/motion
sudo reboot

At this point you might want to test out if motion actually works. Make some motion in front of the camera and check if any images and videos were stored into /tmp/motion. If yes continue! :)

First install python package manager pip and python module gdata:

sudo apt-get install python-pip
sudo pip install gdata

Then download and uploader.cfg. Configure uploader.cfg with your google account credentials to enable motion to upload recorded videos.

sudo wget -O /etc/motion/
sudo wget -O /etc/motion/uploader.cfg
sudo chmod +x /etc/motion/
sudo vi /etc/motion/uploader.cfg

Now reopen /etc/motion/motion.conf and add the following line: on_movie_end python /etc/motion/ /etc/motion/uploader.cfg %f

sudo vi /etc/motion/motion.conf
sudo reboot

We create a folder named motion on our google drive, this is where the captured videos will be uploaded to. Now we plugin the webcam, restart the system and test it by, well, moving. Final result should be recieving an email to our gmail account with a link to the captured video. If something is not working it is worth checking /tmp/motion folder - if there is no files in it motion is not working properly. If files appear in /tmp/motion, but don’t upload to your google drive account the problem is in the uploader area.


References: [3] [4] [5]

To set up the wireless connection we first open the dedicated config file:

sudo vi /etc/network/interfaces

The “wlan0 part” should look something like this (but various other setups are possible).

auto wlan0
iface wlan0 inet dhcp
wpa-ssid YOUR_SSID
wpa-psk your_password

In case you have Edimax EW-7811Un wireless adapter you can assure it never enters power saving mode by setting options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 in /etc/modprobe.d/8192cu.conf:

sudo vi /etc/modprobe.d/8192cu.conf

Further, to ensure reestablishing of wlan connection in case it is dropped we download a script that reconnects in case of dropped connection and add it to cron.

sudo wget -O /usr/local/bin/WiFi_Check
sudo chmod 0755 /usr/local/bin/WiFi_Check
crontab -e

Add the following line at the end

*/5 * * * * sudo /usr/local/bin/WiFi_Check

Finaly we reboot to finish setting up.

sudo reboot

Now we unplug the wired connecition and set up the camera and Pi in the desired position and see if everything works. You can tweak the /etc/motion/motion.conf settings for higher resolution etc.