Well boys and girls!
Here we are again…and this time we will SEE something with our project.:-)
I know that finally your voyeuristic tendencies (I know…I know) will be satisfied! 😉
Now, it’s time to connect ….the webcam! TA-DA!
I chose a very popular webcam by Logitech (…why? simply because it is cheap and it is natively supported by Debian and Raspbian!): the model is the well known C170, and I bought it on Amazon.it for approx. 19 euros.
The connection to Raspberry is very simple: connect it to one USB port of Raspi before the board power on, then after the Raspi boot sequence it should be automatically mapped on /dev/video0 device.
I will use mjpg-streamer to remotely view the webcam stream, so we must to execute some preliminary (but necessary) step.
Firstly we must install SVN client, since mjpg-streamer is not in the Raspbian repository.
#sudo apt-get install subversion
Secondly we must download the mjpg-streamer sources in the Raspberry disk.
#svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
The last argument is the local folder where the sources will be saved.
IMPORTANT NOTE: some day ago the svn repository for mjpg-stream should be changed, so svn command should return an error reporting also the NEW svn repository path. You should relaunch svn command using the new/right svn repository path.
After this we must also install libjpeg8-dev and imagemagick.
#sudo apt-get install libjpeg8-dev
#sudo apt-get install imagemagick
After this, we must compile mjpg-streamer entering the folder /home/pi/mjpg-streamer (the sources location) and launch the old (very old 🙂 ) make command.
Cross the fingers ;-)….. and voilà, les jeux sont faits! 🙂
In order to remotely view (i.e. inside Firefox or IE) we must now activate the webserver provided by mjpg-streamer.
The command line (a little difficult to read but it works very well in my case) is:
# ./home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/input_uvc.so -d /dev/video0 -r 320x240 -f 28" -o "/home/pi/mjpg-streamer/output_http.so -p 8090 -w /home/pi/mjpg-streamer/www" &
Well, only some clarification:
-i defines the input stream string
-d defines the video device (as mentioned, we use /dev/video0)
-r defines the video resolution (320 x 240)
-f defines the frame rate (28 frames/minute)
-o defines the output mode configuration (in this case the http is used)
-p defines the http port (in my case 8090)
-w defines the root for the webserver (where the webpages are placed)
Finally, note that the command should be launched in background (using the “&”).
Note also that some error will appear at command launch because C170 webcam doesn’t support all mjpg-streamer features (i.e. zoom), but NO PANIC. It should work correctly (I hope 😉 ).
This is rear garden of my house using mjpg-streamer…it’s a very strange view (from the ground) for my C170:
What’s Montecchio? Ehmmm…that’s the name of the place where I will install the meteo station when it will be ready! 😉
OK, last recommendation: if you want to start automatically the mjpg-streamer webserver, you have to add the above command line to /etc/rc.local, as usual.
All good today, without pain. Strange, very strange…. 😉
So, the work on meteo station is more or less terminated: the only things to activate for full functionalities are
- the web page containg at the same time the webcam stream asnd the meteo data took from Arduino via I2C
- the internet access of Raspberry using a 3G dongle with the aid of a Dynamic DNS service.
…But I ensure you that the difficult parts are already passed without (so high) difficulties.
So, see you soon geeks…keep always in touch with Garretlabs! 🙂