Sunday, August 14, 2011

Setting Up a Free Weather Webcam


"Everyone talks about the weather, but no one does anything about it." - Mark Twain

Weather webcam image
The weather effects our lives everyday and weather websites are among the most heavily trafficked on the web. They tell us whether we will need an umbrella today or what to pack for a trip across the country.

Weather webcams are always popular and it is easy and free to set one up yourself. Whether you run Windows, Mac or Linux there are tools and hosting available which only requires you own a webcam to be up and running on the web.

Basically you need three things: a webcam, software which can upload via ftp and a website which will host and publish your images.

Webcams are ridiculously cheap these days and if you don't have an old one in a drawer somewhere, they are available online or at your local department store for 10.00 and up. Generally, you want the best resolution you can afford with back light and white control, if possible.

Webcam software is usually included with your webcam or is widely available online. You will need a program which can upload your images to the web via ftp or sftp.

Free software for Windows is available here:
http://www.lundie.ca/fwink/

For Mac:
http://www.klieme.com/EyeSight.html

And Linux:
I use uvccapture, designed for still webcam images, it handles auto-exposure better than software designed for streaming video. It is available in the Ubuntu repositories or you can grab it here:
https://github.com/csete/uvccapture
See "My Linux Setup" below for instructions. 

Camorama Software
Regardless of the software, the process will be the same: Capture an image, save it to your computer, use ftp (or sftp) to upload it to a remote server, view it online.

For free weathercam hosting and making the images available online, I use weatherunderground. They will broadcast your images, create a video of the last 24 hours and even provide a weather calendar of the last month which offers videos for each day.

Ok. Lets get started.

Plug your webcam into a usb port on your computer. Point the camera out the window. This sounds simple enough, however there are considerations which may complicate your choice of view.

Direction: Pointing your camera either due west or east will result in direct sunlight on your camera and window glass during part of each day. This usually results in overwhelming glare which can obliterate the image. If possible, it is best to point your camera either north or south so it will not be pointed directly into the sun.

Distance: USB looses signal strength with a cable over 15' long. This can cause corruption of your images and an unreliable source. Choose a window which you webcam can reach without using an extension or keep the total distance under 15 feet.

Sky Cam
Subject: Choose a view which gives the info you are looking for. Are you watching for snow so you know if you need to leave work early? If yes, then make sure you can see the ground. Are you watching the sky for approaching threats of bad weather? Point it toward an open area of sky, preferably in the direction which weather usually approaches (avoiding due west/east if possible).

Once you have decided on a view, next you will need to create an account with your host. In the case of this article, that will be weatherunderground.
Go here to setup an account:
http://www.wunderground.com/members/signup.asp

Setup your webcam here:
http://www.wunderground.com/webcams/signup.html

You can choose to upload images via FTP or URL. This means either you will send the pics directly to weatherunderground via FTP, or point them toward your own website where your webcam already exists. We will be using the ftp option.

Streamcam Software
To setup your webcam, you will be asked a few questions:
First, select the FTP option and give some general information about your organization (if any) and location. Select your timezone. Your address is requested, but general area info is fine. Enter the City, State and Zip Code. Your latitude and longitude will be calculated.

If you have a Personal Weather Station (PWS) and would like to upload the data, you can enter the address, IP or url here.

Finally, you can choose to share your camera type and this info will appear on your webcam page.

Click 'Save Changes' and you will be taken to a page where your camera will be listed with a name like mywebcamCAM1. It will show the location you entered and allows you to add another webcam if you have one.

Go to your webcam software and use the following settings, per the WunderCam FTP Wiki:
   "FTP SERVER: webcam.wunderground.com
    Username: You will be provided with a Camera ID on the sign up page in the "Your Current Cameras" box.
    Password: You will need to log in with the same password you use to access the Weather Underground site.
    Directory: We actually move the file for you, so if your software requires a directory you should set it as '/', but otherwise leave it blank.
    Filename: We also change the filename of your image, so a default name can be almost anything you'd like but 'image.jpg' is preferred.
    Binary: Please make sure that you are uploading your images through FTP using the binary setting.
    Image Resolution: There is no minimum or maximum resolution. However, the larger the resolution, the larger the file size, so please adjust your resolution and image quality settings to get the best image within the size limitations. "
If you click on the link which is your CameraID, it will take you to your own webcam page, which displays your current image, date and time, current local conditions, camera type and you will start building a calendar which shows still and videos of each day.

video 

