Raspberry Pi based wireless motion triggered camera
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:
To set the proper timezone run:
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.
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.
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:
Then download uploader.py and uploader.cfg. Configure uploader.cfg with your google account credentials to enable motion to upload recorded videos.
Now reopen /etc/motion/motion.conf and add the following line: on_movie_end python /etc/motion/uploader.py /etc/motion/uploader.cfg %f
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.
To set up the wireless connection we first open the dedicated config file:
The “wlan0 part” should look something like this (but various other setups are possible).
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:
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.
Add the following line at the end
Finaly we reboot to finish setting up.
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.