Google returns over 300k results for “raspberry pi webcam”, but only 3 if you add “sensr.net”. So here is some guidance to getting your camera on http://www.sensr.net
Get a Pi and a Web Cam
First off, shameless plug for adafrult industries in NYC. Great supplier of all things Pi. Besides the Pi, you will also need a webcam, 4gb sd card, wi-fi dongle, and maybe a pi case. The raspi also has its own direct-connect camera. Compatible wi-fi dongles are available from adafruit. Unless you got an SD card with a Linux distro pre-loaded, you will have to load it with your PC. The following instructions uses Raspbian – http://www.raspbian.org/FrontPage, one of the most popular distros.
*Most* common Webcams will work, Microsoft HD web cams definitely work.
Follow the instructions at http://www.raspberrypi.org/quick-start-guide . My variation: Forget the keyboard and display. Just give it power and an ethernet connection onto a dhcp served net, then look at my /finding-your-raspi-using-nmap/ Alternately, you can just log into your router (which is probably doing your DHCP grants), and look at the DHCP table for raspberry pi foundation. I then use an ssh client to log onto the pi (login: pi password: raspberry)
From here on out we assume you have a shell prompt
Run this first set of commands. It’ll take a while..
sudo apt-get install rpi-update sudo rpi-update sudo apt-get update sudo apt-get upgrade sudo apt-get install motion
Edit /etc/motion/motion.conf using vi or nano
sudo nano /etc/motion/motion.conf
Here are some things you will want to change:
# set resolution width 640 height 480 # how many frames to save per motion event (0 == just one) minimum_frame_time 0 # text to overlay on image text_left MY SENSR.NET CAMERA # make text double size text_double on # name of file jpeg_filename %Y_%m_%d_%H%M%S_%v_my_sensr_net_camera # The mini-http server listens to this port for requests (default: 0 = disabled) webcam_port 8081 # TCP/IP port for the http server to listen on (default: 0 = disabled) control_port 8080 # allow control (port 8080) via non-local hosts control_localhost off # execute this script when motion frame is captures on_picture_save /home/pi/bin/motion_on_picture_save_action.sh %f
Create the motion_on_picture_save_action.sh script which does the dirty work of uploading to the sensr.net
# create bin directory in case you haven't already mkdir ~/bin cd ~/bin # set proper modes on touch motion_on_picture_save_action.sh chmod ug+x motion_on_picture_save_action.sh nano motion_on_picture_save_action.sh
The script should look like this:
#!/bin/bash # upload file to sensr.net replace CAMID and PASSWORD with your sensr.net camera's id curl -T $1 --user CAMID:PASSWORD ftp://f1.sensr.net/ rm $1
Next, plug in your camera (if you haven’t already and restart the motion service:
sudo service motion restart </pre> On your PC, navigate to <strong>http://<<em>your pi's ip address</em>>:8081</strong> . You should be able to see your camera.. Other things you are going to want to do # put user daemon in group motion so it can read the files sudo usermod -g motion daemon # open up motion's data director to daemon sudo chmod g+rwx /tmp/motion
At this point files should be getting uploaded to sensr.net. If not there’s a few things to check. You can run motion directly on the command line with
sudo service motion stop sudo motion
You can also test the upload script by itself:
sudo su daemon
You can also connect to http://<your pi’s ip address>:8080, and tweek configuration parmeters on the fly.