Bookmark this page or link to it from somewhere else for a reliable free weathercam, accessible from anywhere (including from your smartphone). You will also see your webcam included in their weathercam 'library', which is available by clicking on the 'webcams' tab on the weatherunderground site.

Last, monitor your new webcam for a few days and adjust as necessary to reduce glare (clean the glass, inside and out), fine tune the image and make it as useful to you and interesting to others as possible. Finally, If desired, you can submit your webcam to a site such as 'EarthCam', to be included in their listings of worldwide webcams.  As their tagline boasts, "Where the World Watches the World".

As Mark Twain noted, we may not be able to do anything about the weather, but we can monitor it closely and be prepared for it. Your new weathercam makes that easy and fun.

*********************************

My Linux Setup

Install uvccapture, then open Startup Applications and paste the following code into the 'command' section.
uvccapture -m -t600 -q75 -x640 -y480 -o/home/user/webcam/image.jpg
This string of commands loads the program and instructs it to refresh the image every 10 minutes (600 seconds), to use compression on the JPG file at 75% quality. It states the webcam resolution, which must be supported by your device. The last argument includes the location to save the image file.

More info and commands for uvccapture are located here: http://manpages.ubuntu.com/manpages/natty/man1/uvccapture.1.html 

For basic ftp upload of images, try this simple script.
Copy and paste the following into a text editor. Edit lines 4, 5 & 6 in the top section and line 5 in the bottom section:
# vi ftp-run.sh
#! /bin/sh
#run this file with ./ftp-run.sh
REMOTE='your-remote-server.com'
USER='username'
PASSWORD='password'
FTPLOG='/tmp/ftplog'
date >> $FTPLOG

ftp -n $REMOTE <<_FTP>>$FTPLOG
quote USER $USER
quote PASS $PASSWORD
bin
/home/user/webcam-folder
mput image.jpg
quit
_FTP
Save the file as ftp-run.sh in the webcam folder. Right click on the icon and under Permissions, click to 'Run this file as a program'. I set up a cron job to run this script every 10 minutes with this command:
crontab -e
    arrow down to bottom

Paste:
*/10 * * * * cd webcam && ./ftp-run.sh

Ctrl + x to exit
Y to save
Enter

More fun with your webcam: PortalView Live Desktop Wallpaper for Linux

7 comments:

  1. I want to use webcamd using Linux Mint. I am currently using fwink and Windows, but want to make the switch to Linux because the PC I am using is old and needs an OS that uses fewer resources. Anyway, I cannot get webcamd to work. Any advise beyond the webcamd info above? I cannot find a tutorial anywhere. Also, is there a way to have a specific jpeg file uploaded via ftp? Currently, the name of my webcam file is webcam.jpeg, but there is nowhere in the above config file to specify a file name to upload.

    ReplyDelete
    Replies
    1. Webcamd took me a while to get working. You are right, there is very little info on the web.

      A few things I remember fighting with:
      In the .webcamd folder, I had to create dummy files called 'index.html, index_down.html and index_up.html. The program requires these to be present even if your not self hosting.

      The option for time/date stamp on the photo doesn't work for me and when I enable it, the program stops working. If your config file shows put_date=yes, then change it to 'no'.

      The .webcamd folder should contain two images: webcamd.jpg and pre-webcamd.jpg. If you don't see these files, then create them. The folder also contains a blank file called webcamd.pid .

      Hope this helps.

      Delete
    2. Re the webcamd.jpeg file name:
      As you can see in my config file, the name is not present there either but it is working for me.

      Perhaps the problem exists in your file extension: try using .jpg instead of .jpeg

      Delete
    3. This comment has been removed by the author.

      Delete
  2. Thanks a lot for the quick reply. I'll fiddle some more and let you know if I get it up & running. -Chris

    ReplyDelete
  3. Note:
    The program accepts three commands:
    webcamd start
    webcamd stop
    webcamd refresh

    Make sure you close any programs which may be accessing the webcam, like an image viewer or webcam settings program.
    Start with: webcamd stop
    then: webcamd start

    Once you get it working, add the command webcamd start to your Startup Applications so it will auto start when the computer boots.

    ReplyDelete
  4. If you're still having problems with webcamd posting a 0 length file to the webserver try this link http://markmail.org/thread/6kpmht2dfqck2ro7

    In a nutshell,

    edit /usr/bin/webcamd
    search for 'GIF'
    replace 'GIF' with 'JPG'
    save the file
    restart webcamd

    This fixed the problem for me.

    Good luck,

    John

    ReplyDelete